Skip to content

Commit 72813eb

Browse files
committed
code cleanup (+1 squashed commit)
Squashed commits: [fff7976510] code cleanup
1 parent a05a684 commit 72813eb

8 files changed

Lines changed: 27 additions & 102 deletions

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

Lines changed: 23 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020 Eclipse RDF4J contributors.
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Distribution License v1.0
66
* which accompanies this distribution, and is available at
77
* http://www.eclipse.org/org/documents/edl-v10.php.
88
*
99
* SPDX-License-Identifier: BSD-3-Clause
10-
*******************************************************************************/
10+
******************************************************************************/
1111

1212
package org.eclipse.rdf4j.sail.shacl.ast.constraintcomponents;
1313

@@ -49,11 +49,17 @@ public AbstractPairwiseConstraintComponent(IRI predicate, Shape shape) {
4949
this.shape = shape;
5050
}
5151

52-
abstract IRI getIRI();
52+
/**
53+
* The abstract method that is implemented by the subclasses to return the IRI of the constraint component, e.g.
54+
* sh:equals, sh:disjoint etc.
55+
*
56+
* @return The IRI of the constraint component
57+
*/
58+
abstract IRI getConstraintIri();
5359

5460
@Override
5561
public void toModel(Resource subject, IRI predicate, Model model, Set<Resource> cycleDetection) {
56-
model.add(subject, getIRI(), this.predicate);
62+
model.add(subject, getConstraintIri(), this.predicate);
5763
}
5864

5965
@Override
@@ -112,6 +118,18 @@ public PlanNode generateTransactionalValidationPlan(ConnectionsGroup connections
112118
return getPairwiseCheck(connectionsGroup, validationSettings, allTargets, subject, object, targetQueryFragment);
113119
}
114120

121+
/**
122+
* The abstract method that is implemented by the subclasses to add the pairwise check as a PlanNode to the
123+
* validation plan.
124+
*
125+
* @param connectionsGroup
126+
* @param validationSettings
127+
* @param allTargets
128+
* @param subject
129+
* @param object
130+
* @param targetQueryFragment
131+
* @return The PlanNode that performs the pairwise check
132+
*/
115133
abstract PlanNode getPairwiseCheck(ConnectionsGroup connectionsGroup, ValidationSettings validationSettings,
116134
PlanNode allTargets, StatementMatcher.Variable<Resource> subject, StatementMatcher.Variable<Value> object,
117135
SparqlFragment targetQueryFragment);
@@ -136,55 +154,6 @@ private PlanNode getAllTargetsBasedOnPredicate(ConnectionsGroup connectionsGroup
136154
return Unique.getInstance(UnionNode.getInstance(targetFilter1, targetFilter2), false);
137155
}
138156

139-
// @Override
140-
// public PlanNode getAllTargetsPlan(ConnectionsGroup connectionsGroup, Resource[] dataGraph, Scope scope,
141-
// StatementMatcher.StableRandomVariableProvider stableRandomVariableProvider) {
142-
// assert scope == Scope.propertyShape;
143-
//
144-
// PlanNode allTargetsPlan = getTargetChain()
145-
// .getEffectiveTarget(Scope.nodeShape, connectionsGroup.getRdfsSubClassOfReasoner(),
146-
// stableRandomVariableProvider)
147-
// .getPlanNode(connectionsGroup, dataGraph, Scope.nodeShape, true, null);
148-
//
149-
// allTargetsPlan = new ShiftToPropertyShape(allTargetsPlan);
150-
//
151-
// // removed statements that match predicate could affect sh:or
152-
// if (connectionsGroup.getStats().hasRemoved()) {
153-
// PlanNode deletedPredicates = new UnorderedSelect(connectionsGroup.getRemovedStatements(), null, predicate,
154-
// null, dataGraph, UnorderedSelect.Mapper.SubjectScopedMapper.getFunction(Scope.propertyShape));
155-
// deletedPredicates = getTargetChain()
156-
// .getEffectiveTarget(Scope.propertyShape, connectionsGroup.getRdfsSubClassOfReasoner(),
157-
// stableRandomVariableProvider)
158-
// .getTargetFilter(connectionsGroup, dataGraph, deletedPredicates);
159-
// deletedPredicates = getTargetChain()
160-
// .getEffectiveTarget(Scope.propertyShape, connectionsGroup.getRdfsSubClassOfReasoner(),
161-
// stableRandomVariableProvider)
162-
// .extend(deletedPredicates, connectionsGroup, dataGraph, Scope.propertyShape, EffectiveTarget.Extend.left,
163-
// false,
164-
// null);
165-
// allTargetsPlan = UnionNode.getInstanceDedupe(allTargetsPlan, deletedPredicates);
166-
// }
167-
//
168-
// // added statements that match predicate could affect sh:not
169-
// if (connectionsGroup.getStats().hasAdded()) {
170-
// PlanNode addedPredicates = new UnorderedSelect(connectionsGroup.getAddedStatements(), null, predicate,
171-
// null, dataGraph, UnorderedSelect.Mapper.SubjectScopedMapper.getFunction(Scope.propertyShape));
172-
// addedPredicates = getTargetChain()
173-
// .getEffectiveTarget(Scope.propertyShape, connectionsGroup.getRdfsSubClassOfReasoner(),
174-
// stableRandomVariableProvider)
175-
// .getTargetFilter(connectionsGroup, dataGraph, addedPredicates);
176-
// addedPredicates = getTargetChain()
177-
// .getEffectiveTarget(Scope.propertyShape, connectionsGroup.getRdfsSubClassOfReasoner(),
178-
// stableRandomVariableProvider)
179-
// .extend(addedPredicates, connectionsGroup, dataGraph, Scope.propertyShape, EffectiveTarget.Extend.left,
180-
// false,
181-
// null);
182-
// allTargetsPlan = UnionNode.getInstanceDedupe(allTargetsPlan, addedPredicates);
183-
// }
184-
//
185-
// return Unique.getInstance(new TrimToTarget(allTargetsPlan), false);
186-
// }
187-
188157
@Override
189158
public PlanNode getAllTargetsPlan(ConnectionsGroup connectionsGroup, Resource[] dataGraph, Scope scope,
190159
StatementMatcher.StableRandomVariableProvider stableRandomVariableProvider) {
@@ -291,26 +260,6 @@ public boolean requiresEvaluation(ConnectionsGroup connectionsGroup, Scope scope
291260
|| connectionsGroup.getAddedStatements().hasStatement(null, predicate, null, true, dataGraph);
292261
}
293262

294-
@Override
295-
public ValidationApproach getPreferredValidationApproach(ConnectionsGroup connectionsGroup) {
296-
return ValidationApproach.Transactional;
297-
}
298-
299-
@Override
300-
public ValidationApproach getOptimalBulkValidationApproach() {
301-
return ValidationApproach.Transactional;
302-
}
303-
304-
@Override
305-
public ConstraintComponent deepClone() {
306-
throw new UnsupportedOperationException();
307-
}
308-
309-
@Override
310-
public List<Literal> getDefaultMessage() {
311-
return List.of();
312-
}
313-
314263
@Override
315264
public boolean equals(Object o) {
316265
if (this == o) {
@@ -327,7 +276,7 @@ public boolean equals(Object o) {
327276

328277
@Override
329278
public int hashCode() {
330-
return predicate.hashCode() + "LessThanConstraintComponent".hashCode();
279+
return predicate.hashCode() + "AbstractPairwiseConstraintComponent".hashCode();
331280
}
332281

333282
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public DisjointConstraintComponent(IRI predicate, Shape shape) {
3434
}
3535

3636
@Override
37-
IRI getIRI() {
37+
IRI getConstraintIri() {
3838
return SHACL.DISJOINT;
3939
}
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public EqualsConstraintComponent(IRI predicate, Shape shape) {
3434
}
3535

3636
@Override
37-
IRI getIRI() {
37+
IRI getConstraintIri() {
3838
return SHACL.EQUALS;
3939
}
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public LessThanConstraintComponent(IRI predicate, Shape shape) {
3434
}
3535

3636
@Override
37-
IRI getIRI() {
37+
IRI getConstraintIri() {
3838
return SHACL.LESS_THAN;
3939
}
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public LessThanOrEqualsConstraintComponent(IRI predicate, Shape shape) {
3434
}
3535

3636
@Override
37-
IRI getIRI() {
37+
IRI getConstraintIri() {
3838
return SHACL.LESS_THAN_OR_EQUALS;
3939
}
4040

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424

2525
import com.google.common.collect.Sets;
2626

27-
/**
28-
* Used by sh:equals to return any targets and values where the target has values by path that are not values by the
29-
* predicate, or vice versa. It returns the targets and any symmetricDifference values when comparing the set of values
30-
* by path and by predicate.
31-
*
32-
* @author Håvard Ottestad
33-
*/
3427
public class CheckDisjointValuesBasedOnPathAndPredicate extends AbstractPairwisePlanNode {
3528

3629
public CheckDisjointValuesBasedOnPathAndPredicate(SailConnection connection, Resource[] dataGraph, PlanNode parent,

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,14 @@
1919
import org.eclipse.rdf4j.model.Value;
2020
import org.eclipse.rdf4j.query.algebra.Compare;
2121
import org.eclipse.rdf4j.query.algebra.evaluation.util.QueryEvaluationUtility;
22-
import org.eclipse.rdf4j.query.algebra.evaluation.util.ValueComparator;
2322
import org.eclipse.rdf4j.sail.SailConnection;
2423
import org.eclipse.rdf4j.sail.shacl.ast.Shape;
2524
import org.eclipse.rdf4j.sail.shacl.ast.SparqlFragment;
2625
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2726
import org.eclipse.rdf4j.sail.shacl.ast.constraintcomponents.ConstraintComponent;
2827

29-
/**
30-
* Used by sh:equals to return any targets and values where the target has values by path that are not values by the
31-
* predicate, or vice versa. It returns the targets and any symmetricDifference values when comparing the set of values
32-
* by path and by predicate.
33-
*
34-
* @author Håvard Ottestad
35-
*/
3628
public class CheckLessThanOrEqualValuesBasedOnPathAndPredicate extends AbstractPairwisePlanNode {
3729

38-
private final ValueComparator valueComparator = new ValueComparator();
39-
4030
public CheckLessThanOrEqualValuesBasedOnPathAndPredicate(SailConnection connection, Resource[] dataGraph,
4131
PlanNode parent, IRI predicate, StatementMatcher.Variable<Resource> subject,
4232
StatementMatcher.Variable<Value> object, SparqlFragment targetQueryFragment, Shape shape,

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
import org.eclipse.rdf4j.sail.shacl.ast.StatementMatcher;
2727
import org.eclipse.rdf4j.sail.shacl.ast.constraintcomponents.ConstraintComponent;
2828

29-
/**
30-
* Used by sh:equals to return any targets and values where the target has values by path that are not values by the
31-
* predicate, or vice versa. It returns the targets and any symmetricDifference values when comparing the set of values
32-
* by path and by predicate.
33-
*
34-
* @author Håvard Ottestad
35-
*/
3629
public class CheckLessThanValuesBasedOnPathAndPredicate extends AbstractPairwisePlanNode {
3730

3831
private final ValueComparator valueComparator = new ValueComparator();

0 commit comments

Comments
 (0)