Skip to content

Commit

Permalink
Merge branch 'master' of github.com:TopQuadrant/shacl
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleycaselli committed Apr 9, 2024
2 parents 8f1675f + b6494ab commit 3c234ad
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ public void executeConstraint(Constraint constraint, ValidationEngine engine, Co
if(closed) {
long startTime = System.currentTimeMillis();
for(RDFNode focusNode : focusNodes) {
if(focusNode instanceof Resource) {
Iterator<Statement> it = ((Resource)focusNode).listProperties();
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
Resource result = engine.createValidationResult(constraint, focusNode, s.getObject(), () -> "Predicate " + engine.getLabelFunction().apply(s.getPredicate()) + " is not allowed (closed shape)");
result.removeAll(SH.resultPath);
result.addProperty(SH.resultPath, s.getPredicate());
for(RDFNode valueNode : engine.getValueNodes(constraint, focusNode)) {
if(valueNode instanceof Resource) {
Iterator<Statement> it = ((Resource)valueNode).listProperties();
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
Resource result = engine.createValidationResult(constraint, valueNode, s.getObject(), () -> "Predicate " + engine.getLabelFunction().apply(s.getPredicate()) + " is not allowed (closed shape)");
result.removeAll(SH.resultPath);
result.addProperty(SH.resultPath, s.getPredicate());
}
}
engine.checkCanceled();
}
}
engine.checkCanceled();
}
addStatistics(engine, constraint, startTime, focusNodes.size(), focusNodes.size());
}
Expand Down
39 changes: 39 additions & 0 deletions src/test/resources/sh/tests/core/property/closed-001.test.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# baseURI: http://datashapes.org/sh/tests/core/property/closed-001.test
# prefix: ex

@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/property/closed-001.test#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://datashapes.org/sh/tests/core/property/closed-001.test>
rdf:type owl:Ontology ;
rdfs:label "Test of sh:closed at property shape 001" ;
owl:imports <http://datashapes.org/dash> ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "true"^^xsd:boolean ;
] ;
.
ex:Person
a rdfs:Class, sh:NodeShape ;
sh:property [
sh:path ex:knows ;
sh:closed true;
sh:property
[
sh:path ex:name ;
];

] .
ex:validPerson1 a ex:Person ;
ex:knows
[
ex:name "John" ;
] .

0 comments on commit 3c234ad

Please sign in to comment.