This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit 81fefff9ca60b5bd56a6dd82c515c7caf4c46c52 Author: Ali Ariff <[email protected]> AuthorDate: Fri Feb 21 21:18:56 2025 +0100 GH-3018: Introduce operation mode --- .../jena/shacl/engine/constraint/UniqueLangConstraint.java | 4 +++- .../src/main/java/org/apache/jena/shacl/sys/ShaclSystem.java | 12 ++++++++++++ .../src/test/files/std/core/property/uniqueLang-001.ttl | 3 --- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/UniqueLangConstraint.java b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/UniqueLangConstraint.java index 70c31d60bd..b29b5ba5a4 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/UniqueLangConstraint.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/UniqueLangConstraint.java @@ -34,6 +34,7 @@ import org.apache.jena.shacl.engine.ValidationContext; import org.apache.jena.shacl.parser.Constraint; import org.apache.jena.shacl.parser.ConstraintVisitor; import org.apache.jena.shacl.parser.Shape; +import org.apache.jena.shacl.sys.ShaclSystem; import org.apache.jena.shacl.validation.event.ConstraintEvaluatedOnPathNodesEvent; import org.apache.jena.shacl.validation.event.ConstraintEvaluatedOnSinglePathNodeEvent; import org.apache.jena.shacl.vocabulary.SHACL; @@ -78,7 +79,8 @@ public class UniqueLangConstraint implements Constraint { String msg = toString()+" Duplicate langtag: "+obj.getLiteralLanguage(); vCxt.notifyValidationListener(() -> new ConstraintEvaluatedOnSinglePathNodeEvent(vCxt, shape, focusNode, this, path, obj, false)); - vCxt.reportEntry(msg, shape, focusNode, path, obj, this); + Node valueNode = ShaclSystem.getMode().equals(ShaclSystem.Mode.NORMAL) ? obj : null; + vCxt.reportEntry(msg, shape, focusNode, path, valueNode, this); results.add(tag); } seen.add(tag); diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/sys/ShaclSystem.java b/jena-shacl/src/main/java/org/apache/jena/shacl/sys/ShaclSystem.java index 507586a96f..527a4bf858 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/sys/ShaclSystem.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/sys/ShaclSystem.java @@ -36,4 +36,16 @@ public class ShaclSystem { /** The current system-wide {@link ShaclValidator}. */ public static ShaclValidator get() { return globalDefault; } + + /** Mode of operation to indicate environment. */ + public enum Mode { NORMAL, TEST } + + /** Default mode of operation is NORMAL. */ + private static Mode mode = Mode.NORMAL; + + /** Set the mode of operation. */ + public static void setMode(Mode mode) { ShaclSystem.mode = mode; } + + /** Get the mode of operation. */ + public static Mode getMode() { return mode; } } diff --git a/jena-shacl/src/test/files/std/core/property/uniqueLang-001.ttl b/jena-shacl/src/test/files/std/core/property/uniqueLang-001.ttl index 6482bbb1aa..9014c7fa11 100644 --- a/jena-shacl/src/test/files/std/core/property/uniqueLang-001.ttl +++ b/jena-shacl/src/test/files/std/core/property/uniqueLang-001.ttl @@ -64,7 +64,6 @@ ex:ValidInstance1 sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; - sh:value "Myself"@en ; ] ; sh:result [ rdf:type sh:ValidationResult ; @@ -73,7 +72,6 @@ ex:ValidInstance1 sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; - sh:value "I"@en ; ] ; sh:result [ rdf:type sh:ValidationResult ; @@ -82,7 +80,6 @@ ex:ValidInstance1 sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; - sh:value "Ich"@de ; ] ; ] ; mf:status sht:approved ;
