Skip to content

Commit e5b1dd7

Browse files
committed
GH-4770 rsx:actualPairwisePath
1 parent 901570a commit e5b1dd7

26 files changed

Lines changed: 146 additions & 46 deletions

core/model-vocabulary/src/main/java/org/eclipse/rdf4j/model/vocabulary/RSX.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class RSX {
4646
public final static IRI valueConformsToXsdDatatypeFunction = create("valueConformsToXsdDatatypeFunction");
4747

4848
public final static IRI DataAndShapesGraphLink = create("DataAndShapesGraphLink");
49+
public final static IRI actualPairwisePath = create("actualPairwisePath");
4950

5051
private static IRI create(String localName) {
5152
return Vocabularies.createIRI(RSX.NAMESPACE, localName);

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/NodeShape.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ public ConstraintComponent deepClone() {
239239
return nodeShape;
240240
}
241241

242+
@Override
243+
public boolean overrideValidationReport() {
244+
return false;
245+
}
246+
242247
@Override
243248
public SparqlFragment buildSparqlValidNodes_rsx_targetShape(Variable<Value> subject,
244249
Variable<Value> object,

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/PropertyShape.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public PlanNode generateTransactionalValidationPlan(ConnectionsGroup connections
231231
.generateTransactionalValidationPlan(connectionsGroup, validationSettings, overrideTargetNode,
232232
Scope.propertyShape);
233233

234-
if (!(constraintComponent instanceof PropertyShape)) {
234+
if (!(constraintComponent instanceof PropertyShape) && !constraintComponent.overrideValidationReport()) {
235235
validationPlanNode = new ValidationReportNode(validationPlanNode, t -> {
236236
return new ValidationResult(t.getActiveTarget(), t.getValue(), this,
237237
constraintComponent, getSeverity(), t.getScope(), t.getContexts(),
@@ -315,6 +315,11 @@ public ConstraintComponent deepClone() {
315315
return nodeShape;
316316
}
317317

318+
@Override
319+
public boolean overrideValidationReport() {
320+
return false;
321+
}
322+
318323
@Override
319324
public SparqlFragment buildSparqlValidNodes_rsx_targetShape(Variable<Value> subject,
320325
Variable<Value> object,

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/Shape.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,23 @@ List<ConstraintComponent> getConstraintComponents(ShaclProperties properties, Sh
309309
}
310310

311311
for (IRI iri : properties.getEquals()) {
312-
var equalsConstraintComponent = new EqualsConstraintComponent(iri);
312+
var equalsConstraintComponent = new EqualsConstraintComponent(iri, this);
313313
constraintComponent.add(equalsConstraintComponent);
314314
}
315315

316316
for (IRI iri : properties.getDisjoint()) {
317-
var disjointConstraintComponent = new DisjointConstraintComponent(iri);
317+
var disjointConstraintComponent = new DisjointConstraintComponent(iri, this);
318318
constraintComponent.add(disjointConstraintComponent);
319319
}
320320

321321
for (IRI iri : properties.getLessThan()) {
322-
var lessThanConstraintComponent = new LessThanConstraintComponent(iri);
322+
var lessThanConstraintComponent = new LessThanConstraintComponent(iri, this);
323323
constraintComponent.add(lessThanConstraintComponent);
324324
}
325325

326326
for (IRI iri : properties.getLessThanOrEquals()) {
327327
var lessThanOrEqualsConstraintComponent = new LessThanOrEqualsConstraintComponent(
328-
iri);
328+
iri, this);
329329
constraintComponent.add(lessThanOrEqualsConstraintComponent);
330330
}
331331

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/AbstractConstraintComponent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,8 @@ static PlanNode getAllTargetsIncludingThoseAddedByPath(ConnectionsGroup connecti
174174
return allTargets;
175175
}
176176

177+
@Override
178+
public boolean overrideValidationReport() {
179+
return false;
180+
}
177181
}

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/AbstractPairwiseConstraintComponent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.eclipse.rdf4j.model.Resource;
2222
import org.eclipse.rdf4j.model.Value;
2323
import org.eclipse.rdf4j.sail.shacl.ValidationSettings;
24+
import org.eclipse.rdf4j.sail.shacl.ast.Shape;
2425
import org.eclipse.rdf4j.sail.shacl.ast.SparqlFragment;
2526
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2627
import org.eclipse.rdf4j.sail.shacl.ast.ValidationApproach;
@@ -39,10 +40,12 @@
3940

4041
abstract class AbstractPairwiseConstraintComponent extends AbstractConstraintComponent {
4142

42-
IRI predicate;
43+
final Shape shape;
44+
final IRI predicate;
4345

44-
public AbstractPairwiseConstraintComponent(IRI predicate) {
46+
public AbstractPairwiseConstraintComponent(IRI predicate, Shape shape) {
4547
this.predicate = predicate;
48+
this.shape = shape;
4649
}
4750

4851
abstract IRI getIRI();
@@ -229,4 +232,9 @@ public boolean equals(Object o) {
229232
public int hashCode() {
230233
return predicate.hashCode() + "LessThanConstraintComponent".hashCode();
231234
}
235+
236+
@Override
237+
public boolean overrideValidationReport() {
238+
return true;
239+
}
232240
}

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/ConstraintComponent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ SparqlFragment buildSparqlValidNodes_rsx_targetShape(Variable<Value> subject,
7373

7474
List<Literal> getDefaultMessage();
7575

76+
boolean overrideValidationReport();
77+
7678
enum Scope {
7779
none,
7880
nodeShape,

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/DisjointConstraintComponent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.rdf4j.model.vocabulary.SHACL;
2121
import org.eclipse.rdf4j.sail.shacl.SourceConstraintComponent;
2222
import org.eclipse.rdf4j.sail.shacl.ValidationSettings;
23+
import org.eclipse.rdf4j.sail.shacl.ast.Shape;
2324
import org.eclipse.rdf4j.sail.shacl.ast.SparqlFragment;
2425
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2526
import org.eclipse.rdf4j.sail.shacl.ast.planNodes.CheckDisjointValuesBasedOnPathAndPredicate;
@@ -28,8 +29,8 @@
2829

2930
public class DisjointConstraintComponent extends AbstractPairwiseConstraintComponent {
3031

31-
public DisjointConstraintComponent(IRI predicate) {
32-
super(predicate);
32+
public DisjointConstraintComponent(IRI predicate, Shape shape) {
33+
super(predicate, shape);
3334
}
3435

3536
@Override
@@ -46,12 +47,13 @@ PlanNode getPairwiseCheck(ConnectionsGroup connectionsGroup, ValidationSettings
4647
PlanNode allTargets, StatementMatcher.Variable<Resource> subject, StatementMatcher.Variable<Value> object,
4748
SparqlFragment targetQueryFragment) {
4849
return new CheckDisjointValuesBasedOnPathAndPredicate(connectionsGroup.getBaseConnection(),
49-
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment);
50+
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment, shape,
51+
this);
5052
}
5153

5254
@Override
5355
public ConstraintComponent deepClone() {
54-
return new DisjointConstraintComponent(predicate);
56+
return new DisjointConstraintComponent(predicate, shape);
5557
}
5658

5759
@Override

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/EqualsConstraintComponent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.rdf4j.model.vocabulary.SHACL;
2121
import org.eclipse.rdf4j.sail.shacl.SourceConstraintComponent;
2222
import org.eclipse.rdf4j.sail.shacl.ValidationSettings;
23+
import org.eclipse.rdf4j.sail.shacl.ast.Shape;
2324
import org.eclipse.rdf4j.sail.shacl.ast.SparqlFragment;
2425
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2526
import org.eclipse.rdf4j.sail.shacl.ast.planNodes.CheckEqualsValuesBasedOnPathAndPredicate;
@@ -28,8 +29,8 @@
2829

2930
public class EqualsConstraintComponent extends AbstractPairwiseConstraintComponent {
3031

31-
public EqualsConstraintComponent(IRI predicate) {
32-
super(predicate);
32+
public EqualsConstraintComponent(IRI predicate, Shape shape) {
33+
super(predicate, shape);
3334
}
3435

3536
@Override
@@ -46,12 +47,13 @@ CheckEqualsValuesBasedOnPathAndPredicate getPairwiseCheck(ConnectionsGroup conne
4647
ValidationSettings validationSettings, PlanNode allTargets, StatementMatcher.Variable<Resource> subject,
4748
StatementMatcher.Variable<Value> object, SparqlFragment targetQueryFragment) {
4849
return new CheckEqualsValuesBasedOnPathAndPredicate(connectionsGroup.getBaseConnection(),
49-
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment);
50+
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment, shape,
51+
this);
5052
}
5153

5254
@Override
5355
public ConstraintComponent deepClone() {
54-
return new EqualsConstraintComponent(predicate);
56+
return new EqualsConstraintComponent(predicate, shape);
5557
}
5658

5759
@Override

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/LessThanConstraintComponent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.rdf4j.model.vocabulary.SHACL;
2121
import org.eclipse.rdf4j.sail.shacl.SourceConstraintComponent;
2222
import org.eclipse.rdf4j.sail.shacl.ValidationSettings;
23+
import org.eclipse.rdf4j.sail.shacl.ast.Shape;
2324
import org.eclipse.rdf4j.sail.shacl.ast.SparqlFragment;
2425
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2526
import org.eclipse.rdf4j.sail.shacl.ast.planNodes.CheckLessThanValuesBasedOnPathAndPredicate;
@@ -28,8 +29,8 @@
2829

2930
public class LessThanConstraintComponent extends AbstractPairwiseConstraintComponent {
3031

31-
public LessThanConstraintComponent(IRI predicate) {
32-
super(predicate);
32+
public LessThanConstraintComponent(IRI predicate, Shape shape) {
33+
super(predicate, shape);
3334
}
3435

3536
@Override
@@ -46,12 +47,13 @@ PlanNode getPairwiseCheck(ConnectionsGroup connectionsGroup, ValidationSettings
4647
PlanNode allTargets, StatementMatcher.Variable<Resource> subject, StatementMatcher.Variable<Value> object,
4748
SparqlFragment targetQueryFragment) {
4849
return new CheckLessThanValuesBasedOnPathAndPredicate(connectionsGroup.getBaseConnection(),
49-
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment);
50+
validationSettings.getDataGraph(), allTargets, predicate, subject, object, targetQueryFragment, shape,
51+
this);
5052
}
5153

5254
@Override
5355
public ConstraintComponent deepClone() {
54-
return new LessThanConstraintComponent(predicate);
56+
return new LessThanConstraintComponent(predicate, shape);
5557
}
5658

5759
@Override

0 commit comments

Comments
 (0)