Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
angelip2303 committed Nov 13, 2024
1 parent 3193851 commit cd64b11
Show file tree
Hide file tree
Showing 88 changed files with 854 additions and 572 deletions.
6 changes: 3 additions & 3 deletions rudof_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use shapes_converter::{ImageFormat, ShEx2Html, ShEx2Uml, Shacl2ShEx, Tap2ShEx, U
use shex_ast::object_value::ObjectValue;
use shex_ast::{ShapeExprLabel, SimpleReprSchema};
use sparql_service::{QueryConfig, RdfData, ServiceDescription};
use srdf::srdf_graph::SRDFGraph;
use srdf::srdf_graph::GenericGraph;
use srdf::{
QuerySolution, RDFFormat, RdfDataConfig, ReaderMode, SRDFBuilder, SRDFSparql, VarName, SRDF,
};
Expand Down Expand Up @@ -1509,8 +1509,8 @@ fn parse_data(
data_format: &DataFormat,
reader_mode: &RDFReaderMode,
config: &RdfDataConfig,
) -> Result<SRDFGraph> {
let mut graph = SRDFGraph::new();
) -> Result<GenericGraph> {
let mut graph = GenericGraph::new();
let rdf_format = data_format2rdf_format(data_format);
for d in data {
let reader = d.open_read(Some(data_format.mime_type().as_str()))?;
Expand Down
6 changes: 3 additions & 3 deletions rudof_lib/src/rudof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use shex_ast::compiled::compiled_schema::CompiledSchema;
use shex_compact::ShExParser;
use shex_validation::{ResolveMethod, SchemaWithoutImports};
use sparql_service::RdfData;
use srdf::{FocusRDF, SRDFGraph};
use srdf::{FocusRDF, GenericGraph};
use std::fmt::Debug;
use std::path::Path;
use std::str::FromStr;
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Rudof {
}
_ => {
let data_format = shacl_format2rdf_format(format)?;
let mut shacl_writer: ShaclWriter<SRDFGraph> = ShaclWriter::new();
let mut shacl_writer: ShaclWriter<GenericGraph> = ShaclWriter::new();
shacl_writer
.write(shacl)
.map_err(|e| RudofError::WritingSHACL {
Expand Down Expand Up @@ -305,7 +305,7 @@ impl Rudof {
}?;

let rdf_graph =
SRDFGraph::from_reader(reader, &format, base, reader_mode).map_err(|e| {
GenericGraph::from_reader(reader, &format, base, reader_mode).map_err(|e| {
RudofError::ReadError {
error: format!("{e}"),
}
Expand Down
6 changes: 4 additions & 2 deletions shacl_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ homepage.workspace = true
repository.workspace = true

[features]
rdf-star = ["oxrdf/rdf-star", "srdf/rdf-star"]
# rdf-star = ["oxrdf/rdf-star", "srdf/rdf-star"]
rdf-star = []

[dependencies]
api = { workspace = true }
srdf = { workspace = true }
# srdf = { workspace = true }
iri_s = { workspace = true }
rbe = { workspace = true }
prefixmap = { workspace = true }

serde = "1"
serde_derive = "1"
void = "1"
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use iri_s::{iri, IriS};
use itertools::Itertools;
use oxrdf::{Literal as OxLiteral, NamedNode, Term as OxTerm};
use prefixmap::IriRef;
use srdf::{lang::Lang, literal::Literal, RDFNode, SRDFBuilder, XSD_INTEGER_STR};
use std::fmt::Display;

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/message_map.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use oxrdf::{Literal as OxLiteral, Term as OxTerm};
use srdf::lang::Lang;
use std::collections::HashMap;
use std::str::FromStr;

Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/node_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
};
use iri_s::iri;
use oxrdf::{Literal as OxLiteral, Term as OxTerm};
use srdf::{RDFNode, SRDFBuilder};
use std::fmt::Display;

#[derive(Debug, Clone)]
Expand Down
4 changes: 0 additions & 4 deletions shacl_ast/src/ast/property_shape.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use iri_s::{iri, IriS};
use oxrdf::{BlankNode, Literal as OxLiteral, NamedNode, Subject, Term as OxTerm};
use srdf::{
numeric_literal::NumericLiteral, RDFNode, SHACLPath, SRDFBuilder, SRDFGraph, SRDF,
XSD_DECIMAL_STR,
};
use std::{collections::HashSet, fmt::Display};

use crate::{
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{collections::HashMap, fmt::Display};
use crate::shape::Shape;
use iri_s::IriS;
use prefixmap::PrefixMap;
use srdf::RDFNode;

#[derive(Debug, Clone, Default)]
pub struct Schema {
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/shacl_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use srdf::RDFNode;
use thiserror::Error;

#[derive(Debug, Error)]
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/shape.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use srdf::SRDFBuilder;
use std::fmt::Display;

use crate::{node_shape::NodeShape, property_shape::PropertyShape};
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fmt::Display;

use crate::{SH_TARGET_CLASS_STR, SH_TARGET_NODE_STR};
use prefixmap::IriRef;
use srdf::{RDFNode, SRDFBuilder};

#[derive(Debug, Clone)]
pub enum Target {
Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/ast/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fmt::Display;

use iri_s::IriS;
use prefixmap::IriRef;
use srdf::literal::Literal;

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum Value {
Expand Down
2 changes: 0 additions & 2 deletions shacl_ast/src/compiled/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use super::shape::CompiledShape;
use iri_s::iri;
use iri_s::IriS;
use node_kind::NodeKind;
use srdf::RDFNode;
use srdf::SRDFBasic;

#[derive(Debug)]
pub enum CompiledComponent<S: SRDFBasic> {
Expand Down
5 changes: 0 additions & 5 deletions shacl_ast/src/compiled/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use compiled_shacl_error::CompiledShaclError;
use prefixmap::IriRef;
use shape::CompiledShape;
use srdf::lang::Lang;
use srdf::literal::Literal;
use srdf::Object;
use srdf::RDFNode;
use srdf::SRDFBasic;

use crate::value::Value;
use crate::Schema;
Expand Down
2 changes: 0 additions & 2 deletions shacl_ast/src/compiled/node_shape.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::collections::HashSet;

use srdf::SRDFBasic;

use crate::node_shape::NodeShape;
use crate::Schema;

Expand Down
3 changes: 0 additions & 3 deletions shacl_ast/src/compiled/property_shape.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::collections::HashSet;

use srdf::SHACLPath;
use srdf::SRDFBasic;

use crate::property_shape::PropertyShape;
use crate::Schema;

Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/compiled/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use api::model::rdf::Predicate;
use api::model::rdf::Rdf;
use api::model::Subject;
use prefixmap::PrefixMap;
use srdf::SRDFBasic;

use crate::Schema;

Expand Down
1 change: 0 additions & 1 deletion shacl_ast/src/compiled/severity.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use iri_s::iri;
use iri_s::IriS;
use srdf::SRDFBasic;

use crate::severity::Severity;
use crate::*;
Expand Down
2 changes: 0 additions & 2 deletions shacl_ast/src/compiled/shape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use srdf::SRDFBasic;

use crate::shape::Shape;
use crate::Schema;

Expand Down
2 changes: 0 additions & 2 deletions shacl_ast/src/compiled/target.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use srdf::SRDFBasic;

use crate::target::Target;

use super::compiled_shacl_error::CompiledShaclError;
Expand Down
7 changes: 0 additions & 7 deletions shacl_ast/src/converter/rdf_to_shacl/shacl_parser_error.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
use crate::ShaclError;
use srdf::RDFParseError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ShaclParserError {
#[error("RDF parse error: {err}")]
RDFParseError {
#[from]
err: RDFParseError,
},

#[error("Expected RDFNode parsing node shape, found: {term}")]
ExpectedRDFNodeNodeShape { term: String },

Expand Down
9 changes: 5 additions & 4 deletions shacl_validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ categories.workspace = true
edition.workspace = true

[features]
rdf-star = ["srdf/rdf-star"]
rdf-star = [] # TODO: API with the rdf-star feature

[dependencies]
api = { workspace = true }
iri_s = { workspace = true }
prefixmap = { workspace = true }
shacl_ast = { workspace = true }
iri_s = { workspace = true } # TODO: is this necessary?
prefixmap = { workspace = true } # TODO: is this necessary?

serde = { version = "1.0", features = ["derive"] } # needed for the config thing
thiserror = { workspace = true } # needed for the definition of errors
Expand All @@ -28,6 +29,6 @@ clap = { workspace = true } # needed for creating the Val
serde_yml = { workspace = true } # needed for the config thing
colored = { workspace = true }

[dev-dependencies]
[dev-dependencies] # necessary for the tests
sparql_service = { workspace = true }
oxrdf = { workspace = true }
13 changes: 6 additions & 7 deletions shacl_validation/src/constraints/core/cardinality/max_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,25 @@ impl<T: Triple> Validator<T> for MaxCount {
value_nodes: &ValueNodes<S>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
let max_count = |targets: &FocusNodes<S>| targets.len() > self.max_count();
validate_native_with_strategy(
component,
shape,
value_nodes,
FocusNodeIteration,
max_count,
|targets: &FocusNodes<S>| targets.len() > self.max_count(),
subsetting,
)
}
}

// TODO: is it necessary having a 'static?
impl<S: SRDF + Debug + 'static> NativeValidator<S> for MaxCount {
impl<R: Rdf> NativeValidator<R> for MaxCount {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ impl<T: Triple> Validator<T> for MinCount {
impl<R: Rdf> NativeValidator<R> for MinCount {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/logical/and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl<T: Triple> Validator<T> for And<R> {
impl<R: Rdf> NativeValidator<R> for And<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/logical/not.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl<T: Triple> Validator<T> for Not<S> {
impl<R: Rdf> NativeValidator<R> for Not<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/logical/or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ impl<T: Triple> Validator<T> for Or<S> {
impl<R: Rdf> NativeValidator<R> for Or<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/logical/xone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl<T: Triple> Validator<T> for Xone<S> {
impl<R: Rdf> NativeValidator<R> for Xone<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/other/closed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ impl<T: Triple> Validator<T> for Closed<S> {
impl<R: Rdf> NativeValidator<R> for Closed<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/other/has_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ impl<T: Triple> Validator<T> for HasValue<S> {
impl<R: Rdf> NativeValidator<R> for HasValue<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
8 changes: 4 additions & 4 deletions shacl_validation/src/constraints/core/other/in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ impl<T: Triple> Validator<T> for In<S> {
impl<R: Rdf> NativeValidator<R> for In<S> {
fn validate_native(
&self,
component: &CompiledComponent<S>,
shape: &CompiledShape<S>,
store: &Store<S>,
value_nodes: &ValueNodes<S>,
component: &CompiledComponent<R>,
shape: &CompiledShape<R>,
store: &Store<R>,
value_nodes: &ValueNodes<R>,
subsetting: &Subsetting,
) -> Result<Vec<ValidationResult>, ConstraintError> {
self.validate(
Expand Down
Loading

0 comments on commit cd64b11

Please sign in to comment.