diff --git a/shacl_ast/src/ast/component.rs b/shacl_ast/src/ast/component.rs index 1391bcf1..21cf239f 100644 --- a/shacl_ast/src/ast/component.rs +++ b/shacl_ast/src/ast/component.rs @@ -124,8 +124,8 @@ impl Component { } } Self::UniqueLang(value) => { - Self::write_literal( - &Literal::BooleanLiteral(*value), + Self::write_boolean( + *value, SH_UNIQUE_LANG_STR, rdf_node, rdf, @@ -175,8 +175,8 @@ impl Component { is_closed, ignored_properties, } => { - Self::write_literal( - &Literal::BooleanLiteral(*is_closed), + Self::write_boolean( + *is_closed, SH_CLOSED_STR, rdf_node, rdf, @@ -235,8 +235,8 @@ impl Component { } if let Some(value) = qualified_value_shapes_disjoint { - Self::write_literal( - &Literal::BooleanLiteral(*value), + Self::write_boolean( + *value, SH_QUALIFIED_MAX_COUNT_STR, rdf_node, rdf, @@ -266,6 +266,20 @@ impl Component { Self::write_term(&RDF::term_s2term(&term), predicate, rdf_node, rdf) } + fn write_boolean( + value: bool, + predicate: &str, + rdf_node: &RDFNode, + rdf: &mut RDF, + ) -> Result<(), RDF::Err> + where + RDF: SRDFBuilder, + { + let term = OxTerm::Literal(OxLiteral::from(value)); + + Self::write_term(&RDF::term_s2term(&term), predicate, rdf_node, rdf) + } + fn write_literal( value: &Literal, predicate: &str, diff --git a/shacl_ast/src/ast/node_shape.rs b/shacl_ast/src/ast/node_shape.rs index 75f2b130..697145c7 100644 --- a/shacl_ast/src/ast/node_shape.rs +++ b/shacl_ast/src/ast/node_shape.rs @@ -1,8 +1,4 @@ -use crate::{ - component::Component, message_map::MessageMap, severity::Severity, target::Target, - SH_DEACTIVATED_STR, SH_DESCRIPTION_STR, SH_GROUP_STR, SH_INFO_STR, SH_NAME_STR, SH_NODE_SHAPE, - SH_PROPERTY_STR, SH_SEVERITY_STR, SH_VIOLATION_STR, SH_WARNING_STR, -}; +use crate::{component::Component, message_map::MessageMap, severity::Severity, target::Target, SH_DEACTIVATED_STR, SH_DESCRIPTION_STR, SH_GROUP_STR, SH_INFO_STR, SH_NAME_STR, SH_NODE_SHAPE, SH_PROPERTY_STR, SH_SEVERITY_STR, SH_VIOLATION_STR, SH_WARNING_STR, SH_CLOSED_STR}; use iri_s::iri; use oxrdf::{Literal as OxLiteral, Term as OxTerm}; use srdf::{RDFNode, SRDFBuilder}; @@ -143,6 +139,16 @@ impl NodeShape { )?; } + if self.closed { + let term = OxTerm::Literal(OxLiteral::from(true)); + + rdf.add_triple( + &RDF::object_as_subject(&self.id).unwrap(), + &RDF::iri_s2iri(&iri!(SH_CLOSED_STR)), + &RDF::term_s2term(&term), + )?; + } + Ok(()) } }