Skip to content

Commit

Permalink
fix(validation): preferred constraint executor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleycaselli committed Jan 10, 2024
1 parent bb9e8bb commit d63504c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public boolean isCore() {
// Not entirely correct - someone may define their own component in the SH namespace, but close enough
return SH.NS.equals(getNameSpace()) &&
!SH.JSConstraintComponent.equals(this) &&
!SH.SPARQLConstraintComponent.equals(this);
!SH.SPARQLConstraintComponent.equals(this) &&
!SH.PyConstraintComponent.equals(this);
}
}
6 changes: 3 additions & 3 deletions src/main/java/org/topbraid/shacl/util/SHACLPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public static boolean isProduceFailuresMode() {

public static void setJSPreferred(boolean value) {
jsPreferred = value;
ConstraintExecutors.get().setPyPreferred(value);
SHACLFunctionDriver.setPyPreferred(value);
ConstraintExecutors.get().setJSPreferred(value);
SHACLFunctionDriver.setJSPreferred(value);
CustomTargets.get().setJSPreferred(value);
}

public static void setPyPreferred(boolean value) {
jsPreferred = value;
pyPreferred = value;
ConstraintExecutors.get().setPyPreferred(value);
SHACLFunctionDriver.setPyPreferred(value);
//CustomTargets.get().setPyPreferred(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,25 @@ public void removeSpecialExecutor(Resource constraintComponent) {


/**
* Can be used to make the JavaScript engine the preferred implementation over SPARQL.
* Can be used to make the JavaScript engine the preferred implementation to SPARQL.
* By default, SPARQL is preferred.
* In cases where a constraint component has multiple validators, it would then chose
* In cases where a constraint component has multiple validators, it would then choose
* the JavaScript one.
*
* @param value true to make JS
*/
public void setJSPreferred(boolean value) {
languages.remove(0);
languages.remove(0);
languages.remove(0);
if (value) {
languages.add(0, JSValidationLanguage.get());
languages.add(1, SPARQLValidationLanguage.get());
languages.add(1, PyValidationLanguage.get());
} else {
languages.add(0, SPARQLValidationLanguage.get());
languages.add(1, JSValidationLanguage.get());
languages.add(2, PyValidationLanguage.get());
}
}

Expand All @@ -129,8 +132,8 @@ public void setPyPreferred(boolean value) {
languages.add(1, JSValidationLanguage.get());
languages.add(2, SPARQLValidationLanguage.get());
} else {
languages.add(0, SPARQLValidationLanguage.get());
languages.add(1, JSValidationLanguage.get());
languages.add(0, JSValidationLanguage.get());
languages.add(1, SPARQLValidationLanguage.get());
languages.add(2, PyValidationLanguage.get());
}
}
Expand Down

0 comments on commit d63504c

Please sign in to comment.