Search is not available for this dataset
id
stringlengths 1
8
| text
stringlengths 72
9.81M
| addition_count
int64 0
10k
| commit_subject
stringlengths 0
3.7k
| deletion_count
int64 0
8.43k
| file_extension
stringlengths 0
32
| lang
stringlengths 1
94
| license
stringclasses 10
values | repo_name
stringlengths 9
59
|
---|---|---|---|---|---|---|---|---|
200 | <NME> LanguageExamplePropertyShape.test.ttl
<BEF> ADDFILE
<MSG> Generalized sh:sparql for property shapes
<DFF> @@ -0,0 +1,61 @@
+# baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.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/sparql/property/LanguageExamplePropertyShape.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of LanguageExamplePropertyShape" ;
+ owl:imports <http://datashapes.org/dash> ;
+ owl:versionInfo "Created with TopBraid Composer" ;
+.
+ex:Country
+ rdf:type rdfs:Class ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidCountry ;
+ sh:resultPath ex:germanLabel ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:value "Spain"@en ;
+ ] ;
+ ] ;
+.
+ex:InvalidCountry
+ rdf:type ex:Country ;
+ ex:germanLabel "Spain"@en ;
+.
+ex:LanguageExamplePropertyShape
+ rdf:type sh:PropertyShape ;
+ sh:path ex:germanLabel ;
+ sh:sparql [
+ rdf:type sh:SPARQLConstraint ;
+ sh:message "Values are literals with German language tag." ;
+ sh:prefixes ex: ;
+ sh:select """
+ SELECT $this ?value
+ WHERE {
+ $this $PATH ?value .
+ FILTER (!isLiteral(?value) || !langMatches(lang(?value), \"de\"))
+ }
+ """ ;
+ ] ;
+ sh:targetClass ex:Country ;
+.
+ex:ValidCountry
+ rdf:type ex:Country ;
+ ex:germanLabel "Spanien"@de ;
+.
| 61 | Generalized sh:sparql for property shapes | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
201 | <NME> LanguageExamplePropertyShape.test.ttl
<BEF> ADDFILE
<MSG> Generalized sh:sparql for property shapes
<DFF> @@ -0,0 +1,61 @@
+# baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.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/sparql/property/LanguageExamplePropertyShape.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of LanguageExamplePropertyShape" ;
+ owl:imports <http://datashapes.org/dash> ;
+ owl:versionInfo "Created with TopBraid Composer" ;
+.
+ex:Country
+ rdf:type rdfs:Class ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidCountry ;
+ sh:resultPath ex:germanLabel ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:value "Spain"@en ;
+ ] ;
+ ] ;
+.
+ex:InvalidCountry
+ rdf:type ex:Country ;
+ ex:germanLabel "Spain"@en ;
+.
+ex:LanguageExamplePropertyShape
+ rdf:type sh:PropertyShape ;
+ sh:path ex:germanLabel ;
+ sh:sparql [
+ rdf:type sh:SPARQLConstraint ;
+ sh:message "Values are literals with German language tag." ;
+ sh:prefixes ex: ;
+ sh:select """
+ SELECT $this ?value
+ WHERE {
+ $this $PATH ?value .
+ FILTER (!isLiteral(?value) || !langMatches(lang(?value), \"de\"))
+ }
+ """ ;
+ ] ;
+ sh:targetClass ex:Country ;
+.
+ex:ValidCountry
+ rdf:type ex:Country ;
+ ex:germanLabel "Spanien"@de ;
+.
| 61 | Generalized sh:sparql for property shapes | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
202 | <NME> TestDASHTestCases.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.util.FileUtils;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.js.JSScriptEngine;
import org.topbraid.shacl.js.JSScriptEngineFactory;
import org.topbraid.shacl.js.NashornScriptEngine;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
import org.topbraid.shacl.util.SHACLSystemModel;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
static {
// Redirect loading of text JS files to local folder
JSScriptEngineFactory.set(new JSScriptEngineFactory() {
@Override
public JSScriptEngine createScriptEngine() {
return new NashornScriptEngine() {
@Override
protected Reader createScriptReader(String url) throws Exception {
if(DASH_JS.equals(url)) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/dash.js"));
}
else if(RDFQUERY_JS.equals(url)) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/rdfquery.js"));
}
else if(url.startsWith("http://datashapes.org/js/")) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream(url.substring(21)));
}
else {
return new InputStreamReader(new URL(url).openStream());
}
}
};
}
});
}
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
List<TestCase> testCases = new LinkedList<TestCase>();
File rootFolder = new File("src/test/resources");
collectTestCases(rootFolder, testCases);
List<Object[]> results = new LinkedList<Object[]>();
for(TestCase testCase : testCases) {
results.add(new Object[]{ testCase });
}
return results;
}
private static void collectTestCases(File folder, List<TestCase> testCases) throws Exception {
for(File f : folder.listFiles()) {
if(f.isDirectory()) {
collectTestCases(f, testCases);
}
else if(f.isFile() && f.getName().endsWith(".ttl")) {
Model testModel = JenaUtil.createDefaultModel();
InputStream is = new FileInputStream(f);
testModel.read(is, "urn:dummy", FileUtils.langTurtle);
testModel.add(SHACLSystemModel.getSHACLModel());
Resource ontology = testModel.listStatements(null, OWL.imports, ResourceFactory.createResource(DASH.BASE_URI)).next().getSubject();
for(TestCaseType type : TestCaseTypes.getTypes()) {
testCases.addAll(type.getTestCases(testModel, ontology));
}
}
}
}
private TestCase testCase;
public TestDASHTestCases(TestCase testCase) {
this.testCase = testCase;
}
@Test
public void testTestCase() {
System.out.println(" - " + testCase.getResource());
Model results = JenaUtil.createMemoryModel();
try {
testCase.run(results);
}
catch(Exception ex) {
testCase.createFailure(results, "Exception during test case execution: " + ex);
ex.printStackTrace();
}
for(Statement s : results.listStatements(null, RDF.type, DASH.FailureTestCaseResult).toList()) {
String message = JenaUtil.getStringProperty(s.getSubject(), SH.resultMessage);
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(testCase.getResource() + ": " + message);
}
}
}
<MSG> Synching up with latest TopBraid code base. Deleted SHACL-JS support to avoid Nashorn/Graal issues with Java 11 onwards, and since we have moved to https://datashapes.org/active/
<DFF> @@ -19,9 +19,6 @@ package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -39,9 +36,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
-import org.topbraid.shacl.js.JSScriptEngine;
-import org.topbraid.shacl.js.JSScriptEngineFactory;
-import org.topbraid.shacl.js.NashornScriptEngine;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
@@ -51,32 +45,6 @@ import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
-
- static {
- // Redirect loading of text JS files to local folder
- JSScriptEngineFactory.set(new JSScriptEngineFactory() {
- @Override
- public JSScriptEngine createScriptEngine() {
- return new NashornScriptEngine() {
- @Override
- protected Reader createScriptReader(String url) throws Exception {
- if(DASH_JS.equals(url)) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/dash.js"));
- }
- else if(RDFQUERY_JS.equals(url)) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/rdfquery.js"));
- }
- else if(url.startsWith("http://datashapes.org/js/")) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream(url.substring(21)));
- }
- else {
- return new InputStreamReader(new URL(url).openStream());
- }
- }
- };
- }
- });
- }
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
| 0 | Synching up with latest TopBraid code base. Deleted SHACL-JS support to avoid Nashorn/Graal issues with Java 11 onwards, and since we have moved to https://datashapes.org/active/ | 32 | .java | java | apache-2.0 | TopQuadrant/shacl |
203 | <NME> TestDASHTestCases.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.util.FileUtils;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.js.JSScriptEngine;
import org.topbraid.shacl.js.JSScriptEngineFactory;
import org.topbraid.shacl.js.NashornScriptEngine;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
import org.topbraid.shacl.util.SHACLSystemModel;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
static {
// Redirect loading of text JS files to local folder
JSScriptEngineFactory.set(new JSScriptEngineFactory() {
@Override
public JSScriptEngine createScriptEngine() {
return new NashornScriptEngine() {
@Override
protected Reader createScriptReader(String url) throws Exception {
if(DASH_JS.equals(url)) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/dash.js"));
}
else if(RDFQUERY_JS.equals(url)) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/rdfquery.js"));
}
else if(url.startsWith("http://datashapes.org/js/")) {
return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream(url.substring(21)));
}
else {
return new InputStreamReader(new URL(url).openStream());
}
}
};
}
});
}
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
List<TestCase> testCases = new LinkedList<TestCase>();
File rootFolder = new File("src/test/resources");
collectTestCases(rootFolder, testCases);
List<Object[]> results = new LinkedList<Object[]>();
for(TestCase testCase : testCases) {
results.add(new Object[]{ testCase });
}
return results;
}
private static void collectTestCases(File folder, List<TestCase> testCases) throws Exception {
for(File f : folder.listFiles()) {
if(f.isDirectory()) {
collectTestCases(f, testCases);
}
else if(f.isFile() && f.getName().endsWith(".ttl")) {
Model testModel = JenaUtil.createDefaultModel();
InputStream is = new FileInputStream(f);
testModel.read(is, "urn:dummy", FileUtils.langTurtle);
testModel.add(SHACLSystemModel.getSHACLModel());
Resource ontology = testModel.listStatements(null, OWL.imports, ResourceFactory.createResource(DASH.BASE_URI)).next().getSubject();
for(TestCaseType type : TestCaseTypes.getTypes()) {
testCases.addAll(type.getTestCases(testModel, ontology));
}
}
}
}
private TestCase testCase;
public TestDASHTestCases(TestCase testCase) {
this.testCase = testCase;
}
@Test
public void testTestCase() {
System.out.println(" - " + testCase.getResource());
Model results = JenaUtil.createMemoryModel();
try {
testCase.run(results);
}
catch(Exception ex) {
testCase.createFailure(results, "Exception during test case execution: " + ex);
ex.printStackTrace();
}
for(Statement s : results.listStatements(null, RDF.type, DASH.FailureTestCaseResult).toList()) {
String message = JenaUtil.getStringProperty(s.getSubject(), SH.resultMessage);
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(testCase.getResource() + ": " + message);
}
}
}
<MSG> Synching up with latest TopBraid code base. Deleted SHACL-JS support to avoid Nashorn/Graal issues with Java 11 onwards, and since we have moved to https://datashapes.org/active/
<DFF> @@ -19,9 +19,6 @@ package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -39,9 +36,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
-import org.topbraid.shacl.js.JSScriptEngine;
-import org.topbraid.shacl.js.JSScriptEngineFactory;
-import org.topbraid.shacl.js.NashornScriptEngine;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
@@ -51,32 +45,6 @@ import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
-
- static {
- // Redirect loading of text JS files to local folder
- JSScriptEngineFactory.set(new JSScriptEngineFactory() {
- @Override
- public JSScriptEngine createScriptEngine() {
- return new NashornScriptEngine() {
- @Override
- protected Reader createScriptReader(String url) throws Exception {
- if(DASH_JS.equals(url)) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/dash.js"));
- }
- else if(RDFQUERY_JS.equals(url)) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream("/js/rdfquery.js"));
- }
- else if(url.startsWith("http://datashapes.org/js/")) {
- return new InputStreamReader(NashornScriptEngine.class.getResourceAsStream(url.substring(21)));
- }
- else {
- return new InputStreamReader(new URL(url).openStream());
- }
- }
- };
- }
- });
- }
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
| 0 | Synching up with latest TopBraid code base. Deleted SHACL-JS support to avoid Nashorn/Graal issues with Java 11 onwards, and since we have moved to https://datashapes.org/active/ | 32 | .java | java | apache-2.0 | TopQuadrant/shacl |
204 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
Coverage:
* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library
uses code from org.topbraid.spin packages. These will eventually be refactored.
Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
```
SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
As another example, for Linux, add to .bashrc these lines:
```
# for shacl
export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin
export PATH=$SHACLROOT:$PATH
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Updated to README.md
<DFF> @@ -13,9 +13,11 @@ Coverage:
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
+See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
+
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
-For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library
-uses code from org.topbraid.spin packages. These will eventually be refactored.
+For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
+These will eventually be refactored.
Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
| 4 | Updated to README.md | 2 | .md | md | apache-2.0 | TopQuadrant/shacl |
205 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
Coverage:
* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library
uses code from org.topbraid.spin packages. These will eventually be refactored.
Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
```
SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
As another example, for Linux, add to .bashrc these lines:
```
# for shacl
export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin
export PATH=$SHACLROOT:$PATH
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Updated to README.md
<DFF> @@ -13,9 +13,11 @@ Coverage:
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
+See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
+
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
-For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library
-uses code from org.topbraid.spin packages. These will eventually be refactored.
+For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
+These will eventually be refactored.
Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
| 4 | Updated to README.md | 2 | .md | md | apache-2.0 | TopQuadrant/shacl |
206 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static Resource CountConstraint = ResourceFactory.createResource(NS + "CountConstraint");
public final static Resource Error = ResourceFactory.createResource(NS + "Error");
public final static Resource FatalError = ResourceFactory.createResource(NS + "FatalError");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Turned sh:defaultValueType into an inference that may (or may not) be computed prior to constraint checking
<DFF> @@ -35,6 +35,8 @@ public class SH {
public final static Resource CountConstraint = ResourceFactory.createResource(NS + "CountConstraint");
+ public final static Resource DefaultValueTypeRule = ResourceFactory.createResource(NS + "DefaultValueTypeRule");
+
public final static Resource Error = ResourceFactory.createResource(NS + "Error");
public final static Resource FatalError = ResourceFactory.createResource(NS + "FatalError");
| 2 | Turned sh:defaultValueType into an inference that may (or may not) be computed prior to constraint checking | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
207 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static Resource CountConstraint = ResourceFactory.createResource(NS + "CountConstraint");
public final static Resource Error = ResourceFactory.createResource(NS + "Error");
public final static Resource FatalError = ResourceFactory.createResource(NS + "FatalError");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Turned sh:defaultValueType into an inference that may (or may not) be computed prior to constraint checking
<DFF> @@ -35,6 +35,8 @@ public class SH {
public final static Resource CountConstraint = ResourceFactory.createResource(NS + "CountConstraint");
+ public final static Resource DefaultValueTypeRule = ResourceFactory.createResource(NS + "DefaultValueTypeRule");
+
public final static Resource Error = ResourceFactory.createResource(NS + "Error");
public final static Resource FatalError = ResourceFactory.createResource(NS + "FatalError");
| 2 | Turned sh:defaultValueType into an inference that may (or may not) be computed prior to constraint checking | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
208 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Added reportDetails option to validation configuration, making sure that nested validation engines inherit the same settings
<DFF> @@ -69,6 +69,8 @@ public class SH {
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
+ public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
+
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
| 2 | Added reportDetails option to validation configuration, making sure that nested validation engines inherit the same settings | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
209 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Added reportDetails option to validation configuration, making sure that nested validation engines inherit the same settings
<DFF> @@ -69,6 +69,8 @@ public class SH {
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
+ public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
+
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
| 2 | Added reportDetails option to validation configuration, making sure that nested validation engines inherit the same settings | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
210 | <NME> SHACLFunctionsCache.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.arq;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.expr.ExprEvalException;
import org.apache.jena.sparql.expr.NodeValue;
/**
* A cache that remembers previous calls to SHACL functions marked with sh:cachable.
*
* @author Holger Knublauch
*/
public class SHACLFunctionsCache {
private static SHACLFunctionsCache singleton = new SHACLFunctionsCache();
public static SHACLFunctionsCache get() {
return singleton;
}
public static void set(SHACLFunctionsCache value) {
SHACLFunctionsCache.singleton = value;
}
private static final int capacity = 10000;
@SuppressWarnings("serial")
private static class MyCache extends LinkedHashMap<Key,Result> {
MyCache() {
super(capacity + 1, 1.1f, true);
}
@Override
protected boolean removeEldestEntry(Entry<Key, Result> eldest) {
if(size() > capacity) {
return true;
}
else {
return false;
}
}
};
private Map<Key,Result> cache = Collections.synchronizedMap(new MyCache());
public void clear() {
cache.clear();
}
public NodeValue execute(SHACLARQFunction function, Dataset dataset, Model defaultModel, QuerySolution bindings, Node[] args) {
Key key = new Key(function.getSHACLFunction().getURI(), args);
Result result = cache.get(key);
if(result == null) {
result = new Result();
try {
result.nodeValue = function.executeBody(dataset, defaultModel, bindings);
}
catch(ExprEvalException ex) {
result.ex = ex;
}
cache.put(key, result);
}
if(result.ex != null) {
throw new ExprEvalException(result.ex.getMessage());
}
else {
return result.nodeValue;
}
}
private static class Key {
private int hashCode;
private Node[] args;
private String functionURI;
Key(String functionURI, Node[] args) {
this.args = args;
this.functionURI = functionURI;
hashCode = functionURI.hashCode();
for(Node arg : args) {
if(arg != null) {
hashCode += arg.hashCode();
}
}
}
private boolean argEquals(Node arg1, Node arg2) {
if(arg1 == null) {
return arg2 == null;
}
else if(arg2 == null) {
return false;
}
else {
return arg1.equals(arg2);
}
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Key)) {
return false;
}
Key other = (Key) obj;
if(!functionURI.equals(other.functionURI)) {
return false;
}
if(args.length != other.args.length) {
return false;
}
for(int i = 0; i < args.length; i++) {
if(!argEquals(args[i], other.args[i])) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
return hashCode;
}
}
private static class Result {
ExprEvalException ex;
NodeValue nodeValue;
}
}
<MSG> Switched to next Jena version, restored missing import
<DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.arq;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
| 1 | Switched to next Jena version, restored missing import | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
211 | <NME> SHACLFunctionsCache.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.arq;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.expr.ExprEvalException;
import org.apache.jena.sparql.expr.NodeValue;
/**
* A cache that remembers previous calls to SHACL functions marked with sh:cachable.
*
* @author Holger Knublauch
*/
public class SHACLFunctionsCache {
private static SHACLFunctionsCache singleton = new SHACLFunctionsCache();
public static SHACLFunctionsCache get() {
return singleton;
}
public static void set(SHACLFunctionsCache value) {
SHACLFunctionsCache.singleton = value;
}
private static final int capacity = 10000;
@SuppressWarnings("serial")
private static class MyCache extends LinkedHashMap<Key,Result> {
MyCache() {
super(capacity + 1, 1.1f, true);
}
@Override
protected boolean removeEldestEntry(Entry<Key, Result> eldest) {
if(size() > capacity) {
return true;
}
else {
return false;
}
}
};
private Map<Key,Result> cache = Collections.synchronizedMap(new MyCache());
public void clear() {
cache.clear();
}
public NodeValue execute(SHACLARQFunction function, Dataset dataset, Model defaultModel, QuerySolution bindings, Node[] args) {
Key key = new Key(function.getSHACLFunction().getURI(), args);
Result result = cache.get(key);
if(result == null) {
result = new Result();
try {
result.nodeValue = function.executeBody(dataset, defaultModel, bindings);
}
catch(ExprEvalException ex) {
result.ex = ex;
}
cache.put(key, result);
}
if(result.ex != null) {
throw new ExprEvalException(result.ex.getMessage());
}
else {
return result.nodeValue;
}
}
private static class Key {
private int hashCode;
private Node[] args;
private String functionURI;
Key(String functionURI, Node[] args) {
this.args = args;
this.functionURI = functionURI;
hashCode = functionURI.hashCode();
for(Node arg : args) {
if(arg != null) {
hashCode += arg.hashCode();
}
}
}
private boolean argEquals(Node arg1, Node arg2) {
if(arg1 == null) {
return arg2 == null;
}
else if(arg2 == null) {
return false;
}
else {
return arg1.equals(arg2);
}
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Key)) {
return false;
}
Key other = (Key) obj;
if(!functionURI.equals(other.functionURI)) {
return false;
}
if(args.length != other.args.length) {
return false;
}
for(int i = 0; i < args.length; i++) {
if(!argEquals(args[i], other.args[i])) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
return hashCode;
}
}
private static class Result {
ExprEvalException ex;
NodeValue nodeValue;
}
}
<MSG> Switched to next Jena version, restored missing import
<DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.arq;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
| 1 | Switched to next Jena version, restored missing import | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
212 | <NME> ValidationUtil.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation;
import java.net.URI;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.compose.MultiUnion;
import org.apache.jena.query.Dataset;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
import org.topbraid.shacl.vocabulary.TOSH;
/**
* Convenience methods to perform SHACL validation.
*
* These methods are provided for convenience of simple use cases only but are often not the most efficient way
* of working with SHACL. It is typically better to separate the creation of the ShapesGraph object from
* the ValidationEngine because the ShapesGraph can be reused across multiple validations, and serves as a "pre-compiled"
* data structure that is expensive to rebuild for each run.
*
* Having separate calls also provides access to the other functions of the ValidationEngine object, such as
* <code>validateNode</code> and <code>getValidationReport</code>.
*
* @author Holger Knublauch
*/
public class ValidationUtil {
public static ValidationEngine createValidationEngine(Model dataModel, Model shapesModel, boolean validateShapes) {
return createValidationEngine(dataModel, shapesModel, new ValidationEngineConfiguration().setValidateShapes(validateShapes));
}
public static ValidationEngine createValidationEngine(Model dataModel, Model shapesModel, ValidationEngineConfiguration configuration) {
shapesModel = ensureToshTriplesExist(shapesModel);
}
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
try {
return engine.validateAll();
}
catch(InterruptedException ex) {
Dataset dataset = ARQFactory.get().getDataset(dataModel);
dataset.addNamedModel(shapesGraphURI.toString(), shapesModel);
ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel);
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
engine.setConfiguration(configuration);
return engine;
}
public static Model ensureToshTriplesExist(Model shapesModel) {
// Ensure that the SHACL, DASH and TOSH graphs are present in the shapes Model
if(!shapesModel.contains(TOSH.hasShape, RDF.type, (RDFNode)null)) { // Heuristic
Model unionModel = SHACLSystemModel.getSHACLModel();
MultiUnion unionGraph = new MultiUnion(new Graph[] {
unionModel.getGraph(),
shapesModel.getGraph()
});
shapesModel = ModelFactory.createModelForGraph(unionGraph);
}
return shapesModel;
}
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
* @return an instance of sh:ValidationReport in a results Model
*/
public static Resource validateModel(Model dataModel, Model shapesModel, boolean validateShapes) {
return validateModel(dataModel, shapesModel, new ValidationEngineConfiguration().setValidateShapes(validateShapes));
}
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param configuration configuration for the validation engine
* @return an instance of sh:ValidationReport in a results Model
*/
public static Resource validateModel(Model dataModel, Model shapesModel, ValidationEngineConfiguration configuration) {
ValidationEngine engine = createValidationEngine(dataModel, shapesModel, configuration);
engine.setConfiguration(configuration);
try {
engine.applyEntailments();
return engine.validateAll();
}
catch(InterruptedException ex) {
return null;
}
}
}
<MSG> Added support for entailments
<DFF> @@ -28,6 +28,7 @@ public class ValidationUtil {
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
+ * Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
@@ -60,6 +61,7 @@ public class ValidationUtil {
}
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
try {
+ engine.applyEntailments();
return engine.validateAll();
}
catch(InterruptedException ex) {
| 2 | Added support for entailments | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
213 | <NME> ValidationUtil.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation;
import java.net.URI;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.compose.MultiUnion;
import org.apache.jena.query.Dataset;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
import org.topbraid.shacl.vocabulary.TOSH;
/**
* Convenience methods to perform SHACL validation.
*
* These methods are provided for convenience of simple use cases only but are often not the most efficient way
* of working with SHACL. It is typically better to separate the creation of the ShapesGraph object from
* the ValidationEngine because the ShapesGraph can be reused across multiple validations, and serves as a "pre-compiled"
* data structure that is expensive to rebuild for each run.
*
* Having separate calls also provides access to the other functions of the ValidationEngine object, such as
* <code>validateNode</code> and <code>getValidationReport</code>.
*
* @author Holger Knublauch
*/
public class ValidationUtil {
public static ValidationEngine createValidationEngine(Model dataModel, Model shapesModel, boolean validateShapes) {
return createValidationEngine(dataModel, shapesModel, new ValidationEngineConfiguration().setValidateShapes(validateShapes));
}
public static ValidationEngine createValidationEngine(Model dataModel, Model shapesModel, ValidationEngineConfiguration configuration) {
shapesModel = ensureToshTriplesExist(shapesModel);
}
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
try {
return engine.validateAll();
}
catch(InterruptedException ex) {
Dataset dataset = ARQFactory.get().getDataset(dataModel);
dataset.addNamedModel(shapesGraphURI.toString(), shapesModel);
ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel);
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
engine.setConfiguration(configuration);
return engine;
}
public static Model ensureToshTriplesExist(Model shapesModel) {
// Ensure that the SHACL, DASH and TOSH graphs are present in the shapes Model
if(!shapesModel.contains(TOSH.hasShape, RDF.type, (RDFNode)null)) { // Heuristic
Model unionModel = SHACLSystemModel.getSHACLModel();
MultiUnion unionGraph = new MultiUnion(new Graph[] {
unionModel.getGraph(),
shapesModel.getGraph()
});
shapesModel = ModelFactory.createModelForGraph(unionGraph);
}
return shapesModel;
}
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
* @return an instance of sh:ValidationReport in a results Model
*/
public static Resource validateModel(Model dataModel, Model shapesModel, boolean validateShapes) {
return validateModel(dataModel, shapesModel, new ValidationEngineConfiguration().setValidateShapes(validateShapes));
}
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
* Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param configuration configuration for the validation engine
* @return an instance of sh:ValidationReport in a results Model
*/
public static Resource validateModel(Model dataModel, Model shapesModel, ValidationEngineConfiguration configuration) {
ValidationEngine engine = createValidationEngine(dataModel, shapesModel, configuration);
engine.setConfiguration(configuration);
try {
engine.applyEntailments();
return engine.validateAll();
}
catch(InterruptedException ex) {
return null;
}
}
}
<MSG> Added support for entailments
<DFF> @@ -28,6 +28,7 @@ public class ValidationUtil {
/**
* Validates a given data Model against all shapes from a given shapes Model.
* If the shapesModel does not include the system graph triples then these will be added.
+ * Entailment regimes are applied prior to validation.
* @param dataModel the data Model
* @param shapesModel the shapes Model
* @param validateShapes true to also validate any shapes in the data Model (false is faster)
@@ -60,6 +61,7 @@ public class ValidationUtil {
}
ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
try {
+ engine.applyEntailments();
return engine.validateAll();
}
catch(InterruptedException ex) {
| 2 | Added support for entailments | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
214 | <NME> AbstractFunction6.java
<BEF> ADDFILE
<MSG> Tracking the latest TopBraid snapshot
<DFF> @@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 TopQuadrant, Inc.
+ * All rights reserved.
+ *******************************************************************************/
+package org.topbraid.spin.arq;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.expr.NodeValue;
+import org.apache.jena.sparql.function.FunctionEnv;
+
+
+/**
+ * An abstract superclass for Functions with 6 arguments.
+ *
+ * @author Holger Knublauch
+ */
+public abstract class AbstractFunction6 extends AbstractFunction {
+
+ @Override
+ protected NodeValue exec(Node[] nodes, FunctionEnv env) {
+ Node arg1 = nodes.length > 0 ? nodes[0] : null;
+ Node arg2 = nodes.length > 1 ? nodes[1] : null;
+ Node arg3 = nodes.length > 2 ? nodes[2] : null;
+ Node arg4 = nodes.length > 3 ? nodes[3] : null;
+ Node arg5 = nodes.length > 4 ? nodes[4] : null;
+ Node arg6 = nodes.length > 5 ? nodes[5] : null;
+ return exec(arg1, arg2, arg3, arg4, arg5, arg6, env);
+ }
+
+
+ protected abstract NodeValue exec(Node arg1, Node arg2, Node arg3, Node arg4, Node arg5, Node arg6, FunctionEnv env);
+}
| 32 | Tracking the latest TopBraid snapshot | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
215 | <NME> AbstractFunction6.java
<BEF> ADDFILE
<MSG> Tracking the latest TopBraid snapshot
<DFF> @@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 TopQuadrant, Inc.
+ * All rights reserved.
+ *******************************************************************************/
+package org.topbraid.spin.arq;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.expr.NodeValue;
+import org.apache.jena.sparql.function.FunctionEnv;
+
+
+/**
+ * An abstract superclass for Functions with 6 arguments.
+ *
+ * @author Holger Knublauch
+ */
+public abstract class AbstractFunction6 extends AbstractFunction {
+
+ @Override
+ protected NodeValue exec(Node[] nodes, FunctionEnv env) {
+ Node arg1 = nodes.length > 0 ? nodes[0] : null;
+ Node arg2 = nodes.length > 1 ? nodes[1] : null;
+ Node arg3 = nodes.length > 2 ? nodes[2] : null;
+ Node arg4 = nodes.length > 3 ? nodes[3] : null;
+ Node arg5 = nodes.length > 4 ? nodes[4] : null;
+ Node arg6 = nodes.length > 5 ? nodes[5] : null;
+ return exec(arg1, arg2, arg3, arg4, arg5, arg6, env);
+ }
+
+
+ protected abstract NodeValue exec(Node arg1, Node arg2, Node arg3, Node arg4, Node arg5, Node arg6, FunctionEnv env);
+}
| 32 | Tracking the latest TopBraid snapshot | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
216 | <NME> SHT.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
public final static Resource NonWellFormedSchema = ResourceFactory.createResource(NS + "NonWellFormedSchema");
public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Resource SHACLC = ResourceFactory.createResource(NS + "SHACLC");
public static final String BASE_URI = "http://www.w3.org/ns/shacl-test";
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
public final static Property data = ResourceFactory.createProperty(NS + "data");
public final static Property data_format = ResourceFactory.createProperty(NS + "data-format");
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
}
<MSG> Updated API
<DFF> @@ -19,8 +19,6 @@ public class SHT {
public final static Resource NonWellFormedSchema = ResourceFactory.createResource(NS + "NonWellFormedSchema");
- public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
-
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Resource SHACLC = ResourceFactory.createResource(NS + "SHACLC");
@@ -29,6 +27,8 @@ public class SHT {
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
+ public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
+
public final static Property data = ResourceFactory.createProperty(NS + "data");
public final static Property data_format = ResourceFactory.createProperty(NS + "data-format");
| 2 | Updated API | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
217 | <NME> SHT.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
public final static Resource NonWellFormedSchema = ResourceFactory.createResource(NS + "NonWellFormedSchema");
public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Resource SHACLC = ResourceFactory.createResource(NS + "SHACLC");
public static final String BASE_URI = "http://www.w3.org/ns/shacl-test";
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
public final static Property data = ResourceFactory.createProperty(NS + "data");
public final static Property data_format = ResourceFactory.createProperty(NS + "data-format");
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
}
<MSG> Updated API
<DFF> @@ -19,8 +19,6 @@ public class SHT {
public final static Resource NonWellFormedSchema = ResourceFactory.createResource(NS + "NonWellFormedSchema");
- public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
-
public final static Resource proposed = ResourceFactory.createResource(NS + "proposed");
public final static Resource SHACLC = ResourceFactory.createResource(NS + "SHACLC");
@@ -29,6 +27,8 @@ public class SHT {
public final static Resource Validate = ResourceFactory.createResource(NS + "Validate");
+ public final static Resource WellFormedSchema = ResourceFactory.createResource(NS + "WellFormedSchema");
+
public final static Property data = ResourceFactory.createProperty(NS + "data");
public final static Property data_format = ResourceFactory.createProperty(NS + "data-format");
| 2 | Updated API | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
218 | <NME> test.js
<BEF> ADDFILE
<MSG> Adding packaging information and web tests
<DFF> @@ -0,0 +1,284 @@
+var examples = {
+
+ example1: {
+ dataFormat: "application/ld+json",
+ shapesFormat: "application/ld+json",
+ data: JSON.stringify({
+ "http://raml.org/vocabularies/shapes#toValidate":
+ { "http://raml.org/vocabularies/shapes/anon#name": { "@value": "John" } }
+ }),
+ shapes: JSON.stringify({
+ "@type": [
+ "http://www.w3.org/ns/shacl#NodeShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape",
+ "http://www.w3.org/ns/shacl#property": [
+ {
+ "http://www.w3.org/ns/shacl#maxCount": [
+ {
+ "@value": 1
+ }
+ ],
+ "http://www.w3.org/ns/shacl#dataType": [
+ {
+ "@id": "http://www.w3.org/2001/XMLSchema#string"
+ }
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape/property/name",
+ "@type": [
+ "http://www.w3.org/ns/shacl#PropertyShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "http://www.w3.org/ns/shacl#path": [
+ {
+ "@id": "http://raml.org/vocabularies/shapes/anon#name"
+ }
+ ],
+ "http://raml.org/vocabularies/shapes#propertyLabel": [
+ {
+ "@value": "name"
+ }
+ ],
+ "http://www.w3.org/ns/shacl#minCount": [
+ {
+ "@value": 1
+ }
+ ]
+ },
+ {
+ "http://www.w3.org/ns/shacl#maxCount": [
+ {
+ "@value": 1
+ }
+ ],
+ "http://www.w3.org/ns/shacl#dataType": [
+ {
+ "@id": "http://www.w3.org/2001/XMLSchema#string"
+ }
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape/property/surname",
+ "@type": [
+ "http://www.w3.org/ns/shacl#PropertyShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "http://www.w3.org/ns/shacl#path": [
+ {
+ "@id": "http://raml.org/vocabularies/shapes/anon#surname"
+ }
+ ],
+ "http://raml.org/vocabularies/shapes#propertyLabel": [
+ {
+ "@value": "surname"
+ }
+ ],
+ "http://www.w3.org/ns/shacl#minCount": [
+ {
+ "@value": 1
+ }
+ ]
+ }
+ ],
+ "http://www.w3.org/ns/shacl#targetObjectsOf": {
+ "@id": "http://raml.org/vocabularies/shapes#toValidate"
+ }
+ })
+ },
+ example2: {
+ dataFormat: "application/ld+json",
+ data: '{"http://raml.org/vocabularies/shapes#toValidate": {\
+ "http://raml.org/vocabularies/shapes/anon#title": ["hey","ho"],\
+ "http://raml.org/vocabularies/shapes/anon#artist": "Antonio Carlos Brasileiro de Almeida Jobim"\
+ } }',
+ shapesFormat: "application/ld+json",
+ shapes: '{\
+ "@context": {\
+ "raml-doc": "http://raml.org/vocabularies/document#",\
+ "raml-http": "http://raml.org/vocabularies/http#",\
+ "raml-shapes": "http://raml.org/vocabularies/shapes#",\
+ "hydra": "http://www.w3.org/ns/hydra/core#",\
+ "shacl": "http://www.w3.org/ns/shacl#",\
+ "schema-org": "http://schema.org/",\
+ "xsd": "http://www.w3.org/2001/XMLSchema#"\
+ },\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0",\
+ "@type": [\
+ "shacl:NodeShape",\
+ "shacl:Shape"\
+ ],\
+ "shacl:targetObjectsOf": {"@id": "raml-shapes:toValidate"},\
+ "shacl:property": [\
+ {\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title",\
+ "@type": [\
+ "shacl:PropertyShape",\
+ "shacl:Shape"\
+ ],\
+ "raml-shapes:propertyLabel": "title",\
+ "shacl:dataType": {\
+ "@id": "xsd:string"\
+ },\
+ "shacl:maxCount": 1,\
+ "shacl:minCount": 0,\
+ "shacl:path": {\
+ "@id": "http://raml.org/vocabularies/shapes/anon#title"\
+ }\
+ },\
+ {\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/artist",\
+ "@type": [\
+ "shacl:PropertyShape",\
+ "shacl:Shape"\
+ ],\
+ "raml-shapes:propertyLabel": "artist",\
+ "shacl:dataType": {\
+ "@id": "xsd:string"\
+ },\
+ "shacl:maxCount": 1,\
+ "shacl:minCount": 0,\
+ "shacl:path": {\
+ "@id": "http://raml.org/vocabularies/shapes/anon#artist"\
+ }\
+ }\
+ ]\
+ }'
+ },
+
+ peopleTTL: {
+ dataFormat: "text/turtle",
+ data: '@prefix ex: <http://example.org/ns#> .\n\
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n\
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
+@prefix schema: <http://schema.org/> .\n\
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\
+\n\
+ex:Bob\n\
+ a schema:Person ;\n\
+ schema:givenName "Robert" ;\n\
+ schema:familyName "Junior" ;\n\
+ schema:birthDate "1971-07-07"^^xsd:date ;\n\
+ schema:deathDate "1968-09-10"^^xsd:date ;\n\
+ schema:address ex:BobsAddress .\n\
+\n\
+ex:BobsAddress\n\
+ schema:streetAddress "1600 Amphitheatre Pkway" ;\n\
+ schema:postalCode 9404 .',
+ shapesFormat: "text/turtle",
+ shapes: '@prefix dash: <http://datashapes.org/dash#> .\n\
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n\
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
+@prefix schema: <http://schema.org/> .\n\
+@prefix sh: <http://www.w3.org/ns/shacl#> .\n\
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\
+\n\
+schema:peoplehape\n\
+ a sh:NodeShape ;\n\
+ sh:targetClass schema:Person ;\n\
+ sh:property [\n\
+ sh:path schema:givenName ;\n\
+ sh:datatype xsd:string ;\n\
+ sh:name "given name" ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:birthDate ;\n\
+ sh:lessThan schema:deathDate ;\n\
+ sh:maxCount 1 ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:gender ;\n\
+ sh:in ( "female" "male" ) ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:address ;\n\
+ sh:node schema:AddressShape ;\n\
+ ] .\n\
+\n\
+schema:AddressShape\n\
+ a sh:NodeShape ;\n\
+ sh:closed true ;\n\
+ sh:property [\n\
+ sh:path schema:streetAddress ;\n\
+ sh:datatype xsd:string ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:postalCode ;\n\
+ sh:or ( [ sh:datatype xsd:string ] [ sh:datatype xsd:integer ] ) ;\n\
+ sh:minInclusive 10000 ;\n\
+ sh:maxInclusive 99999 ;\n\
+ ] .'
+ },
+
+ peopleJSON: {
+
+ data: '{\n\
+ "@context": { "@vocab": "http://schema.org/" },\n\
+\n\
+ "@id": "http://example.org/ns#Bob",\n\
+ "@type": "Person",\n\
+ "givenName": "Robert",\n\
+ "familyName": "Junior",\n\
+ "birthDate": "1971-07-07",\n\
+ "deathDate": "1968-09-10",\n\
+ "address": {\n\
+ "@id": "http://example.org/ns#BobsAddress",\n\
+ "streetAddress": "1600 Amphitheatre Pkway",\n\
+ "postalCode": 9404\n\
+ }\n\
+}',
+ dataFormat: "application/ld+json",
+ shapes: '',
+ shapesFormat: "text/turtle"
+ }
+};
+examples.peopleJSON.shapes = examples.peopleTTL.shapes;
+
+QUnit.test("Integration test 1", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example1.data,
+ examples.example1.dataFormat,
+ examples.example1.shapes,
+ examples.example1.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "Less than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#surname");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MinCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "http://raml.org/vocabularies/data#AnonShape/property/surname");
+ done();
+ });
+});
+
+
+QUnit.test("Integration test 2", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example2.data,
+ examples.example2.dataFormat,
+ examples.example2.shapes,
+ examples.example2.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "More than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#title");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MaxCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title");
+ done();
+ });
+});
| 284 | Adding packaging information and web tests | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
219 | <NME> test.js
<BEF> ADDFILE
<MSG> Adding packaging information and web tests
<DFF> @@ -0,0 +1,284 @@
+var examples = {
+
+ example1: {
+ dataFormat: "application/ld+json",
+ shapesFormat: "application/ld+json",
+ data: JSON.stringify({
+ "http://raml.org/vocabularies/shapes#toValidate":
+ { "http://raml.org/vocabularies/shapes/anon#name": { "@value": "John" } }
+ }),
+ shapes: JSON.stringify({
+ "@type": [
+ "http://www.w3.org/ns/shacl#NodeShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape",
+ "http://www.w3.org/ns/shacl#property": [
+ {
+ "http://www.w3.org/ns/shacl#maxCount": [
+ {
+ "@value": 1
+ }
+ ],
+ "http://www.w3.org/ns/shacl#dataType": [
+ {
+ "@id": "http://www.w3.org/2001/XMLSchema#string"
+ }
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape/property/name",
+ "@type": [
+ "http://www.w3.org/ns/shacl#PropertyShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "http://www.w3.org/ns/shacl#path": [
+ {
+ "@id": "http://raml.org/vocabularies/shapes/anon#name"
+ }
+ ],
+ "http://raml.org/vocabularies/shapes#propertyLabel": [
+ {
+ "@value": "name"
+ }
+ ],
+ "http://www.w3.org/ns/shacl#minCount": [
+ {
+ "@value": 1
+ }
+ ]
+ },
+ {
+ "http://www.w3.org/ns/shacl#maxCount": [
+ {
+ "@value": 1
+ }
+ ],
+ "http://www.w3.org/ns/shacl#dataType": [
+ {
+ "@id": "http://www.w3.org/2001/XMLSchema#string"
+ }
+ ],
+ "@id": "http://raml.org/vocabularies/data#AnonShape/property/surname",
+ "@type": [
+ "http://www.w3.org/ns/shacl#PropertyShape",
+ "http://www.w3.org/ns/shacl#Shape"
+ ],
+ "http://www.w3.org/ns/shacl#path": [
+ {
+ "@id": "http://raml.org/vocabularies/shapes/anon#surname"
+ }
+ ],
+ "http://raml.org/vocabularies/shapes#propertyLabel": [
+ {
+ "@value": "surname"
+ }
+ ],
+ "http://www.w3.org/ns/shacl#minCount": [
+ {
+ "@value": 1
+ }
+ ]
+ }
+ ],
+ "http://www.w3.org/ns/shacl#targetObjectsOf": {
+ "@id": "http://raml.org/vocabularies/shapes#toValidate"
+ }
+ })
+ },
+ example2: {
+ dataFormat: "application/ld+json",
+ data: '{"http://raml.org/vocabularies/shapes#toValidate": {\
+ "http://raml.org/vocabularies/shapes/anon#title": ["hey","ho"],\
+ "http://raml.org/vocabularies/shapes/anon#artist": "Antonio Carlos Brasileiro de Almeida Jobim"\
+ } }',
+ shapesFormat: "application/ld+json",
+ shapes: '{\
+ "@context": {\
+ "raml-doc": "http://raml.org/vocabularies/document#",\
+ "raml-http": "http://raml.org/vocabularies/http#",\
+ "raml-shapes": "http://raml.org/vocabularies/shapes#",\
+ "hydra": "http://www.w3.org/ns/hydra/core#",\
+ "shacl": "http://www.w3.org/ns/shacl#",\
+ "schema-org": "http://schema.org/",\
+ "xsd": "http://www.w3.org/2001/XMLSchema#"\
+ },\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0",\
+ "@type": [\
+ "shacl:NodeShape",\
+ "shacl:Shape"\
+ ],\
+ "shacl:targetObjectsOf": {"@id": "raml-shapes:toValidate"},\
+ "shacl:property": [\
+ {\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title",\
+ "@type": [\
+ "shacl:PropertyShape",\
+ "shacl:Shape"\
+ ],\
+ "raml-shapes:propertyLabel": "title",\
+ "shacl:dataType": {\
+ "@id": "xsd:string"\
+ },\
+ "shacl:maxCount": 1,\
+ "shacl:minCount": 0,\
+ "shacl:path": {\
+ "@id": "http://raml.org/vocabularies/shapes/anon#title"\
+ }\
+ },\
+ {\
+ "@id": "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/artist",\
+ "@type": [\
+ "shacl:PropertyShape",\
+ "shacl:Shape"\
+ ],\
+ "raml-shapes:propertyLabel": "artist",\
+ "shacl:dataType": {\
+ "@id": "xsd:string"\
+ },\
+ "shacl:maxCount": 1,\
+ "shacl:minCount": 0,\
+ "shacl:path": {\
+ "@id": "http://raml.org/vocabularies/shapes/anon#artist"\
+ }\
+ }\
+ ]\
+ }'
+ },
+
+ peopleTTL: {
+ dataFormat: "text/turtle",
+ data: '@prefix ex: <http://example.org/ns#> .\n\
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n\
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
+@prefix schema: <http://schema.org/> .\n\
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\
+\n\
+ex:Bob\n\
+ a schema:Person ;\n\
+ schema:givenName "Robert" ;\n\
+ schema:familyName "Junior" ;\n\
+ schema:birthDate "1971-07-07"^^xsd:date ;\n\
+ schema:deathDate "1968-09-10"^^xsd:date ;\n\
+ schema:address ex:BobsAddress .\n\
+\n\
+ex:BobsAddress\n\
+ schema:streetAddress "1600 Amphitheatre Pkway" ;\n\
+ schema:postalCode 9404 .',
+ shapesFormat: "text/turtle",
+ shapes: '@prefix dash: <http://datashapes.org/dash#> .\n\
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n\
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
+@prefix schema: <http://schema.org/> .\n\
+@prefix sh: <http://www.w3.org/ns/shacl#> .\n\
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\
+\n\
+schema:peoplehape\n\
+ a sh:NodeShape ;\n\
+ sh:targetClass schema:Person ;\n\
+ sh:property [\n\
+ sh:path schema:givenName ;\n\
+ sh:datatype xsd:string ;\n\
+ sh:name "given name" ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:birthDate ;\n\
+ sh:lessThan schema:deathDate ;\n\
+ sh:maxCount 1 ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:gender ;\n\
+ sh:in ( "female" "male" ) ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:address ;\n\
+ sh:node schema:AddressShape ;\n\
+ ] .\n\
+\n\
+schema:AddressShape\n\
+ a sh:NodeShape ;\n\
+ sh:closed true ;\n\
+ sh:property [\n\
+ sh:path schema:streetAddress ;\n\
+ sh:datatype xsd:string ;\n\
+ ] ;\n\
+ sh:property [\n\
+ sh:path schema:postalCode ;\n\
+ sh:or ( [ sh:datatype xsd:string ] [ sh:datatype xsd:integer ] ) ;\n\
+ sh:minInclusive 10000 ;\n\
+ sh:maxInclusive 99999 ;\n\
+ ] .'
+ },
+
+ peopleJSON: {
+
+ data: '{\n\
+ "@context": { "@vocab": "http://schema.org/" },\n\
+\n\
+ "@id": "http://example.org/ns#Bob",\n\
+ "@type": "Person",\n\
+ "givenName": "Robert",\n\
+ "familyName": "Junior",\n\
+ "birthDate": "1971-07-07",\n\
+ "deathDate": "1968-09-10",\n\
+ "address": {\n\
+ "@id": "http://example.org/ns#BobsAddress",\n\
+ "streetAddress": "1600 Amphitheatre Pkway",\n\
+ "postalCode": 9404\n\
+ }\n\
+}',
+ dataFormat: "application/ld+json",
+ shapes: '',
+ shapesFormat: "text/turtle"
+ }
+};
+examples.peopleJSON.shapes = examples.peopleTTL.shapes;
+
+QUnit.test("Integration test 1", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example1.data,
+ examples.example1.dataFormat,
+ examples.example1.shapes,
+ examples.example1.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "Less than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#surname");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MinCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "http://raml.org/vocabularies/data#AnonShape/property/surname");
+ done();
+ });
+});
+
+
+QUnit.test("Integration test 2", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example2.data,
+ examples.example2.dataFormat,
+ examples.example2.shapes,
+ examples.example2.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "More than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#title");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MaxCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title");
+ done();
+ });
+});
| 284 | Adding packaging information and web tests | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
220 | <NME> qualifiedValueShapesDisjoint-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/core/property/qualifiedValueShapesDisjoint-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/property/qualifiedValueShapesDisjoint-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/qualifiedValueShapesDisjoint-001.test>
rdf:type owl:Ontology ;
rdfs:label "Test of sh:qualifiedValueShapesDisjoint at property shape 001" ;
owl:imports <http://datashapes.org/dash> ;
.
ex:Finger
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Finger" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:Finger1
rdf:type ex:Finger ;
rdfs:label "Finger1" ;
.
ex:Finger2
rdf:type ex:Finger ;
rdfs:label "Finger2" ;
.
ex:Finger3
rdf:type ex:Finger ;
rdfs:label "Finger3" ;
.
ex:Finger4
rdf:type ex:Finger ;
rdfs:label "Finger4" ;
.
ex:FingerAndThumb
rdf:type ex:Finger ;
rdf:type ex:Thumb ;
rdfs:label "Finger and thumb" ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidHand1 ;
sh:resultPath ex:digit ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
] ;
] ;
.
ex:Hand
.
ex:Hand
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Hand" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:HandShape
rdf:type sh:NodeShape ;
sh:property ex:HandShape-digit1 ;
sh:property ex:HandShape-digit4 ;
sh:targetClass ex:Hand ;
.
ex:HandShape-digit1
sh:path ex:digit ;
sh:qualifiedMaxCount 1 ;
sh:qualifiedMinCount 1 ;
sh:qualifiedValueShape [
sh:class ex:Thumb ;
] ;
sh:qualifiedValueShapesDisjoint true ;
.
ex:HandShape-digit4
sh:path ex:digit ;
sh:qualifiedMaxCount 4 ;
sh:qualifiedMinCount 4 ;
sh:qualifiedValueShape [
sh:class ex:Finger ;
] ;
sh:qualifiedValueShapesDisjoint true ;
.
ex:InvalidHand1
rdf:type ex:Hand ;
ex:digit ex:Finger1 ;
ex:digit ex:Finger2 ;
ex:digit ex:Finger3 ;
ex:digit ex:FingerAndThumb ;
.
ex:Thumb
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Thumb" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:Thumb1
rdf:type ex:Thumb ;
rdfs:label "Thumb1" ;
.
ex:ValidHand
rdf:type ex:Hand ;
ex:digit ex:Finger1 ;
ex:digit ex:Finger2 ;
ex:digit ex:Finger3 ;
ex:digit ex:Finger4 ;
ex:digit ex:Thumb1 ;
rdfs:label "Valid hand" ;
.
<MSG> Switched QCRs to JS only
<DFF> @@ -54,6 +54,13 @@ ex:GraphValidationTestCase
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
] ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidHand1 ;
+ sh:resultPath ex:digit ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
+ ] ;
] ;
.
ex:Hand
| 7 | Switched QCRs to JS only | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
221 | <NME> qualifiedValueShapesDisjoint-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/core/property/qualifiedValueShapesDisjoint-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/property/qualifiedValueShapesDisjoint-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/qualifiedValueShapesDisjoint-001.test>
rdf:type owl:Ontology ;
rdfs:label "Test of sh:qualifiedValueShapesDisjoint at property shape 001" ;
owl:imports <http://datashapes.org/dash> ;
.
ex:Finger
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Finger" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:Finger1
rdf:type ex:Finger ;
rdfs:label "Finger1" ;
.
ex:Finger2
rdf:type ex:Finger ;
rdfs:label "Finger2" ;
.
ex:Finger3
rdf:type ex:Finger ;
rdfs:label "Finger3" ;
.
ex:Finger4
rdf:type ex:Finger ;
rdfs:label "Finger4" ;
.
ex:FingerAndThumb
rdf:type ex:Finger ;
rdf:type ex:Thumb ;
rdfs:label "Finger and thumb" ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidHand1 ;
sh:resultPath ex:digit ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
] ;
] ;
.
ex:Hand
.
ex:Hand
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Hand" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:HandShape
rdf:type sh:NodeShape ;
sh:property ex:HandShape-digit1 ;
sh:property ex:HandShape-digit4 ;
sh:targetClass ex:Hand ;
.
ex:HandShape-digit1
sh:path ex:digit ;
sh:qualifiedMaxCount 1 ;
sh:qualifiedMinCount 1 ;
sh:qualifiedValueShape [
sh:class ex:Thumb ;
] ;
sh:qualifiedValueShapesDisjoint true ;
.
ex:HandShape-digit4
sh:path ex:digit ;
sh:qualifiedMaxCount 4 ;
sh:qualifiedMinCount 4 ;
sh:qualifiedValueShape [
sh:class ex:Finger ;
] ;
sh:qualifiedValueShapesDisjoint true ;
.
ex:InvalidHand1
rdf:type ex:Hand ;
ex:digit ex:Finger1 ;
ex:digit ex:Finger2 ;
ex:digit ex:Finger3 ;
ex:digit ex:FingerAndThumb ;
.
ex:Thumb
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Thumb" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:Thumb1
rdf:type ex:Thumb ;
rdfs:label "Thumb1" ;
.
ex:ValidHand
rdf:type ex:Hand ;
ex:digit ex:Finger1 ;
ex:digit ex:Finger2 ;
ex:digit ex:Finger3 ;
ex:digit ex:Finger4 ;
ex:digit ex:Thumb1 ;
rdfs:label "Valid hand" ;
.
<MSG> Switched QCRs to JS only
<DFF> @@ -54,6 +54,13 @@ ex:GraphValidationTestCase
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
] ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidHand1 ;
+ sh:resultPath ex:digit ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraintComponent sh:QualifiedMinCountConstraintComponent ;
+ ] ;
] ;
.
ex:Hand
| 7 | Switched QCRs to JS only | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
222 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
Coverage:
* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
Former Coverage until version 1.4.0
* [SHACL Compact Syntax](https://w3c.github.io/shacl/shacl-compact-syntax/)
Former Coverage until version 1.3.2
* [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/)
The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes)
and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves).
The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release).
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
SET PATH=%PATH%;%SHACLROOT%\bin
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Update README.md
Added Linux set up description from Andrew.
<DFF> @@ -60,6 +60,14 @@ SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.0.0-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
+As another example, for Linux, add to .bashrc these lines:
+
+```
+# for shacl
+export SHACLROOT=/home/holger/shacl/shacl-1.0.0-bin/shacl-1.0.0/bin
+export PATH=$SHACLROOT:$PATH
+```
+
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
| 8 | Update README.md | 0 | .md | md | apache-2.0 | TopQuadrant/shacl |
223 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
Coverage:
* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
Former Coverage until version 1.4.0
* [SHACL Compact Syntax](https://w3c.github.io/shacl/shacl-compact-syntax/)
Former Coverage until version 1.3.2
* [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/)
The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes)
and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves).
The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release).
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
SET PATH=%PATH%;%SHACLROOT%\bin
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Update README.md
Added Linux set up description from Andrew.
<DFF> @@ -60,6 +60,14 @@ SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.0.0-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
+As another example, for Linux, add to .bashrc these lines:
+
+```
+# for shacl
+export SHACLROOT=/home/holger/shacl/shacl-1.0.0-bin/shacl-1.0.0/bin
+export PATH=$SHACLROOT:$PATH
+```
+
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
| 8 | Update README.md | 0 | .md | md | apache-2.0 | TopQuadrant/shacl |
224 | <NME> AbstractSPARQLExecutor.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation.sparql;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryParseException;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.QuerySolutionMap;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.statistics.ExecStatistics;
import org.topbraid.jenax.statistics.ExecStatisticsManager;
import org.topbraid.jenax.util.ARQFactory;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.jenax.util.RDFLabels;
import org.topbraid.shacl.arq.SHACLPaths;
import org.topbraid.shacl.arq.functions.HasShapeFunction;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.util.FailureLog;
import org.topbraid.shacl.util.SHACLUtil;
import org.topbraid.shacl.validation.ConstraintExecutor;
import org.topbraid.shacl.validation.SHACLException;
import org.topbraid.shacl.validation.ValidationEngine;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
public abstract class AbstractSPARQLExecutor implements ConstraintExecutor {
// Flag to generate dash:SuccessResults for all violations.
public static boolean createSuccessResults = false;
private Query query;
private String queryString;
protected AbstractSPARQLExecutor(Constraint constraint) {
this.queryString = getSPARQL(constraint);
try {
this.query = ARQFactory.get().createQuery(queryString);
Resource path = constraint.getShapeResource().getPath();
if(path != null && path.isAnon()) {
String pathString = SHACLPaths.getPathString(constraint.getShapeResource().getPropertyResourceValue(SH.path));
query = SPARQLSubstitutions.substitutePaths(query, pathString, constraint.getShapeResource().getModel());
}
}
catch(QueryParseException ex) {
throw new SHACLException("Invalid SPARQL constraint (" + ex.getLocalizedMessage() + "):\n" + queryString);
}
if(!query.isSelectType()) {
throw new IllegalArgumentException("SHACL constraints must be SELECT queries");
}
}
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
QuerySolutionMap bindings = new QuerySolutionMap();
addBindings(constraint, bindings);
bindings.add(SH.currentShapeVar.getVarName(), constraint.getShapeResource());
bindings.add(SH.shapesGraphVar.getVarName(), ResourceFactory.createResource(engine.getShapesGraphURI().toString()));
Resource path = constraint.getShapeResource().getPath();
if(path != null && path.isURIResource()) {
bindings.add(SH.PATHVar.getName(), path);
}
URI oldShapesGraphURI = HasShapeFunction.getShapesGraphURI();
ShapesGraph oldShapesGraph = HasShapeFunction.getShapesGraph();
if(!engine.getShapesGraphURI().equals(oldShapesGraphURI)) {
HasShapeFunction.setShapesGraph(engine.getShapesGraph(), engine.getShapesGraphURI());
}
Model oldNestedResults = HasShapeFunction.getResultsModel();
Model nestedResults = JenaUtil.createMemoryModel();
HasShapeFunction.setResultsModel(nestedResults);
try {
long startTime = System.currentTimeMillis();
Resource messageHolder = getSPARQLExecutable(constraint);
for(RDFNode focusNode : focusNodes) {
bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding
QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings);
executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings);
engine.checkCanceled();
}
if(ExecStatisticsManager.get().isRecording()) {
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
String label = getLabel(constraint);
Iterator<String> varNames = bindings.varNames();
if(varNames.hasNext()) {
queryString += "\nBindings:";
while(varNames.hasNext()) {
String varName = varNames.next();
queryString += "\n- ?" + varName + ": " + bindings.get(varName);
}
}
ExecStatistics stats = new ExecStatistics(label, queryString, duration, startTime, constraint.getComponent().asNode());
ExecStatisticsManager.get().add(Collections.singletonList(stats));
}
}
finally {
HasShapeFunction.setShapesGraph(oldShapesGraph, oldShapesGraphURI);
HasShapeFunction.setResultsModel(oldNestedResults);
}
}
protected abstract void addBindings(Constraint constraint, QuerySolutionMap bindings);
protected abstract Resource getSPARQLExecutable(Constraint constraint);
protected abstract String getLabel(Constraint constraint);
protected Query getQuery() {
return query;
}
protected abstract String getSPARQL(Constraint constraint);
private void executeSelectQuery(ValidationEngine engine, Constraint constraint, Resource messageHolder, Model nestedResults,
RDFNode focusNode, QueryExecution qexec, QuerySolution bindings) {
ResultSet rs = qexec.execSelect();
if(!rs.getResultVars().contains("this")) {
qexec.close();
throw new IllegalArgumentException("SELECT constraints must return $this");
}
try {
if(rs.hasNext()) {
while(rs.hasNext()) {
QuerySolution sol = rs.next();
RDFNode thisValue = sol.get(SH.thisVar.getVarName());
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
}
else {
message += RDFLabels.get().getLabel((Resource)focusNode);
}
}
FailureLog.get().logFailure(message);
selectMessage = ResourceFactory.createTypedLiteral("Validation Failure: Could not validate shape");
}
Resource result = engine.createResult(resultType, constraint, thisValue);
if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) {
result.addProperty(SH.sourceConstraint, constraint.getParameterValue());
}
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
else if(constraint.getShapeResource().hasProperty(SH.message)) {
for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) {
result.addProperty(SH.resultMessage, s.getObject());
}
}
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
RDFNode pathValue = sol.get(SH.pathVar.getVarName());
if(pathValue != null && pathValue.isURIResource()) {
result.addProperty(SH.resultPath, pathValue);
}
else if(constraint.getShapeResource().isPropertyShape()) {
Resource basePath = constraint.getShapeResource().getPropertyResourceValue(SH.path);
result.addProperty(SH.resultPath, SHACLPaths.clonePath(basePath, result.getModel()));
}
if(!SH.HasValueConstraintComponent.equals(constraint.getComponent())) { // See https://github.com/w3c/data-shapes/issues/111
RDFNode selectValue = sol.get(SH.valueVar.getVarName());
if(selectValue != null) {
result.addProperty(SH.value, selectValue);
}
else if(SH.NodeShape.equals(constraint.getContext())) {
result.addProperty(SH.value, focusNode);
}
}
if(engine.getConfiguration().getReportDetails()) {
addDetails(result, nestedResults);
}
}
}
}
else if(createSuccessResults) {
Resource success = engine.createResult(DASH.SuccessResult, constraint, focusNode);
if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) {
success.addProperty(SH.sourceConstraint, constraint.getParameterValue());
}
if(engine.getConfiguration().getReportDetails()) {
addDetails(success, nestedResults);
}
}
}
finally {
qexec.close();
}
}
private void addDefaultMessages(ValidationEngine engine, Resource messageHolder, Resource fallback, Resource result,
QuerySolution bindings, QuerySolution solution) {
boolean found = false;
for(Statement s : messageHolder.listProperties(SH.message).toList()) {
if(s.getObject().isLiteral()) {
QuerySolutionMap map = new QuerySolutionMap();
map.addAll(bindings);
map.addAll(solution);
engine.addResultMessage(result, s.getLiteral(), map);
found = true;
}
}
if(!found && fallback != null) {
addDefaultMessages(engine, fallback, null, result, bindings, solution);
}
}
public static void addDetails(Resource parentResult, Model nestedResults) {
if(!nestedResults.isEmpty()) {
parentResult.getModel().add(nestedResults);
for(Resource type : SHACLUtil.RESULT_TYPES) {
for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) {
if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) {
parentResult.addProperty(SH.detail, nestedResult);
}
}
}
}
}
}
<MSG> Fixed sh:message issue #13
<DFF> @@ -171,6 +171,11 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor {
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
+ else if(constraint.getShapeResource().hasProperty(SH.message)) {
+ for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) {
+ result.addProperty(SH.resultMessage, s.getObject());
+ }
+ }
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
| 5 | Fixed sh:message issue #13 | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
225 | <NME> AbstractSPARQLExecutor.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation.sparql;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryParseException;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.QuerySolutionMap;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.statistics.ExecStatistics;
import org.topbraid.jenax.statistics.ExecStatisticsManager;
import org.topbraid.jenax.util.ARQFactory;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.jenax.util.RDFLabels;
import org.topbraid.shacl.arq.SHACLPaths;
import org.topbraid.shacl.arq.functions.HasShapeFunction;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.util.FailureLog;
import org.topbraid.shacl.util.SHACLUtil;
import org.topbraid.shacl.validation.ConstraintExecutor;
import org.topbraid.shacl.validation.SHACLException;
import org.topbraid.shacl.validation.ValidationEngine;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
public abstract class AbstractSPARQLExecutor implements ConstraintExecutor {
// Flag to generate dash:SuccessResults for all violations.
public static boolean createSuccessResults = false;
private Query query;
private String queryString;
protected AbstractSPARQLExecutor(Constraint constraint) {
this.queryString = getSPARQL(constraint);
try {
this.query = ARQFactory.get().createQuery(queryString);
Resource path = constraint.getShapeResource().getPath();
if(path != null && path.isAnon()) {
String pathString = SHACLPaths.getPathString(constraint.getShapeResource().getPropertyResourceValue(SH.path));
query = SPARQLSubstitutions.substitutePaths(query, pathString, constraint.getShapeResource().getModel());
}
}
catch(QueryParseException ex) {
throw new SHACLException("Invalid SPARQL constraint (" + ex.getLocalizedMessage() + "):\n" + queryString);
}
if(!query.isSelectType()) {
throw new IllegalArgumentException("SHACL constraints must be SELECT queries");
}
}
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
QuerySolutionMap bindings = new QuerySolutionMap();
addBindings(constraint, bindings);
bindings.add(SH.currentShapeVar.getVarName(), constraint.getShapeResource());
bindings.add(SH.shapesGraphVar.getVarName(), ResourceFactory.createResource(engine.getShapesGraphURI().toString()));
Resource path = constraint.getShapeResource().getPath();
if(path != null && path.isURIResource()) {
bindings.add(SH.PATHVar.getName(), path);
}
URI oldShapesGraphURI = HasShapeFunction.getShapesGraphURI();
ShapesGraph oldShapesGraph = HasShapeFunction.getShapesGraph();
if(!engine.getShapesGraphURI().equals(oldShapesGraphURI)) {
HasShapeFunction.setShapesGraph(engine.getShapesGraph(), engine.getShapesGraphURI());
}
Model oldNestedResults = HasShapeFunction.getResultsModel();
Model nestedResults = JenaUtil.createMemoryModel();
HasShapeFunction.setResultsModel(nestedResults);
try {
long startTime = System.currentTimeMillis();
Resource messageHolder = getSPARQLExecutable(constraint);
for(RDFNode focusNode : focusNodes) {
bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding
QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings);
executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings);
engine.checkCanceled();
}
if(ExecStatisticsManager.get().isRecording()) {
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
String label = getLabel(constraint);
Iterator<String> varNames = bindings.varNames();
if(varNames.hasNext()) {
queryString += "\nBindings:";
while(varNames.hasNext()) {
String varName = varNames.next();
queryString += "\n- ?" + varName + ": " + bindings.get(varName);
}
}
ExecStatistics stats = new ExecStatistics(label, queryString, duration, startTime, constraint.getComponent().asNode());
ExecStatisticsManager.get().add(Collections.singletonList(stats));
}
}
finally {
HasShapeFunction.setShapesGraph(oldShapesGraph, oldShapesGraphURI);
HasShapeFunction.setResultsModel(oldNestedResults);
}
}
protected abstract void addBindings(Constraint constraint, QuerySolutionMap bindings);
protected abstract Resource getSPARQLExecutable(Constraint constraint);
protected abstract String getLabel(Constraint constraint);
protected Query getQuery() {
return query;
}
protected abstract String getSPARQL(Constraint constraint);
private void executeSelectQuery(ValidationEngine engine, Constraint constraint, Resource messageHolder, Model nestedResults,
RDFNode focusNode, QueryExecution qexec, QuerySolution bindings) {
ResultSet rs = qexec.execSelect();
if(!rs.getResultVars().contains("this")) {
qexec.close();
throw new IllegalArgumentException("SELECT constraints must return $this");
}
try {
if(rs.hasNext()) {
while(rs.hasNext()) {
QuerySolution sol = rs.next();
RDFNode thisValue = sol.get(SH.thisVar.getVarName());
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
}
else {
message += RDFLabels.get().getLabel((Resource)focusNode);
}
}
FailureLog.get().logFailure(message);
selectMessage = ResourceFactory.createTypedLiteral("Validation Failure: Could not validate shape");
}
Resource result = engine.createResult(resultType, constraint, thisValue);
if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) {
result.addProperty(SH.sourceConstraint, constraint.getParameterValue());
}
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
else if(constraint.getShapeResource().hasProperty(SH.message)) {
for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) {
result.addProperty(SH.resultMessage, s.getObject());
}
}
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
RDFNode pathValue = sol.get(SH.pathVar.getVarName());
if(pathValue != null && pathValue.isURIResource()) {
result.addProperty(SH.resultPath, pathValue);
}
else if(constraint.getShapeResource().isPropertyShape()) {
Resource basePath = constraint.getShapeResource().getPropertyResourceValue(SH.path);
result.addProperty(SH.resultPath, SHACLPaths.clonePath(basePath, result.getModel()));
}
if(!SH.HasValueConstraintComponent.equals(constraint.getComponent())) { // See https://github.com/w3c/data-shapes/issues/111
RDFNode selectValue = sol.get(SH.valueVar.getVarName());
if(selectValue != null) {
result.addProperty(SH.value, selectValue);
}
else if(SH.NodeShape.equals(constraint.getContext())) {
result.addProperty(SH.value, focusNode);
}
}
if(engine.getConfiguration().getReportDetails()) {
addDetails(result, nestedResults);
}
}
}
}
else if(createSuccessResults) {
Resource success = engine.createResult(DASH.SuccessResult, constraint, focusNode);
if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) {
success.addProperty(SH.sourceConstraint, constraint.getParameterValue());
}
if(engine.getConfiguration().getReportDetails()) {
addDetails(success, nestedResults);
}
}
}
finally {
qexec.close();
}
}
private void addDefaultMessages(ValidationEngine engine, Resource messageHolder, Resource fallback, Resource result,
QuerySolution bindings, QuerySolution solution) {
boolean found = false;
for(Statement s : messageHolder.listProperties(SH.message).toList()) {
if(s.getObject().isLiteral()) {
QuerySolutionMap map = new QuerySolutionMap();
map.addAll(bindings);
map.addAll(solution);
engine.addResultMessage(result, s.getLiteral(), map);
found = true;
}
}
if(!found && fallback != null) {
addDefaultMessages(engine, fallback, null, result, bindings, solution);
}
}
public static void addDetails(Resource parentResult, Model nestedResults) {
if(!nestedResults.isEmpty()) {
parentResult.getModel().add(nestedResults);
for(Resource type : SHACLUtil.RESULT_TYPES) {
for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) {
if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) {
parentResult.addProperty(SH.detail, nestedResult);
}
}
}
}
}
}
<MSG> Fixed sh:message issue #13
<DFF> @@ -171,6 +171,11 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor {
if(selectMessage != null) {
result.addProperty(SH.resultMessage, selectMessage);
}
+ else if(constraint.getShapeResource().hasProperty(SH.message)) {
+ for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) {
+ result.addProperty(SH.resultMessage, s.getObject());
+ }
+ }
else {
addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol);
}
| 5 | Fixed sh:message issue #13 | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
226 | <NME> shaclsquare.ttl
<BEF> ADDFILE
<MSG> Progress with refactoring towards node constraints, including some renamings and generalizations (ISSUE-98)
<DFF> @@ -0,0 +1,149 @@
+# baseURI: http://topbraid.org/examples/shaclsquare
+# imports: http://www.w3.org/ns/shacl
+# prefix: ex
+
+@prefix arg: <http://www.w3.org/ns/shacl/arg#> .
+@prefix ex: <http://topbraid.org/examples/shaclsquare#> .
+@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 schema: <http://schema.org/> .
+@prefix sh: <http://www.w3.org/ns/shacl#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+schema:Person
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Person" ;
+ rdfs:subClassOf rdfs:Resource ;
+ sh:property [
+ rdfs:comment "Zero or more email addresses of the person." ;
+ rdfs:label "email" ;
+ sh:datatype xsd:string ;
+ sh:predicate schema:email ;
+ ] ;
+.
+<http://topbraid.org/examples/shaclsquare>
+ rdf:type sh:Graph ;
+ rdfs:comment "A simple example model demonstrating some key features of SHACL. Have a look at the ex:computeArea function, the rule attached to ex:Rectangle and the constraint attached to ex:Square." ;
+ rdfs:label "SHACL Square Example" ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+ex:InvalidSquare
+ rdf:type ex:Square ;
+ ex:creator ex:PersonWithoutEmail ;
+ ex:height 8 ;
+ ex:width 9 ;
+ rdfs:label "Invalid square" ;
+.
+ex:PersonWithEmail
+ rdf:type schema:Person ;
+ schema:email "john@example.com" ;
+.
+ex:PersonWithoutEmail
+ rdf:type schema:Person ;
+.
+ex:PositivePropertyValueConstraint
+ rdf:type sh:ConstraintTemplate ;
+ rdfs:comment "A template that can be used to define a SHACL constraint on a given property (arg:property) to make sure that the values of that property are > 0." ;
+ rdfs:label "Positive property value constraint" ;
+ rdfs:subClassOf sh:TemplateConstraint ;
+ sh:argument [
+ rdfs:comment "The property to constrain (e.g. ex:width or ex:height)." ;
+ rdfs:label "property" ;
+ sh:class rdfs:Resource ;
+ sh:predicate arg:property ;
+ ] ;
+ sh:labelTemplate "Values of property {?property} must be > 0" ;
+ sh:message "Property {?property} must only have positive values, but found {?object}" ;
+ sh:sparql """
+ SELECT ?this (?this AS ?subject) (?property AS ?predicate) ?object ?property
+ WHERE {
+ ?this ?property ?object .
+ FILTER (?object <= 0) .
+ }
+ """ ;
+.
+ex:Rectangle
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Rectangle" ;
+ rdfs:subClassOf rdfs:Resource ;
+ sh:constraint [
+ rdf:type ex:PositivePropertyValueConstraint ;
+ arg:property ex:height ;
+ ] ;
+ sh:constraint [
+ rdf:type ex:PositivePropertyValueConstraint ;
+ arg:property ex:width ;
+ ] ;
+ sh:property [
+ rdfs:comment "The creator of the Rectangle." ;
+ rdfs:label "creator" ;
+ sh:class schema:Person ;
+ sh:maxCount 1 ;
+ sh:predicate ex:creator ;
+ sh:valueShape [
+ sh:property [
+ sh:minCount 1 ;
+ sh:predicate schema:email ;
+ ] ;
+ ] ;
+ ] ;
+ sh:property [
+ rdfs:comment "The height of the Rectangle." ;
+ rdfs:label "height" ;
+ sh:datatype xsd:integer ;
+ sh:maxCount 1 ;
+ sh:minCount 1 ;
+ sh:predicate ex:height ;
+ ] ;
+ sh:property [
+ rdfs:comment "The width of the Rectangle." ;
+ rdfs:label "width" ;
+ sh:datatype xsd:integer ;
+ sh:maxCount 1 ;
+ sh:minCount 1 ;
+ sh:predicate ex:width ;
+ ] ;
+.
+ex:Square
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Square" ;
+ rdfs:subClassOf ex:Rectangle ;
+ sh:constraint [
+ sh:message "Width and height of a Square must be equal" ;
+ sh:predicate ex:width ;
+ sh:sparql """
+ SELECT ?this (?this AS ?subject) (?width AS ?object)
+ WHERE {
+ ?this ex:width ?width .
+ ?this ex:height ?height .
+ FILTER (?width != ?height) .
+ }
+ """ ;
+ ] ;
+.
+ex:TestRectangle
+ rdf:type ex:Rectangle ;
+ ex:creator ex:PersonWithEmail ;
+ ex:height 6 ;
+ ex:width 7 ;
+ rdfs:label "Test rectangle" ;
+.
+ex:computeArea
+ rdf:type sh:Function ;
+ rdfs:comment "Computes the area of a given rectangle (?arg1) as the product of its width and height." ;
+ rdfs:label "compute area" ;
+ sh:argument [
+ rdfs:comment "The rectangle whose area to compute." ;
+ sh:class ex:Rectangle ;
+ sh:predicate sh:arg1 ;
+ ] ;
+ sh:returnType xsd:integer ;
+ sh:sparql """
+ SELECT ((?width * ?height) AS ?result)
+ WHERE {
+ ?arg1 ex:width ?width .
+ ?arg1 ex:height ?height .
+ }
+ """ ;
+.
| 149 | Progress with refactoring towards node constraints, including some renamings and generalizations (ISSUE-98) | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
227 | <NME> shaclsquare.ttl
<BEF> ADDFILE
<MSG> Progress with refactoring towards node constraints, including some renamings and generalizations (ISSUE-98)
<DFF> @@ -0,0 +1,149 @@
+# baseURI: http://topbraid.org/examples/shaclsquare
+# imports: http://www.w3.org/ns/shacl
+# prefix: ex
+
+@prefix arg: <http://www.w3.org/ns/shacl/arg#> .
+@prefix ex: <http://topbraid.org/examples/shaclsquare#> .
+@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 schema: <http://schema.org/> .
+@prefix sh: <http://www.w3.org/ns/shacl#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+schema:Person
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Person" ;
+ rdfs:subClassOf rdfs:Resource ;
+ sh:property [
+ rdfs:comment "Zero or more email addresses of the person." ;
+ rdfs:label "email" ;
+ sh:datatype xsd:string ;
+ sh:predicate schema:email ;
+ ] ;
+.
+<http://topbraid.org/examples/shaclsquare>
+ rdf:type sh:Graph ;
+ rdfs:comment "A simple example model demonstrating some key features of SHACL. Have a look at the ex:computeArea function, the rule attached to ex:Rectangle and the constraint attached to ex:Square." ;
+ rdfs:label "SHACL Square Example" ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+ex:InvalidSquare
+ rdf:type ex:Square ;
+ ex:creator ex:PersonWithoutEmail ;
+ ex:height 8 ;
+ ex:width 9 ;
+ rdfs:label "Invalid square" ;
+.
+ex:PersonWithEmail
+ rdf:type schema:Person ;
+ schema:email "john@example.com" ;
+.
+ex:PersonWithoutEmail
+ rdf:type schema:Person ;
+.
+ex:PositivePropertyValueConstraint
+ rdf:type sh:ConstraintTemplate ;
+ rdfs:comment "A template that can be used to define a SHACL constraint on a given property (arg:property) to make sure that the values of that property are > 0." ;
+ rdfs:label "Positive property value constraint" ;
+ rdfs:subClassOf sh:TemplateConstraint ;
+ sh:argument [
+ rdfs:comment "The property to constrain (e.g. ex:width or ex:height)." ;
+ rdfs:label "property" ;
+ sh:class rdfs:Resource ;
+ sh:predicate arg:property ;
+ ] ;
+ sh:labelTemplate "Values of property {?property} must be > 0" ;
+ sh:message "Property {?property} must only have positive values, but found {?object}" ;
+ sh:sparql """
+ SELECT ?this (?this AS ?subject) (?property AS ?predicate) ?object ?property
+ WHERE {
+ ?this ?property ?object .
+ FILTER (?object <= 0) .
+ }
+ """ ;
+.
+ex:Rectangle
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Rectangle" ;
+ rdfs:subClassOf rdfs:Resource ;
+ sh:constraint [
+ rdf:type ex:PositivePropertyValueConstraint ;
+ arg:property ex:height ;
+ ] ;
+ sh:constraint [
+ rdf:type ex:PositivePropertyValueConstraint ;
+ arg:property ex:width ;
+ ] ;
+ sh:property [
+ rdfs:comment "The creator of the Rectangle." ;
+ rdfs:label "creator" ;
+ sh:class schema:Person ;
+ sh:maxCount 1 ;
+ sh:predicate ex:creator ;
+ sh:valueShape [
+ sh:property [
+ sh:minCount 1 ;
+ sh:predicate schema:email ;
+ ] ;
+ ] ;
+ ] ;
+ sh:property [
+ rdfs:comment "The height of the Rectangle." ;
+ rdfs:label "height" ;
+ sh:datatype xsd:integer ;
+ sh:maxCount 1 ;
+ sh:minCount 1 ;
+ sh:predicate ex:height ;
+ ] ;
+ sh:property [
+ rdfs:comment "The width of the Rectangle." ;
+ rdfs:label "width" ;
+ sh:datatype xsd:integer ;
+ sh:maxCount 1 ;
+ sh:minCount 1 ;
+ sh:predicate ex:width ;
+ ] ;
+.
+ex:Square
+ rdf:type sh:ShapeClass ;
+ rdfs:label "Square" ;
+ rdfs:subClassOf ex:Rectangle ;
+ sh:constraint [
+ sh:message "Width and height of a Square must be equal" ;
+ sh:predicate ex:width ;
+ sh:sparql """
+ SELECT ?this (?this AS ?subject) (?width AS ?object)
+ WHERE {
+ ?this ex:width ?width .
+ ?this ex:height ?height .
+ FILTER (?width != ?height) .
+ }
+ """ ;
+ ] ;
+.
+ex:TestRectangle
+ rdf:type ex:Rectangle ;
+ ex:creator ex:PersonWithEmail ;
+ ex:height 6 ;
+ ex:width 7 ;
+ rdfs:label "Test rectangle" ;
+.
+ex:computeArea
+ rdf:type sh:Function ;
+ rdfs:comment "Computes the area of a given rectangle (?arg1) as the product of its width and height." ;
+ rdfs:label "compute area" ;
+ sh:argument [
+ rdfs:comment "The rectangle whose area to compute." ;
+ sh:class ex:Rectangle ;
+ sh:predicate sh:arg1 ;
+ ] ;
+ sh:returnType xsd:integer ;
+ sh:sparql """
+ SELECT ((?width * ?height) AS ?result)
+ WHERE {
+ ?arg1 ex:width ?width .
+ ?arg1 ex:height ?height .
+ }
+ """ ;
+.
| 149 | Progress with refactoring towards node constraints, including some renamings and generalizations (ISSUE-98) | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
228 | <NME> ValidationExample.java
<BEF> package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
public class ValidationExample {
/**
* Loads an example SHACL file and validates all focus nodes against all shapes.
*/
public static void main(String[] args) throws Exception {
// Load the main data model
Model dataModel = JenaUtil.createMemoryModel();
dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
// Perform the validation of everything, using the data model
// also as the shapes model - you may have them separated
Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
// Print violations
System.out.println(ModelPrinter.get().print(report.getModel()));
}
}
<MSG> Add license header to org.topbraid.shacl
<DFF> @@ -1,3 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
| 16 | Add license header to org.topbraid.shacl | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
229 | <NME> ValidationExample.java
<BEF> package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
public class ValidationExample {
/**
* Loads an example SHACL file and validates all focus nodes against all shapes.
*/
public static void main(String[] args) throws Exception {
// Load the main data model
Model dataModel = JenaUtil.createMemoryModel();
dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
// Perform the validation of everything, using the data model
// also as the shapes model - you may have them separated
Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
// Print violations
System.out.println(ModelPrinter.get().print(report.getModel()));
}
}
<MSG> Add license header to org.topbraid.shacl
<DFF> @@ -1,3 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
| 16 | Add license header to org.topbraid.shacl | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
230 | <NME> SHResultImpl.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.model.impl;
import org.apache.jena.enhanced.EnhGraph;
import org.apache.jena.graph.Node;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.model.SHResult;
import org.topbraid.shacl.vocabulary.SH;
public class SHResultImpl extends SHResourceImpl implements SHResult {
public SHResultImpl(Node node, EnhGraph graph) {
super(node, graph);
}
@Override
public RDFNode getFocusNode() {
return JenaUtil.getProperty(this, SH.focusNode);
}
@Override
public String getMessage() {
return JenaUtil.getStringProperty(this, SH.resultMessage);
}
@Override
public Resource getPath() {
return getPropertyResourceValue(SH.resultPath);
}
@Override
public Resource getSeverity() {
return getPropertyResourceValue(SH.resultSeverity);
}
@Override
public Resource getSourceConstraint() {
return getPropertyResourceValue(SH.sourceConstraint);
}
@Override
public Resource getSourceConstraintComponent() {
return getPropertyResourceValue(SH.sourceConstraintComponent);
}
@Override
public Resource getSourceShape() {
return JenaUtil.getResourceProperty(this, SH.sourceShape);
}
}
}
<MSG> Read sh:resultSeverity from SHResult
<DFF> @@ -71,4 +71,9 @@ public class SHResultImpl extends SHResourceImpl implements SHResult {
public Resource getSourceShape() {
return JenaUtil.getResourceProperty(this, SH.sourceShape);
}
+
+ @Override
+ public Resource getResultSeverity() {
+ return JenaUtil.getResourceProperty(this, SH.resultSeverity);
+ }
}
\ No newline at end of file
| 5 | Read sh:resultSeverity from SHResult | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
231 | <NME> SHResultImpl.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.model.impl;
import org.apache.jena.enhanced.EnhGraph;
import org.apache.jena.graph.Node;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.model.SHResult;
import org.topbraid.shacl.vocabulary.SH;
public class SHResultImpl extends SHResourceImpl implements SHResult {
public SHResultImpl(Node node, EnhGraph graph) {
super(node, graph);
}
@Override
public RDFNode getFocusNode() {
return JenaUtil.getProperty(this, SH.focusNode);
}
@Override
public String getMessage() {
return JenaUtil.getStringProperty(this, SH.resultMessage);
}
@Override
public Resource getPath() {
return getPropertyResourceValue(SH.resultPath);
}
@Override
public Resource getSeverity() {
return getPropertyResourceValue(SH.resultSeverity);
}
@Override
public Resource getSourceConstraint() {
return getPropertyResourceValue(SH.sourceConstraint);
}
@Override
public Resource getSourceConstraintComponent() {
return getPropertyResourceValue(SH.sourceConstraintComponent);
}
@Override
public Resource getSourceShape() {
return JenaUtil.getResourceProperty(this, SH.sourceShape);
}
}
}
<MSG> Read sh:resultSeverity from SHResult
<DFF> @@ -71,4 +71,9 @@ public class SHResultImpl extends SHResourceImpl implements SHResult {
public Resource getSourceShape() {
return JenaUtil.getResourceProperty(this, SH.sourceShape);
}
+
+ @Override
+ public Resource getResultSeverity() {
+ return JenaUtil.getResourceProperty(this, SH.resultSeverity);
+ }
}
\ No newline at end of file
| 5 | Read sh:resultSeverity from SHResult | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
232 | <NME> tosh.ttl <BEF> # baseURI: http://topbraid.org/tosh # imports: http://datashapes.org/dash # prefix: tosh @prefix dash: <http://datashapes.org/dash#> . @prefix graphql: <http://datashapes.org/graphql#> . @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 swa: <http://topbraid.org/swa#> . @prefix tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . dash: tosh:systemNamespace true ; . dash:Action sh:property tosh:Action-actionGroup ; sh:property tosh:Action-actionIconClass ; sh:property tosh:Action-deactivated ; . dash:ActionGroup sh:property tosh:ActionGroup-order ; sh:property tosh:Resource-comment ; . dash:NonRecursiveConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:NonRecursiveConstraintComponent-nonRecursive sh:group tosh:RelationshipPropertyGroup ; . dash:PrimaryKeyConstraintComponent-uriStart tosh:editWidget swa:PlainTextFieldEditor ; sh:group tosh:PrimaryKeyPropertyGroup ; . dash:RootClassConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; sh:group tosh:ValidationPropertyGroup ; . dash:CoExistsWithConstraintComponent-coExistsWith sh:group tosh:PropertyPairConstraintsPropertyGroup ; sh:order "0"^^xsd:decimal ; . dash:DetailsEditor dash:hidden true ; owl:versionInfo "This is not yet supported by TopBraid." ; . dash:FunctionTestCase sh:property tosh:FunctionTestCase-expectedResult ; sh:property tosh:FunctionTestCase-expression ; . dash:GraphStoreTestCase }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:group tosh:RelationshipPropertyGroup ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . . dash:InferencingTestCase sh:property tosh:InferencingTestCase-expectedResult ; . dash:JSTestCase sh:property tosh:JSTestCase-expectedResult ; . dash:MultiFunction sh:property tosh:Function-apiStatus ; sh:property tosh:MultiFunction-resultVariable ; . dash:NonRecursiveConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:NonRecursiveConstraintComponent-nonRecursive sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "5"^^xsd:decimal ; . dash:PrimaryKeyConstraintComponent-uriStart sh:group tosh:StringConstraintsPropertyGroup ; sh:order "40"^^xsd:decimal ; . dash:PropertyRole sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; . dash:QueryTestCase sh:property tosh:QueryTestCase-expectedResult ; . dash:ReifiableByConstraintComponent-reifiableBy sh:group tosh:ReificationPropertyGroup ; sh:order "0"^^xsd:decimal ; . dash:ResourceAction sh:property tosh:ResourceAction-jsCondition ; . dash:RootClassConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:RootClassConstraintComponent-rootClass sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "10"^^xsd:decimal ; . dash:SPARQLConstructTemplate a sh:NodeShape ; sh:property tosh:Parameterizable-labelTemplate ; . dash:SPARQLSelectTemplate a sh:NodeShape ; sh:property tosh:Parameterizable-labelTemplate ; . dash:Script sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; sh:property tosh:Script-js ; . dash:ScriptConstraint sh:property tosh:Script-onAllValues ; sh:property tosh:ScriptConstraint-deactivated ; sh:property tosh:ScriptConstraint-message ; . dash:ScriptConstraintComponent-scriptConstraint sh:group tosh:AdvancedPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:ScriptFunction sh:property tosh:ScriptFunction-canWrite ; . dash:ScriptTestCase sh:property tosh:ScriptTestCase-expectedResult ; sh:property tosh:ScriptTestCase-focusNode ; . dash:ScriptValidator sh:property tosh:Script-onAllValues ; . dash:Service sh:property tosh:Service-canWrite ; sh:property tosh:Service-deactivated ; sh:property tosh:Service-responseContentType ; . dash:StemConstraintComponent-stem sh:group tosh:StringConstraintsPropertyGroup ; sh:order "45"^^xsd:decimal ; . dash:SubSetOfConstraintComponent-subSetOf sh:group tosh:PropertyPairConstraintsPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:SymmetricConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator [ a dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add symmetric value." ; sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """INSERT { $value $predicate $focusNode . } WHERE { }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "10"^^xsd:decimal ; . dash:TestCase sh:property tosh:TestCase-deactivated ; . dash:TestCaseResult sh:property [ a sh:PropertyShape ; sh:path dash:testCase ; sh:class dash:TestCase ; sh:description "The dash:TestCase that was executed." ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "test case" ; ] ; sh:property [ a sh:PropertyShape ; sh:path dash:testGraph ; sh:class rdfs:Resource ; sh:description "The graph containing the test case." ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "test graph" ; sh:nodeKind sh:IRI ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:ValidationTestCase sh:property tosh:ValidationTestCase-expectedResult ; sh:property tosh:ValidationTestCase-includeSuggestions ; sh:property tosh:ValidationTestCase-validateShapes ; . tosh:PropertyShapeShape a sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ a sh:PropertyShape ; sh:path dash:detailsEndpoint ; sh:datatype xsd:string ; sh:group tosh:RemoteValuesPropertyGroup ; sh:maxCount 1 ; sh:order "0"^^xsd:decimal ; ] ; sh:property [ a sh:PropertyShape ; sh:path sh:values ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . <http://spinrdf.org/spin#> tosh:systemNamespace true ; . <http://spinrdf.org/spl#> tosh:systemNamespace true ; . <http://topbraid.org/tosh> a owl:Ontology ; dash:generateClass dash:ConstraintReificationShape ; dash:generateClass rdf:Property ; dash:generateClass rdfs:Class ; dash:generateClass rdfs:Datatype ; dash:generateClass owl:Class ; dash:generateClass owl:Ontology ; dash:generateClass sh:ConstraintComponent ; dash:generateClass sh:PropertyGroup ; dash:generateClass sh:Rule ; dash:generateClass sh:Shape ; dash:generatePrefixConstants "dash" ; dash:generatePrefixConstants "owl" ; dash:generatePrefixConstants "rdf" ; dash:generatePrefixConstants "rdfs" ; dash:generatePrefixConstants "sh" ; dash:generatePrefixConstants "xsd" ; rdfs:comment """A collection of SHACL features that are available whenever SHACL graphs are used within TopBraid Suite products. In particular this includes shape definitions for the \"system\" classes such as rdfs:Class, sh:PropertyShape etc. These shapes are used by TopBraid products to validate ontology definitions and to drive user interface forms. The TOSH namespace also includes things like suggestions, Active Data Shapes scripts and a couple of SPARQL functions. Some of these may be of general use outside of TopBraid too.""" ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; sh:prefix "afn" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; sh:prefix "spif" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; sh:prefix "tosh" ; ] ; . tosh: tosh:systemNamespace true ; . tosh:Action-actionGroup a sh:PropertyShape ; sh:path dash:actionGroup ; sh:class dash:ActionGroup ; sh:description "The Action Group that the action should appear in (in menus etc)." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:order "5"^^xsd:decimal ; . tosh:Action-actionIconClass a sh:PropertyShape ; sh:path dash:actionIconClass ; sh:datatype xsd:string ; sh:description "The CSS class for the action for display purposes. For example, pick one of https://fontawesome.com/icons?d=gallery&m=free or https://getbootstrap.com/docs/3.3/components/#glyphicons-glyphs" ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:order "7"^^xsd:decimal ; . tosh:Action-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this action (from user interfaces)." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "8"^^xsd:decimal ; . tosh:ActionGroup-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this group compared to other groups, e.g. to display in drop down menus." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; . tosh:ActionTestCase-action a sh:PropertyShape ; sh:path dash:action ; sh:class dash:Action ; sh:description "The dash:Action to execute." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "action" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:ActionTestCase-expectedResult sh:name "on property" ; sh:order 0 ; ] ; sh:sparql [ sh:message "Property shapes cannot have both class and datatype constraints." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER EXISTS { $this sh:class ?class . $this sh:datatype ?datatype . } }""" ; ] ; sh:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup sh:order "10"^^xsd:decimal ; . rdfs:label "Relationship" ; sh:order 8 ; . tosh:RemoteValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Remote Values" ; sh:order "12"^^xsd:decimal ; . tosh:ReplaceWithDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to replace all values of the given predicate (which must exist) at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; sh:name "focus node" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "5"^^xsd:decimal ; . tosh:ActionTestCase-variables a sh:PropertyShape ; sh:path dash:variables ; sh:datatype xsd:string ; sh:description """A JSON object (string) with name-value pairs for the variable bindings. This must be in the same format as expected by the script servlet. For parameters that declare dash:mimeTypes (i.e. file upload parameters), the value needs to be the path to a file relative to the workspace root. This file will be temporarily uploaded for the duration of the test case execution.""" ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "variables" ; sh:order "2"^^xsd:decimal ; . tosh:AdvancedPropertyGroup a sh:PropertyGroup ; rdfs:label "Advanced" ; sh:order "95"^^xsd:decimal ; . tosh:ChangeScript-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this script, for example for testing purposes, without having to delete it." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "10"^^xsd:decimal ; . tosh:ChangeScript-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this script compared to other change scripts. The default value is 0. Scripts with lower numbers are executed first." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "40"^^xsd:decimal ; . tosh:Class-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of sh:NodeShape. * @returns {sh_NodeShape} */ asNodeShape() { return sh.asNodeShape(this); } /** * @callback rdfs_Class_callback * @param {rdfs_Class} class the visited class */ /** * Performs a depth-first traversal this class and its superclasses, visiting each (super) class * once until the callback function returns a non-null/undefined result. This becomes the result of this function. * The order in which sibling classes are traversed is undefined, so results may be inconsistent in * multiple-inheritance scenarios. * @param {rdfs_Class_callback} callback the callback for each class * @param {Set} [reached] the Set of reached URI strings, used internally * @returns the return value of the first callback that returned any value */ walkSuperclasses(callback, reached) { if(!reached) { reached = new Set(); } if(!reached.has(this.uri)) { reached.add(this.uri); let result = callback(this); if(result !== undefined && result !== null) { return result; } let supers = this.superclasses; for(let i = 0; i < supers.length; i++) { result = supers[i].walkSuperclasses(callback, reached); if(result !== undefined && result !== null) { return result; } } } } """ ; . tosh:Class-abstract a sh:PropertyShape ; sh:path dash:abstract ; sh:datatype xsd:boolean ; sh:description "States whether this class is abstract, i.e. cannot have direct instances. Abstract classes are typically used to defined shared properties of its subclasses." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "abstract" ; sh:order "30"^^xsd:decimal ; . tosh:Class-classIcon a sh:PropertyShape ; sh:path tosh:classIcon ; dash:hidden true ; dash:propertyRole dash:IconRole ; sh:datatype xsd:string ; sh:defaultValue "http://datashapes.org/icons/class.svg" ; sh:description "Used to return the default icon for all classes." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "class icon" ; sh:order "1"^^xsd:decimal ; . tosh:Class-constructor a sh:PropertyShape ; sh:path dash:constructor ; graphql:name "constructorScript" ; sh:class dash:Constructor ; sh:description "The Constructor that shall be used to create new instances of this class or its subclasses." ; sh:group tosh:ScriptsPropertyGroup ; sh:maxCount 1 ; sh:name "constructor" ; sh:order "20"^^xsd:decimal ; . tosh:Class-disjointWith a sh:PropertyShape ; sh:path owl:disjointWith ; sh:class owl:Class ; sh:group tosh:OWLAxiomsPropertyGroup ; sh:name "disjoint with" ; sh:order "1"^^xsd:decimal ; . tosh:Class-domain-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:domain ; ] ; dash:editor dash:PropertyAutoCompleteEditor ; sh:class rdf:Property ; sh:description "The properties that declare to have this class in their domain." ; sh:group tosh:RDFSPropertyAxiomsPropertyGroup ; sh:name "domain of" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:Class-equivalentClass a sh:PropertyShape ; sh:path owl:equivalentClass ; sh:class owl:Class ; sh:group tosh:OWLAxiomsPropertyGroup ; sh:name "equivalent classes" ; sh:order "0"^^xsd:decimal ; . tosh:Class-hidden a sh:PropertyShape ; sh:path dash:hidden ; sh:datatype xsd:boolean ; sh:description "True if this class shall be hidden from the class hierarchies." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "hidden" ; sh:order "0"^^xsd:decimal ; . tosh:Class-range-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:range ; ] ; dash:editor dash:PropertyAutoCompleteEditor ; sh:class rdf:Property ; sh:description "The properties that have this class in their rdfs:range." ; sh:group tosh:RDFSPropertyAxiomsPropertyGroup ; sh:name "range of" ; sh:nodeKind sh:IRI ; sh:order "1"^^xsd:decimal ; . tosh:Class-resourceAction a sh:PropertyShape ; sh:path dash:resourceAction ; graphql:name "resourceActions" ; sh:class dash:ResourceAction ; sh:description "The Resource Actions that can be applied to instances of this class." ; sh:group tosh:ScriptsPropertyGroup ; sh:name "resource actions" ; sh:order "0"^^xsd:decimal ; . tosh:Class-resourceService a sh:PropertyShape ; sh:path dash:resourceService ; graphql:name "resourceServices" ; sh:class dash:ResourceService ; sh:description "The Services that can be applied to instances of this class (as focusNode)." ; rdfs:label "Type of Values" ; sh:order 3 ; . tosh:closed a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment "If set to true, then the corresponding form section will be closed by default." ; rdfs:domain sh:PropertyGroup ; rdfs:label "closed" ; rdfs:range xsd:boolean ; . tosh:countShapesWithMatchResult a sh:SPARQLFunction ; rdfs:comment "Counts the number of shapes from a given rdf:List (?arg2) defined in a given shapes graph (?arg3) where tosh:hasShape returns the provided match value (true or false, ?arg4) for a given focus node (?arg1). The function produces a failure if one of the shapes validated to a failure." ; sh:path rdfs:subClassOf ; graphql:name "superclasses" ; sh:class rdfs:Class ; sh:description "The (direct) parent classes of this class." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "superclasses" ; sh:order "20"^^xsd:decimal ; . tosh:Class-subClassOf-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:subClassOf ; ] ; dash:hidden true ; graphql:name "subclasses" ; sh:class rdfs:Class ; sh:description "The (direct) subclasses of this class." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "subclasses" ; sh:order "21"^^xsd:decimal ; . tosh:ConstraintComponent-localConstraint a sh:PropertyShape ; sh:path dash:localConstraint ; sh:datatype xsd:boolean ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "local constraint" ; sh:order "10"^^xsd:decimal ; . tosh:ConstraintComponent-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message to generate on violations." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "26"^^xsd:decimal ; . tosh:ConstraintComponent-nodeValidator a sh:PropertyShape ; sh:path sh:nodeValidator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate a constraint in the context of a node shape." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "node validators" ; sh:order "2"^^xsd:decimal ; . tosh:ConstraintComponent-propertySuggestionGenerator a sh:PropertyShape ; sh:path dash:propertySuggestionGenerator ; sh:class dash:SuggestionGenerator ; sh:group tosh:ImplementationPropertyGroup ; sh:name "property suggestion generators" ; sh:order "20"^^xsd:decimal ; . tosh:ConstraintComponent-propertyValidator a sh:PropertyShape ; sh:path sh:propertyValidator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate a constraint in the context of a property shape." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "property validators" ; sh:order "1"^^xsd:decimal ; . tosh:ConstraintComponent-staticConstraint a sh:PropertyShape ; sh:path dash:staticConstraint ; sh:datatype xsd:boolean ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "static constraint" ; sh:order "11"^^xsd:decimal ; . tosh:ConstraintComponent-validator a sh:PropertyShape ; sh:path sh:validator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate constraints of either node or property shapes, unless more specific validators are available." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "validators" ; sh:order "0"^^xsd:decimal ; . tosh:DatatypePropertyShapeView a sh:NodeShape ; rdfs:comment "The default view shape for property shapes on datatype values." ; rdfs:label "Attribute view" ; sh:node tosh:PropertyShapeView ; sh:property dash:PrimaryKeyConstraintComponent-uriStart ; sh:property dash:SingleLineConstraintComponent-singleLine ; sh:property tosh:Shape-datatypes ; sh:property sh:LanguageInConstraintComponent-languageIn ; sh:property sh:LessThanConstraintComponent-lessThan ; sh:property sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals ; sh:property sh:MaxExclusiveConstraintComponent-maxExclusive ; sh:property sh:MaxInclusiveConstraintComponent-maxInclusive ; sh:property sh:MaxLengthConstraintComponent-maxLength ; sh:property sh:MinExclusiveConstraintComponent-minExclusive ; sh:property sh:MinInclusiveConstraintComponent-minInclusive ; sh:property sh:MinLengthConstraintComponent-minLength ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; sh:property sh:UniqueLangConstraintComponent-uniqueLang ; ] ; sh:returnType xsd:boolean ; . tosh:isSystemResource a sh:SPARQLFunction ; rdfs:comment "Checks if a given resource is from a namespace that is marked with tosh:systemNamespace true." ; rdfs:label "is system resource" ; sh:ask """ASK { BIND (IRI(afn:namespace($resource)) AS ?namespace) . FILTER (bound(?namespace) && EXISTS { ?namespace tosh:systemNamespace true . }) }""" ; sh:parameter [ a sh:Parameter ; sh:path tosh:resource ; sh:description "The node to check." ; sh:name "resource" ; sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:prefixes <http://topbraid.org/tosh> ; sh:returnType xsd:boolean ; . tosh:open a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment """DEPRECATED: This flag is only used by SWA forms. With the new forms of 6.2 onwards, all form sections are open by default, but you can use tosh:closed to state otherwise. If set to true, then the corresponding form section will be open by default. This only has an effect if sh:openable is set to true as well.""" ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment """DEPRECATED - this was only used by the SWA-based forms that were default before 6.2. In the new forms, all sections are openable. If set to true, then the corresponding form section shall be openable/closable (and show up closed).""" ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . sh:update """DELETE { $focusNode $predicate $value . } WHERE { $focusNode $predicate $value . }""" ; . tosh:DependentEnumSelectEditor a dash:SingleEditor ; rdfs:comment """A drop-down editor for enumerated values that are dynamically determined via a node shape that has sh:target dash:HasValueTarget. Example: states:USAddressShape rdf:type sh:NodeShape ; rdfs:label \"US Address shape\" ; sh:property [ rdf:type sh:PropertyShape ; sh:path states:state ; sh:in ( \"AZ\" \"CA\" \"FL\" ) ; ] ; sh:target [ rdf:type dash:HasValueTarget ; dash:object \"USA\" ; dash:predicate states:country ; ] . """ ; rdfs:label "Dependent enum select editor" ; . tosh:DisplayPropertyGroup a sh:PropertyGroup ; rdfs:label "Display" ; sh:order "30"^^xsd:decimal ; . tosh:Function-apiStatus a sh:PropertyShape ; sh:path dash:apiStatus ; sh:class dash:APIStatus ; sh:description "Declares the status of this function within the TopBraid API. The usual life cycle is to start with no value (meaning: not part of the API at all), then experimental from which it later either moves to stable or deprecated. Stable functions may also get deprecated and have no api status after at least one release cycle." ; sh:group tosh:DefinitionPropertyGroup ; sh:in ( dash:Experimental dash:Stable dash:Deprecated ) ; sh:maxCount 1 ; sh:name "API status" ; sh:order "15"^^xsd:decimal ; . tosh:Function-cachable a sh:PropertyShape ; sh:path dash:cachable ; sh:datatype xsd:boolean ; sh:description "True to indicate that this function will always return the same values for the same combination of arguments, regardless of the query graphs. Engines can use this information to cache and reuse previous function calls." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "cachable" ; sh:order "10"^^xsd:decimal ; . tosh:Function-returnType a sh:PropertyShape ; sh:path sh:returnType ; sh:class rdfs:Class ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "return type" ; sh:order "5"^^xsd:decimal ; . tosh:FunctionTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of a function call." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:order "10"^^xsd:decimal ; . tosh:FunctionTestCase-expression a sh:PropertyShape ; sh:path dash:expression ; sh:description "A valid SPARQL expression calling the function to test." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "expression" ; sh:order "0"^^xsd:decimal ; . tosh:GovernanceRoleSelectEditor a dash:SingleEditor ; rdfs:label "Governance role editor" ; . tosh:GovernanceRoleViewer a dash:SingleViewer ; rdfs:label "Governance role viewer" ; . tosh:GraphStoreTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:datatype xsd:string ; sh:description "The expected RDF graph, as a Turtle string." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:order "10"^^xsd:decimal ; . tosh:GraphStoreTestCase-uri a sh:PropertyShape ; sh:path dash:uri ; sh:datatype xsd:anyURI ; sh:description "The URI of the graph to load." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "uri" ; sh:order "0"^^xsd:decimal ; . tosh:ImplementationPropertyGroup a sh:PropertyGroup ; rdfs:label "Implementation" ; sh:order "10"^^xsd:decimal ; . tosh:IncludedScript-exports a sh:PropertyShape ; sh:path dash:exports ; sh:datatype xsd:string ; sh:description "Declares the symbols that shall be exported from the surrounding module, e.g. for use in Node.js applications." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "exports" ; sh:order "30"^^xsd:decimal ; . tosh:InferenceRulesShape a sh:NodeShape ; rdfs:comment "A node shape for classes and node shapes, declaring the sh:rule property." ; rdfs:label "Inference rules" ; sh:property tosh:InferenceRulesShape-rule ; sh:targetClass sh:NodeShape ; . tosh:InferenceRulesShape-rule a sh:PropertyShape ; sh:path sh:rule ; sh:class sh:Rule ; sh:description "The inference rules associated with this node shape or class." ; sh:group tosh:InferencesPropertyGroup ; sh:name "rule" ; . tosh:InferencesPropertyGroup a sh:PropertyGroup ; rdfs:label "Inferences" ; sh:order "80"^^xsd:decimal ; . tosh:InferencingTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected inferred triples, represented by instances of rdfs:Statement." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:name "expected result" ; sh:order "10"^^xsd:decimal ; . tosh:InstancesInGraphSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of a class (based on tosh:shapeInGraph/sh:class of the property) in a graph specified using tosh:graph." ; rdfs:label "Instances in graph select editor" ; . tosh:JSTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of the JavaScript function call, as an RDF node." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; . tosh:MemberShapeConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Can be used to specify constraints on the members of a given list, assuming that the given sh:property has rdf:Lists as values. A violation is reported for each member of the list that does not comply with the constraints specified by the given shape." ; rdfs:label "Member shape constraint component" ; sh:parameter tosh:MemberShapeConstraintComponent-memberShape ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "List member does not have the shape {$memberShape}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure ?member WHERE { $this $PATH ?value . ?value rdf:rest*/rdf:first ?member . BIND (tosh:hasShape(?member, $memberShape) AS ?hasShape) . BIND (!bound(?hasShape) AS ?failure) . FILTER (?failure || !?hasShape) . } """ ; ] ; sh:targetClass sh:PropertyShape ; . tosh:MemberShapeConstraintComponent-memberShape a sh:Parameter ; sh:path tosh:memberShape ; sh:class sh:Shape ; sh:description "The shape that the list members must have." ; sh:name "member shape" ; . tosh:ModifyAction-skipPreview a sh:PropertyShape ; sh:path dash:skipPreview ; sh:datatype xsd:boolean ; sh:description "For actions that take no parameters, this can be set to true to skip any means for the user to preview the action. It will instead directly execute the modification." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "skip preview" ; sh:order "11"^^xsd:decimal ; . tosh:MultiFunction-resultVariable a sh:PropertyShape ; sh:path dash:resultVariable ; sh:class sh:Parameter ; sh:description "The result variables." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "result variables" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "30"^^xsd:decimal ; . tosh:NodeShape-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of rdfs_Class, assuming this node shape is also a class. * @returns {rdfs_Class} */ asClass() { return rdfs.asClass(this); } /** * Gets the \"nearest\" constraint of a given type and a given path property. Deactivated shapes are skipped. * For example, call it with (ex.myProperty, sh.datatype) to find the closest sh:datatype constraint for ex:myProperty. * @param {NamedNode} path the property that is the sh:path of matching property shapes * @param {NamedNode} predicate the property to fetch the nearest value of */ nearestPropertyShapeValue(path, predicate) { return this.walkSupershapes(s => { if(!s.deactivated) { let ps = s.properties; for(let i = 0; i < ps.length; i++) { if(!ps[i].deactivated && graph.contains(ps[i], sh.path, path)) { let value = ps[i].value(predicate); if(value !== null && value !== undefined) { return value; } } } } }) } /** * @callback sh_NodeShape_callback * @param {sh_NodeShape} nodeShape the visited node shape */ /** * Performs a depth-first traversal of this and its superclasses (via rdfs:subClassOf) and supershapes (via sh:node), * visiting each (super) shape once until the callback function returns a non-null/undefined result. This becomes the result of this function. * The order in which sibling parents are traversed is undefined. * @param {sh_NodeShape_callback} callback the callback for each shape * @param {Set} [reached] the Set of reached URI strings, used internally but may also be used to terminate at certain supers * @returns the return value of the first callback that returned any value */ walkSupershapes(callback, reached) { if(!reached) { reached = new Set(); } if(!reached.has(this.uri)) { reached.add(this.uri); let result = callback(this); if(result !== undefined && result !== null) { return result; } let superClasses = this.asClass().superclasses; for(let i = 0; i < superClasses.length; i++) { result = superClasses[i].asNodeShape().walkSupershapes(callback, reached); if(result !== undefined && result !== null) { return result; } } let superShapes = this.supershapes; for(let i = 0; i < superShapes.length; i++) { result = superShapes[i].walkSupershapes(callback, reached); if(result !== undefined && result !== null) { return result; } } } } """ ; . tosh:NodeShape-applicableToClass a sh:PropertyShape ; sh:path dash:applicableToClass ; sh:class rdfs:Class ; sh:description "Links a node shape with the classes that it can be applied to." ; sh:group tosh:TargetsPropertyGroup ; sh:name "applicable to classes" ; sh:nodeKind sh:IRI ; sh:order "10"^^xsd:decimal ; . tosh:NodeShape-defaultViewForRole a sh:PropertyShape ; sh:path dash:defaultViewForRole ; dash:editor tosh:GovernanceRoleSelectEditor ; dash:viewer tosh:GovernanceRoleViewer ; sh:description "The user roles that this shape shall be used as default view for." ; sh:group tosh:TargetsPropertyGroup ; sh:name "default view for roles" ; sh:nodeKind sh:IRI ; sh:order "20"^^xsd:decimal ; . tosh:NodeShape-inheritedProperty a sh:PropertyShape ; sh:path tosh:inheritedProperty ; dash:neverMaterialize true ; dash:viewer tosh:PropertyTableViewer ; sh:description "Returns all property shapes that have been declared at \"super-shapes\" (via sh:node) or \"superclasses\" (via rdfs:subClassOf), including the indirect supers, recursively." ; sh:group tosh:PropertiesPropertyGroup ; sh:name "inherited properties" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "1"^^xsd:decimal ; sh:values [ sh:path sh:property ; sh:nodes [ sh:minus sh:this ; sh:nodes [ sh:distinct [ sh:path [ sh:oneOrMorePath [ sh:alternativePath ( rdfs:subClassOf sh:node ) ; ] ; ] ; ] ; ] ; ] ; ] ; . tosh:NodeShape-node a sh:PropertyShape ; sh:path sh:node ; graphql:name "supershapes" ; sh:description "The node shapes that this must also conform to, forming a kind of inheritance between shapes similar to a subclass-of relationship." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "node (super shapes)" ; sh:node sh:NodeShape ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "20"^^xsd:decimal ; . tosh:NodeShape-targetClass a sh:PropertyShape ; sh:path sh:targetClass ; graphql:name "targetClasses" ; sh:class rdfs:Class ; sh:description "The types of instances that this shape is targeted at." ; sh:group tosh:TargetsPropertyGroup ; sh:name "target classes" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:NodeShape-targetObjectsOf a sh:PropertyShape ; sh:path sh:targetObjectsOf ; sh:group tosh:TargetsPropertyGroup ; sh:name "target objects of" ; sh:node rdf:Property ; sh:nodeKind sh:IRI ; sh:order "1"^^xsd:decimal ; . tosh:NodeShape-targetSubjectsOf a sh:PropertyShape ; sh:path sh:targetSubjectsOf ; sh:group tosh:TargetsPropertyGroup ; sh:name "target subjects of" ; sh:node rdf:Property ; sh:nodeKind sh:IRI ; sh:order "2"^^xsd:decimal ; . tosh:NodeShapeConstraintsShape a sh:NodeShape ; rdfs:comment "A shape that can be used to validate the syntax of node shapes, and to enter constraints for node shapes on forms." ; rdfs:label "Node shape constraints" ; sh:property dash:ClosedByTypesConstraintComponent-closedByTypes ; sh:property dash:ScriptConstraintComponent-scriptConstraint ; sh:property dash:SingleLineConstraintComponent-singleLine ; sh:property dash:StemConstraintComponent-stem ; sh:property tosh:Shape-datatypes ; sh:property sh:ClassConstraintComponent-class ; sh:property sh:ClosedConstraintComponent-closed ; sh:property sh:ClosedConstraintComponent-ignoredProperties ; sh:property sh:DatatypeConstraintComponent-datatype ; sh:property sh:HasValueConstraintComponent-hasValue ; sh:property sh:InConstraintComponent-in ; sh:property sh:LanguageInConstraintComponent-languageIn ; sh:property sh:MaxExclusiveConstraintComponent-maxExclusive ; sh:property sh:MaxInclusiveConstraintComponent-maxInclusive ; sh:property sh:MaxLengthConstraintComponent-maxLength ; sh:property sh:MinExclusiveConstraintComponent-minExclusive ; sh:property sh:MinInclusiveConstraintComponent-minInclusive ; sh:property sh:MinLengthConstraintComponent-minLength ; sh:property sh:NodeKindConstraintComponent-nodeKind ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; sh:property sh:SPARQLConstraintComponent-sparql ; sh:targetClass sh:NodeShape ; . tosh:NumberOfValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Number of Values" ; sh:order "40"^^xsd:decimal ; . tosh:OWLAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "OWL Axioms" ; sh:order "17"^^xsd:decimal ; . tosh:ObjectPropertyShapeView a sh:NodeShape ; rdfs:comment "The default view shape for property shapes on object values." ; rdfs:label "Relationship view" ; sh:node tosh:PropertyShapeView ; sh:property dash:NonRecursiveConstraintComponent-nonRecursive ; sh:property dash:RootClassConstraintComponent-rootClass ; sh:property dash:StemConstraintComponent-stem ; sh:property dash:SymmetricConstraintComponent-symmetric ; sh:property tosh:ObjectPropertyShapeView-node ; sh:property sh:ClassConstraintComponent-class ; sh:property sh:NodeKindConstraintComponent-nodeKind ; . tosh:ObjectPropertyShapeView-node a sh:PropertyShape ; sh:path sh:node ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class sh:NodeShape ; sh:description "The node shape(s) that all values of the property must conform to." ; sh:group tosh:ValueConstraintsPropertyGroup ; sh:name "node" ; sh:order "0"^^xsd:decimal ; . tosh:Ontology-imports a sh:PropertyShape ; sh:path owl:imports ; sh:description "The (directly) imported graphs." ; sh:name "imports" ; sh:nodeKind sh:IRI ; . tosh:Parameterizable-labelTemplate a sh:PropertyShape ; sh:path sh:labelTemplate ; sh:description "Outlines how human-readable labels of instances of the associated Parameterizable shall be produced. The values can contain {?paramName} as placeholders for the actual values of the given parameter." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "label template" ; sh:or dash:StringOrLangString ; sh:order "25"^^xsd:decimal ; . tosh:Parameterizable-parameter a sh:PropertyShape ; sh:path sh:parameter ; sh:class sh:Parameter ; sh:description "The input parameters." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "parameters" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "20"^^xsd:decimal ; . tosh:PathStringViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Path string viewer" ; . tosh:PropertiesPropertyGroup a sh:PropertyGroup ; rdfs:comment "The declared and inferred properties of a shape or class." ; rdfs:label "Properties" ; sh:order "10"^^xsd:decimal ; . tosh:Property-domain a sh:PropertyShape ; sh:path rdfs:domain ; graphql:name "domains" ; sh:description "The domain(s) of this property." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "0"^^xsd:decimal ; . tosh:Property-range a sh:PropertyShape ; sh:path rdfs:range ; graphql:name "ranges" ; sh:description "The range(s) of this property." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "1"^^xsd:decimal ; . tosh:Property-subPropertyOf a sh:PropertyShape ; sh:path rdfs:subPropertyOf ; graphql:name "superproperties" ; sh:class rdf:Property ; sh:description "The (direct) superproperties of this." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:name "superproperties" ; sh:nodeKind sh:IRI ; sh:order "2"^^xsd:decimal ; . tosh:Property-subPropertyOf-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:subPropertyOf ; ] ; graphql:name "subproperties" ; sh:class rdf:Property ; sh:description "The (direct) subproperties of this." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:name "subproperties" ; sh:nodeKind sh:IRI ; sh:order "3"^^xsd:decimal ; . tosh:PropertyAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "Property Axioms" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyGroup-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this group compared to others." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "0"^^xsd:decimal ; . tosh:PropertyPairConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "Property Pair Constraints" ; sh:order "75"^^xsd:decimal ; . tosh:PropertyShape-defaultValue a sh:PropertyShape ; sh:path sh:defaultValue ; dash:readOnly true ; dash:viewer dash:NodeExpressionViewer ; tosh:useDeclaredDatatype true ; sh:description "The default value to be used for this property if no other value has been asserted. This may be a constant value or a SHACL node expression, in which case the values can be derived from other values. Default values are typically inferred and not stored as RDF statements." ; sh:group tosh:InferencesPropertyGroup ; sh:name "default value" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-description a sh:PropertyShape ; sh:path sh:description ; dash:singleLine false ; graphql:name "descriptions" ; sh:description "The description(s) of the property, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "descriptions" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangStringOrHTML ; sh:order "1"^^xsd:decimal ; sh:sparql [ sh:message "Property shapes cannot have both class and datatype constraints." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER EXISTS { $this sh:class ?class . $this sh:datatype ?datatype . } }""" ; ] ; . tosh:PropertyShape-detailsEndpoint a sh:PropertyShape ; sh:path dash:detailsEndpoint ; sh:datatype xsd:string ; sh:maxCount 1 ; sh:name "details endpoint" ; . tosh:PropertyShape-editor a sh:PropertyShape ; sh:path dash:editor ; dash:editor dash:InstancesSelectEditor ; sh:class dash:Editor ; sh:description "The editor component that should be used to edit values of this property." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:nodeKind sh:IRI ; sh:order "11"^^xsd:decimal ; . tosh:PropertyShape-group a sh:PropertyShape ; sh:path sh:group ; sh:class sh:PropertyGroup ; sh:description "The group that this property belongs to." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "group" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-hidden rdfs:isDefinedBy sh: ; rdfs:label "distinct"@en ; . sh:else a rdf:Property ; rdfs:comment "Links an sh:if node expression with the values that shall be returned if the condition is false."@en ; rdfs:isDefinedBy sh: ; rdfs:label "else"@en ; . sh:exists a rdf:Property ; rdfs:comment "Resources with values for sh:exists are node expressions that produce true if the associated node expression has any values, and false otherwise."@en ; rdfs:isDefinedBy sh: ; rdfs:label "exists"@en ; . sh:groupConcat a rdf:Property ; rdfs:comment "Resources with values for sh:groupConcat are node expressions that produce an xsd:string consisting of the concatenation of all values of the associated node expression, possibly separated by the value of sh:separator."@en ; rdfs:isDefinedBy sh: ; rdfs:label "group concat"@en ; . sh:if a rdf:Property ; rdfs:comment "Resources with values for sh:if are node expressions that produce either the results of sh:then or sh:else depending on whether the associated node expression produces the list [ true ]."@en ; rdfs:isDefinedBy sh: ; rdfs:label "if"@en ; . sh:limit a rdf:Property ; rdfs:comment "Resources with values N for sh:limit are node expressions that produce only the first N values of the associated node expression sh:nodes."@en ; sh:datatype xsd:boolean ; sh:description "True to indicate that the values of this shall be indexed, forming ordered arrays." ; sh:maxCount 1 ; sh:name "indexed" ; . tosh:PropertyShape-name a sh:PropertyShape ; sh:path sh:name ; dash:singleLine true ; graphql:name "names" ; sh:description "The display names of the property, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "names" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangString ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-neverMaterialize a sh:PropertyShape ; sh:path dash:neverMaterialize ; sh:datatype xsd:boolean ; sh:group tosh:InferencesPropertyGroup ; sh:maxCount 1 ; sh:name "never materialize" ; sh:order "11"^^xsd:decimal ; . tosh:PropertyShape-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this property shape compared to others." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShape-path rdfs:isDefinedBy sh: ; rdfs:label "sum"@en ; . sh:then a rdf:Property ; rdfs:comment "Links an sh:if node expression with the values that shall be returned if the condition is true."@en ; rdfs:isDefinedBy sh: ; rdfs:label "then"@en ; . sh:values a rdf:Property ; rdfs:comment "Links a property shape with one or more SHACL node expressions that are used to determine the values of the associated predicate based on the current focus node. Only valid for property shapes where the sh:path is an IRI."@en ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "31"^^xsd:decimal ; . tosh:PropertyShape-propertyRole a sh:PropertyShape ; sh:path dash:propertyRole ; sh:class dash:PropertyRole ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "role" ; sh:order "40"^^xsd:decimal ; . tosh:PropertyShape-readOnly a sh:PropertyShape ; sh:path dash:readOnly ; dash:editor dash:BooleanSelectEditor ; dash:viewer dash:NodeExpressionViewer ; sh:datatype xsd:boolean ; sh:description """If set to true then the values of this property should not be editable in the user interface. Note that low-level access such as source code editors may still allow editing, but form-based editors would not. More generally, the values of this property are SHACL node expressions, e.g. function calls, in which case the property counts as read-only if the expression evaluates to true.""" ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:order "20"^^xsd:decimal ; . tosh:PropertyShape-values a sh:PropertyShape ; sh:path sh:values ; dash:viewer dash:NodeExpressionViewer ; sh:group tosh:InferencesPropertyGroup ; sh:name "values" ; sh:order "10"^^xsd:decimal ; sh:sparql [ sh:message "sh:values must be accompanied by a sh:path that is an IRI." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this ?value WHERE { $this $PATH ?value . FILTER NOT EXISTS { $this sh:path ?path . FILTER isIRI(?path) } }""" ; ] ; . tosh:PropertyShape-viewer a sh:PropertyShape ; sh:path dash:viewer ; dash:editor dash:InstancesSelectEditor ; sh:class dash:Viewer ; sh:description "The viewer component that should be used to render values of this property." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:nodeKind sh:IRI ; sh:order "10"^^xsd:decimal ; . tosh:PropertyShapeView a sh:NodeShape ; rdfs:comment "Base view shape for either datatype or object property shapes." ; rdfs:label "Property shape view" ; sh:property dash:CoExistsWithConstraintComponent-coExistsWith ; sh:property dash:IndexedConstraintComponent-indexed ; sh:property dash:ReifiableByConstraintComponent-reifiableBy ; sh:property dash:ScriptConstraintComponent-scriptConstraint ; sh:property dash:SubSetOfConstraintComponent-subSetOf ; sh:property tosh:PropertyShape-defaultValue ; sh:property tosh:PropertyShape-description ; sh:property tosh:PropertyShape-editor ; sh:property tosh:PropertyShape-group ; sh:property tosh:PropertyShape-hidden ; sh:property tosh:PropertyShape-name ; sh:property tosh:PropertyShape-neverMaterialize ; sh:property tosh:PropertyShape-order ; sh:property tosh:PropertyShape-propertyRole ; sh:property tosh:PropertyShape-readOnly ; sh:property tosh:PropertyShape-values ; sh:property tosh:PropertyShape-viewer ; sh:property tosh:PropertyShapeView-message ; sh:property tosh:PropertyShapeView-pathSystemLabel ; sh:property tosh:PropertyShapeView-qualifiedMaxCount ; sh:property tosh:PropertyShapeView-qualifiedMinCount ; sh:property tosh:PropertyShapeView-qualifiedValueShape ; sh:property tosh:PropertyShapeView-qualifiedValueShapesDisjoint ; sh:property tosh:Shape-deactivated ; sh:property tosh:Shape-severity ; sh:property sh:DisjointConstraintComponent-disjoint ; sh:property sh:EqualsConstraintComponent-equals ; sh:property sh:MaxCountConstraintComponent-maxCount ; sh:property sh:MinCountConstraintComponent-minCount ; sh:property sh:SPARQLConstraintComponent-sparql ; . tosh:PropertyShapeView-indexed a sh:PropertyShape ; sh:path dash:indexed ; sh:datatype xsd:boolean ; sh:description "Indicates whether the values are sorted by an index. The user interface will display them in-order." ; sh:group tosh:ReificationPropertyGroup ; sh:maxCount 1 ; sh:name "indexed" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShapeView-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message that shall be generated for all constraint violations produced by this property shape." ; sh:group tosh:ValidationPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "5"^^xsd:decimal ; . tosh:PropertyShapeView-pathSystemLabel a sh:PropertyShape ; sh:path tosh:pathSystemLabel ; dash:neverMaterialize true ; dash:viewer tosh:PathStringViewer ; sh:datatype xsd:string ; sh:description "A display label of the sh:path based on qnames." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "property path" ; sh:order "2"^^xsd:decimal ; sh:values [ sh:else [ <http://uispin.org/ui#label> ( [ sh:path sh:path ; ] ) ; ] ; sh:if [ <http://datashapes.org/sparql#isIRI> ( [ sh:path sh:path ; ] ) ; ] ; sh:then [ <http://topbraid.org/sparqlmotionfunctions#qname> ( [ sh:path sh:path ; ] ) ; ] ; ] ; . tosh:PropertyShapeView-qualifiedMaxCount a sh:PropertyShape ; sh:path sh:qualifiedMaxCount ; sh:datatype xsd:integer ; sh:description "The maximum number of values that may conform to the qualified value shape." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified max count" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedMinCount a sh:PropertyShape ; sh:path sh:qualifiedMinCount ; sh:datatype xsd:integer ; sh:description "The minimum number of values that must conform to the qualified value shape." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified min count" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedValueShape a sh:PropertyShape ; sh:path sh:qualifiedValueShape ; sh:class sh:NodeShape ; sh:description "The shape that the specified number of values must conform to." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:name "qualified value shape" ; sh:order "2"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedValueShapesDisjoint a sh:PropertyShape ; sh:path sh:qualifiedValueShapesDisjoint ; sh:datatype xsd:boolean ; sh:description "True to treat all qualified values as disjoint." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified value shapes disjoint" ; sh:order "3"^^xsd:decimal ; . tosh:PropertyTableViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Property table viewer" ; . tosh:QualifiedCardinalityConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:comment "The properties in this group are used together to express that a certain number of values must conform to a given shape." ; rdfs:label "Qualified Cardinality Constraints" ; sh:order "77"^^xsd:decimal ; . tosh:QueryTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; dash:singleLine false ; sh:description "The expected result set, as a JSON string." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:or ( [ sh:datatype rdf:JSON ; ] [ sh:datatype xsd:string ; ] ) ; . tosh:RDFSOWLClassView a sh:NodeShape ; dash:applicableToClass rdfs:Class ; rdfs:comment "A node shape collecting RDFS and OWL axioms for classes." ; rdfs:label "RDFS/OWL class view" ; sh:property tosh:Class-disjointWith ; sh:property tosh:Class-domain-inverse ; sh:property tosh:Class-equivalentClass ; sh:property tosh:Class-range-inverse ; sh:property tosh:Class-subClassOf ; sh:property tosh:Class-subClassOf-inverse ; sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; sh:property tosh:Resource-type ; . tosh:RDFSPropertyAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "RDFS Property Axioms" ; sh:order "15"^^xsd:decimal ; . tosh:ReferencesPropertyGroup a sh:PropertyGroup ; rdfs:comment "A property group typically used for incoming references or usages."^^rdf:HTML ; rdfs:label "References" ; sh:order "100"^^xsd:decimal ; . tosh:ReificationPropertyGroup a sh:PropertyGroup ; rdfs:label "Reification (Statements about Statements)" ; sh:order "90"^^xsd:decimal ; . tosh:ReplaceWithDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to replace all values of the given predicate (which must exist) at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; rdfs:label "Replace with default value suggestion generator" ; sh:message "Replace with default value" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?defaultValue WHERE { GRAPH $shapesGraph { $sourceShape sh:defaultValue ?defaultValue . } }""" ; sh:update """DELETE { $focusNode $predicate ?oldValue . } INSERT { $focusNode $predicate ?defaultValue . } WHERE { $focusNode $predicate ?oldValue . }""" ; . tosh:Resource-comment a sh:PropertyShape ; sh:path rdfs:comment ; dash:propertyRole dash:DescriptionRole ; dash:singleLine false ; graphql:name "comments" ; sh:description "The comments of this, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "comments" ; sh:or dash:StringOrLangStringOrHTML ; sh:order "1"^^xsd:decimal ; . tosh:Resource-label a sh:PropertyShape ; sh:path rdfs:label ; dash:propertyRole dash:LabelRole ; graphql:name "labels" ; sh:description "The display name(s) of this, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "labels" ; sh:or dash:StringOrLangString ; sh:order "0"^^xsd:decimal ; . tosh:Resource-type a sh:PropertyShape ; sh:path rdf:type ; graphql:name "types" ; sh:class rdfs:Class ; sh:description "The type(s) of this." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "types" ; sh:order "10"^^xsd:decimal ; . tosh:ResourceAction-jsCondition a sh:PropertyShape ; sh:path dash:jsCondition ; sh:datatype xsd:string ; sh:description "An (ADS) JavaScript expression that will be executed to determine whether the action is applicable to the selected resource in the current context. The variable focusNode can be queried here. The expression needs to return true for the action to be deemed suitable." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "action pre-condition" ; sh:order "25"^^xsd:decimal ; . tosh:ResourceView a sh:NodeShape ; rdfs:comment "A generic view shape that can be used as fallback to display typical resources that have an rdfs:label and an rdfs:comment." ; rdfs:label "Resource view" ; sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; . tosh:Rule-condition a sh:PropertyShape ; sh:path sh:condition ; sh:description "The pre-conditions that must apply before a rule gets executed. The focus node must conform to all conditions, which must be shapes." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "conditions" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "40"^^xsd:decimal ; . tosh:Rule-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate the rule so that it will not get executed." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Rule-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The order of this rule relative to other rules at the same shape. Rules with lower order are executed first. Default value is 0. Rules with the same order cannot \"see\" each other's inferences." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "35"^^xsd:decimal ; . tosh:Rule-rule-inverse a sh:PropertyShape ; sh:path [ sh:inversePath sh:rule ; ] ; sh:class sh:Shape ; sh:description "The shapes or classes that the rule is attached to." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "rule of" ; sh:order "20"^^xsd:decimal ; . tosh:SHMinMaxEditor a dash:SingleEditor ; dash:hidden true ; rdfs:comment "An internally used editor for min/max range values of property shapes."^^rdf:HTML ; rdfs:label "SHACL Min Max Editor" ; . tosh:SPARQLAskExecutable-ask a sh:PropertyShape ; sh:path sh:ask ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL ASK query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "ask" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLConstraint-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactive this constraint." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:SPARQLConstraint-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message(s) that should be produced for constraint violations. The messages may contain placeholders such as {$value} for any variable returned in the SELECT clause of the SPARQL query." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "20"^^xsd:decimal ; . tosh:SPARQLConstructExecutable-construct a sh:PropertyShape ; sh:path sh:construct ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL CONSTRUCT query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "construct" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLExecutable-prefixes a sh:PropertyShape ; sh:path sh:prefixes ; sh:class owl:Ontology ; sh:description "The Ontology declaring the SHACL prefix declarations to use for the SPARQL query." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "prefixes" ; sh:order "0"^^xsd:decimal ; . tosh:SPARQLSelectExecutable-select a sh:PropertyShape ; sh:path sh:select ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL SELECT query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "select" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLUpdateExecutable-update a sh:PropertyShape ; sh:path sh:update ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL UPDATE request string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "update" ; sh:order "1"^^xsd:decimal ; . tosh:Script-js a sh:PropertyShape ; sh:path dash:js ; sh:datatype xsd:string ; sh:description "The implementation as JavaScript." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "JavaScript code" ; sh:order "20"^^xsd:decimal ; . tosh:Script-onAllValues a sh:PropertyShape ; sh:path dash:onAllValues ; sh:datatype xsd:boolean ; sh:description "If true then all value nodes will be available to the script at once, through the variable \"values\"." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "on all values" ; sh:order "0"^^xsd:decimal ; . tosh:ScriptConstraint-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this constraint." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:ScriptConstraint-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message(s) to use for violations produced by this script." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "20"^^xsd:decimal ; . tosh:ScriptFunction-canWrite a sh:PropertyShape ; sh:path dash:canWrite ; sh:datatype xsd:boolean ; sh:description "True to allow this function to have side effects. By default, functions are not permitted to modify the graph as this would violate SPARQL contracts. However, if canWrite is true then the function will not be available as a SPARQL function and only be injected into the generated API in read/write mode." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "can write" ; sh:order "15"^^xsd:decimal ; . tosh:ScriptTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of the evaluation, as JSON object as produced by the servlet, or true or false." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:or ( [ sh:datatype rdf:JSON ; ] [ sh:datatype xsd:boolean ; ] ) ; sh:order "0"^^xsd:decimal ; . tosh:ScriptTestCase-focusNode a sh:PropertyShape ; sh:path dash:focusNode ; sh:description "The selected resource, which will become value of focusNode for the script, with its \"most suitable\" JavaScript class as type. Defaults to the test case itself." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "focus node" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "10"^^xsd:decimal ; . tosh:ScriptsPropertyGroup a sh:PropertyGroup ; rdfs:comment "Scripts based on Active Data Shapes." ; rdfs:label "Scripts" ; sh:order "30"^^xsd:decimal ; . tosh:Service-canWrite a sh:PropertyShape ; sh:path dash:canWrite ; sh:datatype xsd:boolean ; sh:description "True if this service can modify the data, i.e. it will execute in read/write mode. By default, all services are read-only." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "can write" ; . tosh:Service-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this service." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Service-responseContentType a sh:PropertyShape ; sh:path dash:responseContentType ; sh:datatype xsd:string ; sh:description "The content type (mime type) of the service response, defaulting to \"application/json\". Use \"void\" to return nothing." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "response content type" ; sh:order "10"^^xsd:decimal ; . tosh:SetToDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to set the given predicate at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; rdfs:label "Set to default value suggestion generator" ; sh:message "Set to default value" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?defaultValue WHERE { GRAPH $shapesGraph { $sourceShape sh:defaultValue ?defaultValue . } }""" ; sh:update """DELETE { $focusNode $predicate ?oldValue . } INSERT { $focusNode $predicate ?defaultValue . } WHERE { OPTIONAL { $focusNode $predicate ?oldValue . } }""" ; . tosh:Shape-datatypes a sh:PropertyShape ; sh:path tosh:datatypes ; dash:neverMaterialize true ; dash:viewer tosh:DatatypesViewer ; sh:description "Zero of more datatypes that value nodes can take. In SHACL, the typical pattern is to either use a single sh:datatype or a sh:or of multiple sh:datatype constraints. This inferred property here provides a unified way to access these two design patterns." ; sh:group tosh:TypeOfValuesPropertyGroup ; sh:name "datatypes" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; sh:values [ sh:union ( [ sh:path sh:datatype ; ] [ sh:path ( sh:or [ sh:zeroOrMorePath rdf:rest ; ] rdf:first sh:datatype ) ; ] ) ; ] ; . tosh:Shape-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this shape, making it literally invisible and without any effect." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Shape-severity a sh:PropertyShape ; sh:path sh:severity ; dash:editor dash:InstancesSelectEditor ; sh:class sh:Severity ; sh:description "The severity to be used for validation results produced by the constraints." ; sh:group tosh:ValidationPropertyGroup ; sh:maxCount 1 ; sh:name "severity" ; sh:order "0"^^xsd:decimal ; . tosh:ShapeInGraphConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment """A constraint component that can be used to verify that the value nodes have a given shape, where the shape validation is executed in a given graph. This can, for example, be used to verify that a given value is declared as an instance of a given class in some specified (not imported) graph. A typical design pattern is as follows: ex:NodeShape sh:property [ sh:path ex:myProperty ; sh:nodeKind sh:IRI ; tosh:graph <http://example.org/externalGraph> ; tosh:shapeInGraph [ sh:class ex:ExternalClass ; ] ; tosh:editor tosh:InstancesInGraphSelectEditor ; tosh:viewer tosh:URIInGraphViewer ; ] .""" ; rdfs:label "Shape in graph constraint component" ; sh:labelTemplate "Values must have shape {$shapeInGraph} defined in graph {$graph}" ; sh:message "Value does not have shape {$shapeInGraph} defined in graph {$graph}" ; sh:parameter [ a sh:Parameter ; sh:path tosh:graph ; sh:nodeKind sh:IRI ; ] ; sh:parameter [ a sh:Parameter ; sh:path tosh:shapeInGraph ; sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { GRAPH $graph { FILTER tosh:hasShape($value, $shapeInGraph) } }""" ; sh:prefixes <http://topbraid.org/tosh> ; ] ; . tosh:StringConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "String Constraints" ; sh:order "70"^^xsd:decimal ; . tosh:SystemNamespaceShape a sh:NodeShape ; rdfs:comment "A shape that detects whether the focus node is a URI that has a namespace from one of the system namespaces - RDF, RDFS, OWL etc. The list of actual system namespaces is represented via tosh:systemNamespace true triples." ; rdfs:label "System namespace shape" ; sh:sparql [ a sh:SPARQLConstraint ; sh:message "Not a IRI from a system namespace" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER (!isIRI($this) || (isIRI($this) && EXISTS { BIND (IRI(afn:namespace($this)) AS ?ns) . FILTER NOT EXISTS { ?ns tosh:systemNamespace true } . } )) . }""" ; ] ; . tosh:TargetsPropertyGroup a sh:PropertyGroup ; rdfs:label "Targets" ; sh:order "5"^^xsd:decimal ; . tosh:TeamworkPlatform a dash:ExecutionPlatform ; dash:includedExecutionPlatform tosh:TopBraidPlatform ; rdfs:comment "The platform consisting of TopBraid plus any teamwork features used by TopBraid EDG." ; rdfs:label "Teamwork platform" ; . tosh:TestCase-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "If set to true, this test case will be skipped." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "50"^^xsd:decimal ; . tosh:TestPropertiesPropertyGroup a sh:PropertyGroup ; rdfs:label "Test Properties" ; sh:order "20"^^xsd:decimal ; . tosh:TopBraidPlatform a dash:ExecutionPlatform ; rdfs:comment "The platform consisting of TopBraid." ; rdfs:label "TopBraid platform" ; . tosh:TripleRule-object a sh:PropertyShape ; sh:path sh:object ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the object(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "object" ; sh:order 2 ; . tosh:TripleRule-predicate a sh:PropertyShape ; sh:path sh:predicate ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the predicate(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "predicate" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order 1 ; . tosh:TripleRule-subject a sh:PropertyShape ; sh:path sh:subject ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the subject(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "subject" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order 0 ; . tosh:TypeOfValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Type of Values" ; sh:order "50"^^xsd:decimal ; . tosh:URIInGraphViewer a dash:SingleViewer ; rdfs:comment "A viewer for URI resources that have their data in a given graph that may be outside of the imports closure. The graph must be specified using a tosh:graph constraint for the property." ; rdfs:label "URI in graph viewer" ; . tosh:UseDeclaredDatatypeConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator [ a dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change datatype of the invalid value to the specified sh:datatype" ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """DELETE { $subject $predicate $object . } INSERT { $subject $predicate ?newObject . } WHERE { $subject sh:datatype ?datatype . BIND (spif:cast(?object, ?datatype) AS ?newObject) . }""" ; ] ; rdfs:comment "Constrains the value nodes to be either non-literals or literals that have the same datatype as the declared sh:datatype for the given constraint node. This is used, among others, in properties such as sh:hasValue and sh:minExclusive." ; rdfs:label | 8 | #69: work-around to suppress SLF4J warning; also other recent minor changes synchronized with TopBraid code base | 91 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
233 | <NME> tosh.ttl <BEF> # baseURI: http://topbraid.org/tosh # imports: http://datashapes.org/dash # prefix: tosh @prefix dash: <http://datashapes.org/dash#> . @prefix graphql: <http://datashapes.org/graphql#> . @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 swa: <http://topbraid.org/swa#> . @prefix tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . dash: tosh:systemNamespace true ; . dash:Action sh:property tosh:Action-actionGroup ; sh:property tosh:Action-actionIconClass ; sh:property tosh:Action-deactivated ; . dash:ActionGroup sh:property tosh:ActionGroup-order ; sh:property tosh:Resource-comment ; . dash:NonRecursiveConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:NonRecursiveConstraintComponent-nonRecursive sh:group tosh:RelationshipPropertyGroup ; . dash:PrimaryKeyConstraintComponent-uriStart tosh:editWidget swa:PlainTextFieldEditor ; sh:group tosh:PrimaryKeyPropertyGroup ; . dash:RootClassConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; sh:group tosh:ValidationPropertyGroup ; . dash:CoExistsWithConstraintComponent-coExistsWith sh:group tosh:PropertyPairConstraintsPropertyGroup ; sh:order "0"^^xsd:decimal ; . dash:DetailsEditor dash:hidden true ; owl:versionInfo "This is not yet supported by TopBraid." ; . dash:FunctionTestCase sh:property tosh:FunctionTestCase-expectedResult ; sh:property tosh:FunctionTestCase-expression ; . dash:GraphStoreTestCase }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:group tosh:RelationshipPropertyGroup ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . . dash:InferencingTestCase sh:property tosh:InferencingTestCase-expectedResult ; . dash:JSTestCase sh:property tosh:JSTestCase-expectedResult ; . dash:MultiFunction sh:property tosh:Function-apiStatus ; sh:property tosh:MultiFunction-resultVariable ; . dash:NonRecursiveConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:NonRecursiveConstraintComponent-nonRecursive sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "5"^^xsd:decimal ; . dash:PrimaryKeyConstraintComponent-uriStart sh:group tosh:StringConstraintsPropertyGroup ; sh:order "40"^^xsd:decimal ; . dash:PropertyRole sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; . dash:QueryTestCase sh:property tosh:QueryTestCase-expectedResult ; . dash:ReifiableByConstraintComponent-reifiableBy sh:group tosh:ReificationPropertyGroup ; sh:order "0"^^xsd:decimal ; . dash:ResourceAction sh:property tosh:ResourceAction-jsCondition ; . dash:RootClassConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; . dash:RootClassConstraintComponent-rootClass sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "10"^^xsd:decimal ; . dash:SPARQLConstructTemplate a sh:NodeShape ; sh:property tosh:Parameterizable-labelTemplate ; . dash:SPARQLSelectTemplate a sh:NodeShape ; sh:property tosh:Parameterizable-labelTemplate ; . dash:Script sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; sh:property tosh:Script-js ; . dash:ScriptConstraint sh:property tosh:Script-onAllValues ; sh:property tosh:ScriptConstraint-deactivated ; sh:property tosh:ScriptConstraint-message ; . dash:ScriptConstraintComponent-scriptConstraint sh:group tosh:AdvancedPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:ScriptFunction sh:property tosh:ScriptFunction-canWrite ; . dash:ScriptTestCase sh:property tosh:ScriptTestCase-expectedResult ; sh:property tosh:ScriptTestCase-focusNode ; . dash:ScriptValidator sh:property tosh:Script-onAllValues ; . dash:Service sh:property tosh:Service-canWrite ; sh:property tosh:Service-deactivated ; sh:property tosh:Service-responseContentType ; . dash:StemConstraintComponent-stem sh:group tosh:StringConstraintsPropertyGroup ; sh:order "45"^^xsd:decimal ; . dash:SubSetOfConstraintComponent-subSetOf sh:group tosh:PropertyPairConstraintsPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:SymmetricConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator [ a dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add symmetric value." ; sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """INSERT { $value $predicate $focusNode . } WHERE { }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "10"^^xsd:decimal ; . dash:TestCase sh:property tosh:TestCase-deactivated ; . dash:TestCaseResult sh:property [ a sh:PropertyShape ; sh:path dash:testCase ; sh:class dash:TestCase ; sh:description "The dash:TestCase that was executed." ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "test case" ; ] ; sh:property [ a sh:PropertyShape ; sh:path dash:testGraph ; sh:class rdfs:Resource ; sh:description "The graph containing the test case." ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "test graph" ; sh:nodeKind sh:IRI ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass sh:group tosh:ValueConstraintsPropertyGroup ; sh:order "20"^^xsd:decimal ; . dash:ValidationTestCase sh:property tosh:ValidationTestCase-expectedResult ; sh:property tosh:ValidationTestCase-includeSuggestions ; sh:property tosh:ValidationTestCase-validateShapes ; . tosh:PropertyShapeShape a sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ a sh:PropertyShape ; sh:path dash:detailsEndpoint ; sh:datatype xsd:string ; sh:group tosh:RemoteValuesPropertyGroup ; sh:maxCount 1 ; sh:order "0"^^xsd:decimal ; ] ; sh:property [ a sh:PropertyShape ; sh:path sh:values ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . <http://spinrdf.org/spin#> tosh:systemNamespace true ; . <http://spinrdf.org/spl#> tosh:systemNamespace true ; . <http://topbraid.org/tosh> a owl:Ontology ; dash:generateClass dash:ConstraintReificationShape ; dash:generateClass rdf:Property ; dash:generateClass rdfs:Class ; dash:generateClass rdfs:Datatype ; dash:generateClass owl:Class ; dash:generateClass owl:Ontology ; dash:generateClass sh:ConstraintComponent ; dash:generateClass sh:PropertyGroup ; dash:generateClass sh:Rule ; dash:generateClass sh:Shape ; dash:generatePrefixConstants "dash" ; dash:generatePrefixConstants "owl" ; dash:generatePrefixConstants "rdf" ; dash:generatePrefixConstants "rdfs" ; dash:generatePrefixConstants "sh" ; dash:generatePrefixConstants "xsd" ; rdfs:comment """A collection of SHACL features that are available whenever SHACL graphs are used within TopBraid Suite products. In particular this includes shape definitions for the \"system\" classes such as rdfs:Class, sh:PropertyShape etc. These shapes are used by TopBraid products to validate ontology definitions and to drive user interface forms. The TOSH namespace also includes things like suggestions, Active Data Shapes scripts and a couple of SPARQL functions. Some of these may be of general use outside of TopBraid too.""" ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; sh:prefix "afn" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; sh:prefix "spif" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; sh:prefix "tosh" ; ] ; . tosh: tosh:systemNamespace true ; . tosh:Action-actionGroup a sh:PropertyShape ; sh:path dash:actionGroup ; sh:class dash:ActionGroup ; sh:description "The Action Group that the action should appear in (in menus etc)." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:order "5"^^xsd:decimal ; . tosh:Action-actionIconClass a sh:PropertyShape ; sh:path dash:actionIconClass ; sh:datatype xsd:string ; sh:description "The CSS class for the action for display purposes. For example, pick one of https://fontawesome.com/icons?d=gallery&m=free or https://getbootstrap.com/docs/3.3/components/#glyphicons-glyphs" ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:order "7"^^xsd:decimal ; . tosh:Action-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this action (from user interfaces)." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "8"^^xsd:decimal ; . tosh:ActionGroup-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this group compared to other groups, e.g. to display in drop down menus." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; . tosh:ActionTestCase-action a sh:PropertyShape ; sh:path dash:action ; sh:class dash:Action ; sh:description "The dash:Action to execute." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "action" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:ActionTestCase-expectedResult sh:name "on property" ; sh:order 0 ; ] ; sh:sparql [ sh:message "Property shapes cannot have both class and datatype constraints." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER EXISTS { $this sh:class ?class . $this sh:datatype ?datatype . } }""" ; ] ; sh:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup sh:order "10"^^xsd:decimal ; . rdfs:label "Relationship" ; sh:order 8 ; . tosh:RemoteValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Remote Values" ; sh:order "12"^^xsd:decimal ; . tosh:ReplaceWithDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to replace all values of the given predicate (which must exist) at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; sh:name "focus node" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "5"^^xsd:decimal ; . tosh:ActionTestCase-variables a sh:PropertyShape ; sh:path dash:variables ; sh:datatype xsd:string ; sh:description """A JSON object (string) with name-value pairs for the variable bindings. This must be in the same format as expected by the script servlet. For parameters that declare dash:mimeTypes (i.e. file upload parameters), the value needs to be the path to a file relative to the workspace root. This file will be temporarily uploaded for the duration of the test case execution.""" ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "variables" ; sh:order "2"^^xsd:decimal ; . tosh:AdvancedPropertyGroup a sh:PropertyGroup ; rdfs:label "Advanced" ; sh:order "95"^^xsd:decimal ; . tosh:ChangeScript-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this script, for example for testing purposes, without having to delete it." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "10"^^xsd:decimal ; . tosh:ChangeScript-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this script compared to other change scripts. The default value is 0. Scripts with lower numbers are executed first." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "40"^^xsd:decimal ; . tosh:Class-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of sh:NodeShape. * @returns {sh_NodeShape} */ asNodeShape() { return sh.asNodeShape(this); } /** * @callback rdfs_Class_callback * @param {rdfs_Class} class the visited class */ /** * Performs a depth-first traversal this class and its superclasses, visiting each (super) class * once until the callback function returns a non-null/undefined result. This becomes the result of this function. * The order in which sibling classes are traversed is undefined, so results may be inconsistent in * multiple-inheritance scenarios. * @param {rdfs_Class_callback} callback the callback for each class * @param {Set} [reached] the Set of reached URI strings, used internally * @returns the return value of the first callback that returned any value */ walkSuperclasses(callback, reached) { if(!reached) { reached = new Set(); } if(!reached.has(this.uri)) { reached.add(this.uri); let result = callback(this); if(result !== undefined && result !== null) { return result; } let supers = this.superclasses; for(let i = 0; i < supers.length; i++) { result = supers[i].walkSuperclasses(callback, reached); if(result !== undefined && result !== null) { return result; } } } } """ ; . tosh:Class-abstract a sh:PropertyShape ; sh:path dash:abstract ; sh:datatype xsd:boolean ; sh:description "States whether this class is abstract, i.e. cannot have direct instances. Abstract classes are typically used to defined shared properties of its subclasses." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "abstract" ; sh:order "30"^^xsd:decimal ; . tosh:Class-classIcon a sh:PropertyShape ; sh:path tosh:classIcon ; dash:hidden true ; dash:propertyRole dash:IconRole ; sh:datatype xsd:string ; sh:defaultValue "http://datashapes.org/icons/class.svg" ; sh:description "Used to return the default icon for all classes." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "class icon" ; sh:order "1"^^xsd:decimal ; . tosh:Class-constructor a sh:PropertyShape ; sh:path dash:constructor ; graphql:name "constructorScript" ; sh:class dash:Constructor ; sh:description "The Constructor that shall be used to create new instances of this class or its subclasses." ; sh:group tosh:ScriptsPropertyGroup ; sh:maxCount 1 ; sh:name "constructor" ; sh:order "20"^^xsd:decimal ; . tosh:Class-disjointWith a sh:PropertyShape ; sh:path owl:disjointWith ; sh:class owl:Class ; sh:group tosh:OWLAxiomsPropertyGroup ; sh:name "disjoint with" ; sh:order "1"^^xsd:decimal ; . tosh:Class-domain-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:domain ; ] ; dash:editor dash:PropertyAutoCompleteEditor ; sh:class rdf:Property ; sh:description "The properties that declare to have this class in their domain." ; sh:group tosh:RDFSPropertyAxiomsPropertyGroup ; sh:name "domain of" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:Class-equivalentClass a sh:PropertyShape ; sh:path owl:equivalentClass ; sh:class owl:Class ; sh:group tosh:OWLAxiomsPropertyGroup ; sh:name "equivalent classes" ; sh:order "0"^^xsd:decimal ; . tosh:Class-hidden a sh:PropertyShape ; sh:path dash:hidden ; sh:datatype xsd:boolean ; sh:description "True if this class shall be hidden from the class hierarchies." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "hidden" ; sh:order "0"^^xsd:decimal ; . tosh:Class-range-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:range ; ] ; dash:editor dash:PropertyAutoCompleteEditor ; sh:class rdf:Property ; sh:description "The properties that have this class in their rdfs:range." ; sh:group tosh:RDFSPropertyAxiomsPropertyGroup ; sh:name "range of" ; sh:nodeKind sh:IRI ; sh:order "1"^^xsd:decimal ; . tosh:Class-resourceAction a sh:PropertyShape ; sh:path dash:resourceAction ; graphql:name "resourceActions" ; sh:class dash:ResourceAction ; sh:description "The Resource Actions that can be applied to instances of this class." ; sh:group tosh:ScriptsPropertyGroup ; sh:name "resource actions" ; sh:order "0"^^xsd:decimal ; . tosh:Class-resourceService a sh:PropertyShape ; sh:path dash:resourceService ; graphql:name "resourceServices" ; sh:class dash:ResourceService ; sh:description "The Services that can be applied to instances of this class (as focusNode)." ; rdfs:label "Type of Values" ; sh:order 3 ; . tosh:closed a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment "If set to true, then the corresponding form section will be closed by default." ; rdfs:domain sh:PropertyGroup ; rdfs:label "closed" ; rdfs:range xsd:boolean ; . tosh:countShapesWithMatchResult a sh:SPARQLFunction ; rdfs:comment "Counts the number of shapes from a given rdf:List (?arg2) defined in a given shapes graph (?arg3) where tosh:hasShape returns the provided match value (true or false, ?arg4) for a given focus node (?arg1). The function produces a failure if one of the shapes validated to a failure." ; sh:path rdfs:subClassOf ; graphql:name "superclasses" ; sh:class rdfs:Class ; sh:description "The (direct) parent classes of this class." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "superclasses" ; sh:order "20"^^xsd:decimal ; . tosh:Class-subClassOf-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:subClassOf ; ] ; dash:hidden true ; graphql:name "subclasses" ; sh:class rdfs:Class ; sh:description "The (direct) subclasses of this class." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "subclasses" ; sh:order "21"^^xsd:decimal ; . tosh:ConstraintComponent-localConstraint a sh:PropertyShape ; sh:path dash:localConstraint ; sh:datatype xsd:boolean ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "local constraint" ; sh:order "10"^^xsd:decimal ; . tosh:ConstraintComponent-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message to generate on violations." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "26"^^xsd:decimal ; . tosh:ConstraintComponent-nodeValidator a sh:PropertyShape ; sh:path sh:nodeValidator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate a constraint in the context of a node shape." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "node validators" ; sh:order "2"^^xsd:decimal ; . tosh:ConstraintComponent-propertySuggestionGenerator a sh:PropertyShape ; sh:path dash:propertySuggestionGenerator ; sh:class dash:SuggestionGenerator ; sh:group tosh:ImplementationPropertyGroup ; sh:name "property suggestion generators" ; sh:order "20"^^xsd:decimal ; . tosh:ConstraintComponent-propertyValidator a sh:PropertyShape ; sh:path sh:propertyValidator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate a constraint in the context of a property shape." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "property validators" ; sh:order "1"^^xsd:decimal ; . tosh:ConstraintComponent-staticConstraint a sh:PropertyShape ; sh:path dash:staticConstraint ; sh:datatype xsd:boolean ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "static constraint" ; sh:order "11"^^xsd:decimal ; . tosh:ConstraintComponent-validator a sh:PropertyShape ; sh:path sh:validator ; sh:class sh:Validator ; sh:description "The validator(s) used to evaluate constraints of either node or property shapes, unless more specific validators are available." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "validators" ; sh:order "0"^^xsd:decimal ; . tosh:DatatypePropertyShapeView a sh:NodeShape ; rdfs:comment "The default view shape for property shapes on datatype values." ; rdfs:label "Attribute view" ; sh:node tosh:PropertyShapeView ; sh:property dash:PrimaryKeyConstraintComponent-uriStart ; sh:property dash:SingleLineConstraintComponent-singleLine ; sh:property tosh:Shape-datatypes ; sh:property sh:LanguageInConstraintComponent-languageIn ; sh:property sh:LessThanConstraintComponent-lessThan ; sh:property sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals ; sh:property sh:MaxExclusiveConstraintComponent-maxExclusive ; sh:property sh:MaxInclusiveConstraintComponent-maxInclusive ; sh:property sh:MaxLengthConstraintComponent-maxLength ; sh:property sh:MinExclusiveConstraintComponent-minExclusive ; sh:property sh:MinInclusiveConstraintComponent-minInclusive ; sh:property sh:MinLengthConstraintComponent-minLength ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; sh:property sh:UniqueLangConstraintComponent-uniqueLang ; ] ; sh:returnType xsd:boolean ; . tosh:isSystemResource a sh:SPARQLFunction ; rdfs:comment "Checks if a given resource is from a namespace that is marked with tosh:systemNamespace true." ; rdfs:label "is system resource" ; sh:ask """ASK { BIND (IRI(afn:namespace($resource)) AS ?namespace) . FILTER (bound(?namespace) && EXISTS { ?namespace tosh:systemNamespace true . }) }""" ; sh:parameter [ a sh:Parameter ; sh:path tosh:resource ; sh:description "The node to check." ; sh:name "resource" ; sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:prefixes <http://topbraid.org/tosh> ; sh:returnType xsd:boolean ; . tosh:open a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment """DEPRECATED: This flag is only used by SWA forms. With the new forms of 6.2 onwards, all form sections are open by default, but you can use tosh:closed to state otherwise. If set to true, then the corresponding form section will be open by default. This only has an effect if sh:openable is set to true as well.""" ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable a rdf:Property ; a owl:DeprecatedProperty ; rdfs:comment """DEPRECATED - this was only used by the SWA-based forms that were default before 6.2. In the new forms, all sections are openable. If set to true, then the corresponding form section shall be openable/closable (and show up closed).""" ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . sh:update """DELETE { $focusNode $predicate $value . } WHERE { $focusNode $predicate $value . }""" ; . tosh:DependentEnumSelectEditor a dash:SingleEditor ; rdfs:comment """A drop-down editor for enumerated values that are dynamically determined via a node shape that has sh:target dash:HasValueTarget. Example: states:USAddressShape rdf:type sh:NodeShape ; rdfs:label \"US Address shape\" ; sh:property [ rdf:type sh:PropertyShape ; sh:path states:state ; sh:in ( \"AZ\" \"CA\" \"FL\" ) ; ] ; sh:target [ rdf:type dash:HasValueTarget ; dash:object \"USA\" ; dash:predicate states:country ; ] . """ ; rdfs:label "Dependent enum select editor" ; . tosh:DisplayPropertyGroup a sh:PropertyGroup ; rdfs:label "Display" ; sh:order "30"^^xsd:decimal ; . tosh:Function-apiStatus a sh:PropertyShape ; sh:path dash:apiStatus ; sh:class dash:APIStatus ; sh:description "Declares the status of this function within the TopBraid API. The usual life cycle is to start with no value (meaning: not part of the API at all), then experimental from which it later either moves to stable or deprecated. Stable functions may also get deprecated and have no api status after at least one release cycle." ; sh:group tosh:DefinitionPropertyGroup ; sh:in ( dash:Experimental dash:Stable dash:Deprecated ) ; sh:maxCount 1 ; sh:name "API status" ; sh:order "15"^^xsd:decimal ; . tosh:Function-cachable a sh:PropertyShape ; sh:path dash:cachable ; sh:datatype xsd:boolean ; sh:description "True to indicate that this function will always return the same values for the same combination of arguments, regardless of the query graphs. Engines can use this information to cache and reuse previous function calls." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "cachable" ; sh:order "10"^^xsd:decimal ; . tosh:Function-returnType a sh:PropertyShape ; sh:path sh:returnType ; sh:class rdfs:Class ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "return type" ; sh:order "5"^^xsd:decimal ; . tosh:FunctionTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of a function call." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:order "10"^^xsd:decimal ; . tosh:FunctionTestCase-expression a sh:PropertyShape ; sh:path dash:expression ; sh:description "A valid SPARQL expression calling the function to test." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "expression" ; sh:order "0"^^xsd:decimal ; . tosh:GovernanceRoleSelectEditor a dash:SingleEditor ; rdfs:label "Governance role editor" ; . tosh:GovernanceRoleViewer a dash:SingleViewer ; rdfs:label "Governance role viewer" ; . tosh:GraphStoreTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:datatype xsd:string ; sh:description "The expected RDF graph, as a Turtle string." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:order "10"^^xsd:decimal ; . tosh:GraphStoreTestCase-uri a sh:PropertyShape ; sh:path dash:uri ; sh:datatype xsd:anyURI ; sh:description "The URI of the graph to load." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "uri" ; sh:order "0"^^xsd:decimal ; . tosh:ImplementationPropertyGroup a sh:PropertyGroup ; rdfs:label "Implementation" ; sh:order "10"^^xsd:decimal ; . tosh:IncludedScript-exports a sh:PropertyShape ; sh:path dash:exports ; sh:datatype xsd:string ; sh:description "Declares the symbols that shall be exported from the surrounding module, e.g. for use in Node.js applications." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "exports" ; sh:order "30"^^xsd:decimal ; . tosh:InferenceRulesShape a sh:NodeShape ; rdfs:comment "A node shape for classes and node shapes, declaring the sh:rule property." ; rdfs:label "Inference rules" ; sh:property tosh:InferenceRulesShape-rule ; sh:targetClass sh:NodeShape ; . tosh:InferenceRulesShape-rule a sh:PropertyShape ; sh:path sh:rule ; sh:class sh:Rule ; sh:description "The inference rules associated with this node shape or class." ; sh:group tosh:InferencesPropertyGroup ; sh:name "rule" ; . tosh:InferencesPropertyGroup a sh:PropertyGroup ; rdfs:label "Inferences" ; sh:order "80"^^xsd:decimal ; . tosh:InferencingTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected inferred triples, represented by instances of rdfs:Statement." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:name "expected result" ; sh:order "10"^^xsd:decimal ; . tosh:InstancesInGraphSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of a class (based on tosh:shapeInGraph/sh:class of the property) in a graph specified using tosh:graph." ; rdfs:label "Instances in graph select editor" ; . tosh:JSTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of the JavaScript function call, as an RDF node." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; . tosh:MemberShapeConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Can be used to specify constraints on the members of a given list, assuming that the given sh:property has rdf:Lists as values. A violation is reported for each member of the list that does not comply with the constraints specified by the given shape." ; rdfs:label "Member shape constraint component" ; sh:parameter tosh:MemberShapeConstraintComponent-memberShape ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "List member does not have the shape {$memberShape}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure ?member WHERE { $this $PATH ?value . ?value rdf:rest*/rdf:first ?member . BIND (tosh:hasShape(?member, $memberShape) AS ?hasShape) . BIND (!bound(?hasShape) AS ?failure) . FILTER (?failure || !?hasShape) . } """ ; ] ; sh:targetClass sh:PropertyShape ; . tosh:MemberShapeConstraintComponent-memberShape a sh:Parameter ; sh:path tosh:memberShape ; sh:class sh:Shape ; sh:description "The shape that the list members must have." ; sh:name "member shape" ; . tosh:ModifyAction-skipPreview a sh:PropertyShape ; sh:path dash:skipPreview ; sh:datatype xsd:boolean ; sh:description "For actions that take no parameters, this can be set to true to skip any means for the user to preview the action. It will instead directly execute the modification." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "skip preview" ; sh:order "11"^^xsd:decimal ; . tosh:MultiFunction-resultVariable a sh:PropertyShape ; sh:path dash:resultVariable ; sh:class sh:Parameter ; sh:description "The result variables." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "result variables" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "30"^^xsd:decimal ; . tosh:NodeShape-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of rdfs_Class, assuming this node shape is also a class. * @returns {rdfs_Class} */ asClass() { return rdfs.asClass(this); } /** * Gets the \"nearest\" constraint of a given type and a given path property. Deactivated shapes are skipped. * For example, call it with (ex.myProperty, sh.datatype) to find the closest sh:datatype constraint for ex:myProperty. * @param {NamedNode} path the property that is the sh:path of matching property shapes * @param {NamedNode} predicate the property to fetch the nearest value of */ nearestPropertyShapeValue(path, predicate) { return this.walkSupershapes(s => { if(!s.deactivated) { let ps = s.properties; for(let i = 0; i < ps.length; i++) { if(!ps[i].deactivated && graph.contains(ps[i], sh.path, path)) { let value = ps[i].value(predicate); if(value !== null && value !== undefined) { return value; } } } } }) } /** * @callback sh_NodeShape_callback * @param {sh_NodeShape} nodeShape the visited node shape */ /** * Performs a depth-first traversal of this and its superclasses (via rdfs:subClassOf) and supershapes (via sh:node), * visiting each (super) shape once until the callback function returns a non-null/undefined result. This becomes the result of this function. * The order in which sibling parents are traversed is undefined. * @param {sh_NodeShape_callback} callback the callback for each shape * @param {Set} [reached] the Set of reached URI strings, used internally but may also be used to terminate at certain supers * @returns the return value of the first callback that returned any value */ walkSupershapes(callback, reached) { if(!reached) { reached = new Set(); } if(!reached.has(this.uri)) { reached.add(this.uri); let result = callback(this); if(result !== undefined && result !== null) { return result; } let superClasses = this.asClass().superclasses; for(let i = 0; i < superClasses.length; i++) { result = superClasses[i].asNodeShape().walkSupershapes(callback, reached); if(result !== undefined && result !== null) { return result; } } let superShapes = this.supershapes; for(let i = 0; i < superShapes.length; i++) { result = superShapes[i].walkSupershapes(callback, reached); if(result !== undefined && result !== null) { return result; } } } } """ ; . tosh:NodeShape-applicableToClass a sh:PropertyShape ; sh:path dash:applicableToClass ; sh:class rdfs:Class ; sh:description "Links a node shape with the classes that it can be applied to." ; sh:group tosh:TargetsPropertyGroup ; sh:name "applicable to classes" ; sh:nodeKind sh:IRI ; sh:order "10"^^xsd:decimal ; . tosh:NodeShape-defaultViewForRole a sh:PropertyShape ; sh:path dash:defaultViewForRole ; dash:editor tosh:GovernanceRoleSelectEditor ; dash:viewer tosh:GovernanceRoleViewer ; sh:description "The user roles that this shape shall be used as default view for." ; sh:group tosh:TargetsPropertyGroup ; sh:name "default view for roles" ; sh:nodeKind sh:IRI ; sh:order "20"^^xsd:decimal ; . tosh:NodeShape-inheritedProperty a sh:PropertyShape ; sh:path tosh:inheritedProperty ; dash:neverMaterialize true ; dash:viewer tosh:PropertyTableViewer ; sh:description "Returns all property shapes that have been declared at \"super-shapes\" (via sh:node) or \"superclasses\" (via rdfs:subClassOf), including the indirect supers, recursively." ; sh:group tosh:PropertiesPropertyGroup ; sh:name "inherited properties" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "1"^^xsd:decimal ; sh:values [ sh:path sh:property ; sh:nodes [ sh:minus sh:this ; sh:nodes [ sh:distinct [ sh:path [ sh:oneOrMorePath [ sh:alternativePath ( rdfs:subClassOf sh:node ) ; ] ; ] ; ] ; ] ; ] ; ] ; . tosh:NodeShape-node a sh:PropertyShape ; sh:path sh:node ; graphql:name "supershapes" ; sh:description "The node shapes that this must also conform to, forming a kind of inheritance between shapes similar to a subclass-of relationship." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "node (super shapes)" ; sh:node sh:NodeShape ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "20"^^xsd:decimal ; . tosh:NodeShape-targetClass a sh:PropertyShape ; sh:path sh:targetClass ; graphql:name "targetClasses" ; sh:class rdfs:Class ; sh:description "The types of instances that this shape is targeted at." ; sh:group tosh:TargetsPropertyGroup ; sh:name "target classes" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . tosh:NodeShape-targetObjectsOf a sh:PropertyShape ; sh:path sh:targetObjectsOf ; sh:group tosh:TargetsPropertyGroup ; sh:name "target objects of" ; sh:node rdf:Property ; sh:nodeKind sh:IRI ; sh:order "1"^^xsd:decimal ; . tosh:NodeShape-targetSubjectsOf a sh:PropertyShape ; sh:path sh:targetSubjectsOf ; sh:group tosh:TargetsPropertyGroup ; sh:name "target subjects of" ; sh:node rdf:Property ; sh:nodeKind sh:IRI ; sh:order "2"^^xsd:decimal ; . tosh:NodeShapeConstraintsShape a sh:NodeShape ; rdfs:comment "A shape that can be used to validate the syntax of node shapes, and to enter constraints for node shapes on forms." ; rdfs:label "Node shape constraints" ; sh:property dash:ClosedByTypesConstraintComponent-closedByTypes ; sh:property dash:ScriptConstraintComponent-scriptConstraint ; sh:property dash:SingleLineConstraintComponent-singleLine ; sh:property dash:StemConstraintComponent-stem ; sh:property tosh:Shape-datatypes ; sh:property sh:ClassConstraintComponent-class ; sh:property sh:ClosedConstraintComponent-closed ; sh:property sh:ClosedConstraintComponent-ignoredProperties ; sh:property sh:DatatypeConstraintComponent-datatype ; sh:property sh:HasValueConstraintComponent-hasValue ; sh:property sh:InConstraintComponent-in ; sh:property sh:LanguageInConstraintComponent-languageIn ; sh:property sh:MaxExclusiveConstraintComponent-maxExclusive ; sh:property sh:MaxInclusiveConstraintComponent-maxInclusive ; sh:property sh:MaxLengthConstraintComponent-maxLength ; sh:property sh:MinExclusiveConstraintComponent-minExclusive ; sh:property sh:MinInclusiveConstraintComponent-minInclusive ; sh:property sh:MinLengthConstraintComponent-minLength ; sh:property sh:NodeKindConstraintComponent-nodeKind ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; sh:property sh:SPARQLConstraintComponent-sparql ; sh:targetClass sh:NodeShape ; . tosh:NumberOfValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Number of Values" ; sh:order "40"^^xsd:decimal ; . tosh:OWLAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "OWL Axioms" ; sh:order "17"^^xsd:decimal ; . tosh:ObjectPropertyShapeView a sh:NodeShape ; rdfs:comment "The default view shape for property shapes on object values." ; rdfs:label "Relationship view" ; sh:node tosh:PropertyShapeView ; sh:property dash:NonRecursiveConstraintComponent-nonRecursive ; sh:property dash:RootClassConstraintComponent-rootClass ; sh:property dash:StemConstraintComponent-stem ; sh:property dash:SymmetricConstraintComponent-symmetric ; sh:property tosh:ObjectPropertyShapeView-node ; sh:property sh:ClassConstraintComponent-class ; sh:property sh:NodeKindConstraintComponent-nodeKind ; . tosh:ObjectPropertyShapeView-node a sh:PropertyShape ; sh:path sh:node ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class sh:NodeShape ; sh:description "The node shape(s) that all values of the property must conform to." ; sh:group tosh:ValueConstraintsPropertyGroup ; sh:name "node" ; sh:order "0"^^xsd:decimal ; . tosh:Ontology-imports a sh:PropertyShape ; sh:path owl:imports ; sh:description "The (directly) imported graphs." ; sh:name "imports" ; sh:nodeKind sh:IRI ; . tosh:Parameterizable-labelTemplate a sh:PropertyShape ; sh:path sh:labelTemplate ; sh:description "Outlines how human-readable labels of instances of the associated Parameterizable shall be produced. The values can contain {?paramName} as placeholders for the actual values of the given parameter." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "label template" ; sh:or dash:StringOrLangString ; sh:order "25"^^xsd:decimal ; . tosh:Parameterizable-parameter a sh:PropertyShape ; sh:path sh:parameter ; sh:class sh:Parameter ; sh:description "The input parameters." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "parameters" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "20"^^xsd:decimal ; . tosh:PathStringViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Path string viewer" ; . tosh:PropertiesPropertyGroup a sh:PropertyGroup ; rdfs:comment "The declared and inferred properties of a shape or class." ; rdfs:label "Properties" ; sh:order "10"^^xsd:decimal ; . tosh:Property-domain a sh:PropertyShape ; sh:path rdfs:domain ; graphql:name "domains" ; sh:description "The domain(s) of this property." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "0"^^xsd:decimal ; . tosh:Property-range a sh:PropertyShape ; sh:path rdfs:range ; graphql:name "ranges" ; sh:description "The range(s) of this property." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "1"^^xsd:decimal ; . tosh:Property-subPropertyOf a sh:PropertyShape ; sh:path rdfs:subPropertyOf ; graphql:name "superproperties" ; sh:class rdf:Property ; sh:description "The (direct) superproperties of this." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:name "superproperties" ; sh:nodeKind sh:IRI ; sh:order "2"^^xsd:decimal ; . tosh:Property-subPropertyOf-inverse a sh:PropertyShape ; sh:path [ sh:inversePath rdfs:subPropertyOf ; ] ; graphql:name "subproperties" ; sh:class rdf:Property ; sh:description "The (direct) subproperties of this." ; sh:group tosh:PropertyAxiomsPropertyGroup ; sh:name "subproperties" ; sh:nodeKind sh:IRI ; sh:order "3"^^xsd:decimal ; . tosh:PropertyAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "Property Axioms" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyGroup-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this group compared to others." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "0"^^xsd:decimal ; . tosh:PropertyPairConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "Property Pair Constraints" ; sh:order "75"^^xsd:decimal ; . tosh:PropertyShape-defaultValue a sh:PropertyShape ; sh:path sh:defaultValue ; dash:readOnly true ; dash:viewer dash:NodeExpressionViewer ; tosh:useDeclaredDatatype true ; sh:description "The default value to be used for this property if no other value has been asserted. This may be a constant value or a SHACL node expression, in which case the values can be derived from other values. Default values are typically inferred and not stored as RDF statements." ; sh:group tosh:InferencesPropertyGroup ; sh:name "default value" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-description a sh:PropertyShape ; sh:path sh:description ; dash:singleLine false ; graphql:name "descriptions" ; sh:description "The description(s) of the property, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "descriptions" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangStringOrHTML ; sh:order "1"^^xsd:decimal ; sh:sparql [ sh:message "Property shapes cannot have both class and datatype constraints." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER EXISTS { $this sh:class ?class . $this sh:datatype ?datatype . } }""" ; ] ; . tosh:PropertyShape-detailsEndpoint a sh:PropertyShape ; sh:path dash:detailsEndpoint ; sh:datatype xsd:string ; sh:maxCount 1 ; sh:name "details endpoint" ; . tosh:PropertyShape-editor a sh:PropertyShape ; sh:path dash:editor ; dash:editor dash:InstancesSelectEditor ; sh:class dash:Editor ; sh:description "The editor component that should be used to edit values of this property." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:nodeKind sh:IRI ; sh:order "11"^^xsd:decimal ; . tosh:PropertyShape-group a sh:PropertyShape ; sh:path sh:group ; sh:class sh:PropertyGroup ; sh:description "The group that this property belongs to." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "group" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-hidden rdfs:isDefinedBy sh: ; rdfs:label "distinct"@en ; . sh:else a rdf:Property ; rdfs:comment "Links an sh:if node expression with the values that shall be returned if the condition is false."@en ; rdfs:isDefinedBy sh: ; rdfs:label "else"@en ; . sh:exists a rdf:Property ; rdfs:comment "Resources with values for sh:exists are node expressions that produce true if the associated node expression has any values, and false otherwise."@en ; rdfs:isDefinedBy sh: ; rdfs:label "exists"@en ; . sh:groupConcat a rdf:Property ; rdfs:comment "Resources with values for sh:groupConcat are node expressions that produce an xsd:string consisting of the concatenation of all values of the associated node expression, possibly separated by the value of sh:separator."@en ; rdfs:isDefinedBy sh: ; rdfs:label "group concat"@en ; . sh:if a rdf:Property ; rdfs:comment "Resources with values for sh:if are node expressions that produce either the results of sh:then or sh:else depending on whether the associated node expression produces the list [ true ]."@en ; rdfs:isDefinedBy sh: ; rdfs:label "if"@en ; . sh:limit a rdf:Property ; rdfs:comment "Resources with values N for sh:limit are node expressions that produce only the first N values of the associated node expression sh:nodes."@en ; sh:datatype xsd:boolean ; sh:description "True to indicate that the values of this shall be indexed, forming ordered arrays." ; sh:maxCount 1 ; sh:name "indexed" ; . tosh:PropertyShape-name a sh:PropertyShape ; sh:path sh:name ; dash:singleLine true ; graphql:name "names" ; sh:description "The display names of the property, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "names" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangString ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShape-neverMaterialize a sh:PropertyShape ; sh:path dash:neverMaterialize ; sh:datatype xsd:boolean ; sh:group tosh:InferencesPropertyGroup ; sh:maxCount 1 ; sh:name "never materialize" ; sh:order "11"^^xsd:decimal ; . tosh:PropertyShape-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The relative order of this property shape compared to others." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShape-path rdfs:isDefinedBy sh: ; rdfs:label "sum"@en ; . sh:then a rdf:Property ; rdfs:comment "Links an sh:if node expression with the values that shall be returned if the condition is true."@en ; rdfs:isDefinedBy sh: ; rdfs:label "then"@en ; . sh:values a rdf:Property ; rdfs:comment "Links a property shape with one or more SHACL node expressions that are used to determine the values of the associated predicate based on the current focus node. Only valid for property shapes where the sh:path is an IRI."@en ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "31"^^xsd:decimal ; . tosh:PropertyShape-propertyRole a sh:PropertyShape ; sh:path dash:propertyRole ; sh:class dash:PropertyRole ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:name "role" ; sh:order "40"^^xsd:decimal ; . tosh:PropertyShape-readOnly a sh:PropertyShape ; sh:path dash:readOnly ; dash:editor dash:BooleanSelectEditor ; dash:viewer dash:NodeExpressionViewer ; sh:datatype xsd:boolean ; sh:description """If set to true then the values of this property should not be editable in the user interface. Note that low-level access such as source code editors may still allow editing, but form-based editors would not. More generally, the values of this property are SHACL node expressions, e.g. function calls, in which case the property counts as read-only if the expression evaluates to true.""" ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:order "20"^^xsd:decimal ; . tosh:PropertyShape-values a sh:PropertyShape ; sh:path sh:values ; dash:viewer dash:NodeExpressionViewer ; sh:group tosh:InferencesPropertyGroup ; sh:name "values" ; sh:order "10"^^xsd:decimal ; sh:sparql [ sh:message "sh:values must be accompanied by a sh:path that is an IRI." ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this ?value WHERE { $this $PATH ?value . FILTER NOT EXISTS { $this sh:path ?path . FILTER isIRI(?path) } }""" ; ] ; . tosh:PropertyShape-viewer a sh:PropertyShape ; sh:path dash:viewer ; dash:editor dash:InstancesSelectEditor ; sh:class dash:Viewer ; sh:description "The viewer component that should be used to render values of this property." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:nodeKind sh:IRI ; sh:order "10"^^xsd:decimal ; . tosh:PropertyShapeView a sh:NodeShape ; rdfs:comment "Base view shape for either datatype or object property shapes." ; rdfs:label "Property shape view" ; sh:property dash:CoExistsWithConstraintComponent-coExistsWith ; sh:property dash:IndexedConstraintComponent-indexed ; sh:property dash:ReifiableByConstraintComponent-reifiableBy ; sh:property dash:ScriptConstraintComponent-scriptConstraint ; sh:property dash:SubSetOfConstraintComponent-subSetOf ; sh:property tosh:PropertyShape-defaultValue ; sh:property tosh:PropertyShape-description ; sh:property tosh:PropertyShape-editor ; sh:property tosh:PropertyShape-group ; sh:property tosh:PropertyShape-hidden ; sh:property tosh:PropertyShape-name ; sh:property tosh:PropertyShape-neverMaterialize ; sh:property tosh:PropertyShape-order ; sh:property tosh:PropertyShape-propertyRole ; sh:property tosh:PropertyShape-readOnly ; sh:property tosh:PropertyShape-values ; sh:property tosh:PropertyShape-viewer ; sh:property tosh:PropertyShapeView-message ; sh:property tosh:PropertyShapeView-pathSystemLabel ; sh:property tosh:PropertyShapeView-qualifiedMaxCount ; sh:property tosh:PropertyShapeView-qualifiedMinCount ; sh:property tosh:PropertyShapeView-qualifiedValueShape ; sh:property tosh:PropertyShapeView-qualifiedValueShapesDisjoint ; sh:property tosh:Shape-deactivated ; sh:property tosh:Shape-severity ; sh:property sh:DisjointConstraintComponent-disjoint ; sh:property sh:EqualsConstraintComponent-equals ; sh:property sh:MaxCountConstraintComponent-maxCount ; sh:property sh:MinCountConstraintComponent-minCount ; sh:property sh:SPARQLConstraintComponent-sparql ; . tosh:PropertyShapeView-indexed a sh:PropertyShape ; sh:path dash:indexed ; sh:datatype xsd:boolean ; sh:description "Indicates whether the values are sorted by an index. The user interface will display them in-order." ; sh:group tosh:ReificationPropertyGroup ; sh:maxCount 1 ; sh:name "indexed" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShapeView-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message that shall be generated for all constraint violations produced by this property shape." ; sh:group tosh:ValidationPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "5"^^xsd:decimal ; . tosh:PropertyShapeView-pathSystemLabel a sh:PropertyShape ; sh:path tosh:pathSystemLabel ; dash:neverMaterialize true ; dash:viewer tosh:PathStringViewer ; sh:datatype xsd:string ; sh:description "A display label of the sh:path based on qnames." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "property path" ; sh:order "2"^^xsd:decimal ; sh:values [ sh:else [ <http://uispin.org/ui#label> ( [ sh:path sh:path ; ] ) ; ] ; sh:if [ <http://datashapes.org/sparql#isIRI> ( [ sh:path sh:path ; ] ) ; ] ; sh:then [ <http://topbraid.org/sparqlmotionfunctions#qname> ( [ sh:path sh:path ; ] ) ; ] ; ] ; . tosh:PropertyShapeView-qualifiedMaxCount a sh:PropertyShape ; sh:path sh:qualifiedMaxCount ; sh:datatype xsd:integer ; sh:description "The maximum number of values that may conform to the qualified value shape." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified max count" ; sh:order "1"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedMinCount a sh:PropertyShape ; sh:path sh:qualifiedMinCount ; sh:datatype xsd:integer ; sh:description "The minimum number of values that must conform to the qualified value shape." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified min count" ; sh:order "0"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedValueShape a sh:PropertyShape ; sh:path sh:qualifiedValueShape ; sh:class sh:NodeShape ; sh:description "The shape that the specified number of values must conform to." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:name "qualified value shape" ; sh:order "2"^^xsd:decimal ; . tosh:PropertyShapeView-qualifiedValueShapesDisjoint a sh:PropertyShape ; sh:path sh:qualifiedValueShapesDisjoint ; sh:datatype xsd:boolean ; sh:description "True to treat all qualified values as disjoint." ; sh:group tosh:QualifiedCardinalityConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "qualified value shapes disjoint" ; sh:order "3"^^xsd:decimal ; . tosh:PropertyTableViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Property table viewer" ; . tosh:QualifiedCardinalityConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:comment "The properties in this group are used together to express that a certain number of values must conform to a given shape." ; rdfs:label "Qualified Cardinality Constraints" ; sh:order "77"^^xsd:decimal ; . tosh:QueryTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; dash:singleLine false ; sh:description "The expected result set, as a JSON string." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:or ( [ sh:datatype rdf:JSON ; ] [ sh:datatype xsd:string ; ] ) ; . tosh:RDFSOWLClassView a sh:NodeShape ; dash:applicableToClass rdfs:Class ; rdfs:comment "A node shape collecting RDFS and OWL axioms for classes." ; rdfs:label "RDFS/OWL class view" ; sh:property tosh:Class-disjointWith ; sh:property tosh:Class-domain-inverse ; sh:property tosh:Class-equivalentClass ; sh:property tosh:Class-range-inverse ; sh:property tosh:Class-subClassOf ; sh:property tosh:Class-subClassOf-inverse ; sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; sh:property tosh:Resource-type ; . tosh:RDFSPropertyAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "RDFS Property Axioms" ; sh:order "15"^^xsd:decimal ; . tosh:ReferencesPropertyGroup a sh:PropertyGroup ; rdfs:comment "A property group typically used for incoming references or usages."^^rdf:HTML ; rdfs:label "References" ; sh:order "100"^^xsd:decimal ; . tosh:ReificationPropertyGroup a sh:PropertyGroup ; rdfs:label "Reification (Statements about Statements)" ; sh:order "90"^^xsd:decimal ; . tosh:ReplaceWithDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to replace all values of the given predicate (which must exist) at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; rdfs:label "Replace with default value suggestion generator" ; sh:message "Replace with default value" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?defaultValue WHERE { GRAPH $shapesGraph { $sourceShape sh:defaultValue ?defaultValue . } }""" ; sh:update """DELETE { $focusNode $predicate ?oldValue . } INSERT { $focusNode $predicate ?defaultValue . } WHERE { $focusNode $predicate ?oldValue . }""" ; . tosh:Resource-comment a sh:PropertyShape ; sh:path rdfs:comment ; dash:propertyRole dash:DescriptionRole ; dash:singleLine false ; graphql:name "comments" ; sh:description "The comments of this, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "comments" ; sh:or dash:StringOrLangStringOrHTML ; sh:order "1"^^xsd:decimal ; . tosh:Resource-label a sh:PropertyShape ; sh:path rdfs:label ; dash:propertyRole dash:LabelRole ; graphql:name "labels" ; sh:description "The display name(s) of this, possibly in multiple languages." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "labels" ; sh:or dash:StringOrLangString ; sh:order "0"^^xsd:decimal ; . tosh:Resource-type a sh:PropertyShape ; sh:path rdf:type ; graphql:name "types" ; sh:class rdfs:Class ; sh:description "The type(s) of this." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "types" ; sh:order "10"^^xsd:decimal ; . tosh:ResourceAction-jsCondition a sh:PropertyShape ; sh:path dash:jsCondition ; sh:datatype xsd:string ; sh:description "An (ADS) JavaScript expression that will be executed to determine whether the action is applicable to the selected resource in the current context. The variable focusNode can be queried here. The expression needs to return true for the action to be deemed suitable." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "action pre-condition" ; sh:order "25"^^xsd:decimal ; . tosh:ResourceView a sh:NodeShape ; rdfs:comment "A generic view shape that can be used as fallback to display typical resources that have an rdfs:label and an rdfs:comment." ; rdfs:label "Resource view" ; sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; . tosh:Rule-condition a sh:PropertyShape ; sh:path sh:condition ; sh:description "The pre-conditions that must apply before a rule gets executed. The focus node must conform to all conditions, which must be shapes." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "conditions" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "40"^^xsd:decimal ; . tosh:Rule-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate the rule so that it will not get executed." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Rule-order a sh:PropertyShape ; sh:path sh:order ; sh:description "The order of this rule relative to other rules at the same shape. Rules with lower order are executed first. Default value is 0. Rules with the same order cannot \"see\" each other's inferences." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "order" ; sh:or ( [ sh:datatype xsd:decimal ; ] [ sh:datatype xsd:integer ; ] ) ; sh:order "35"^^xsd:decimal ; . tosh:Rule-rule-inverse a sh:PropertyShape ; sh:path [ sh:inversePath sh:rule ; ] ; sh:class sh:Shape ; sh:description "The shapes or classes that the rule is attached to." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "rule of" ; sh:order "20"^^xsd:decimal ; . tosh:SHMinMaxEditor a dash:SingleEditor ; dash:hidden true ; rdfs:comment "An internally used editor for min/max range values of property shapes."^^rdf:HTML ; rdfs:label "SHACL Min Max Editor" ; . tosh:SPARQLAskExecutable-ask a sh:PropertyShape ; sh:path sh:ask ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL ASK query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "ask" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLConstraint-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactive this constraint." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:SPARQLConstraint-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message(s) that should be produced for constraint violations. The messages may contain placeholders such as {$value} for any variable returned in the SELECT clause of the SPARQL query." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "20"^^xsd:decimal ; . tosh:SPARQLConstructExecutable-construct a sh:PropertyShape ; sh:path sh:construct ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL CONSTRUCT query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "construct" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLExecutable-prefixes a sh:PropertyShape ; sh:path sh:prefixes ; sh:class owl:Ontology ; sh:description "The Ontology declaring the SHACL prefix declarations to use for the SPARQL query." ; sh:group tosh:ImplementationPropertyGroup ; sh:name "prefixes" ; sh:order "0"^^xsd:decimal ; . tosh:SPARQLSelectExecutable-select a sh:PropertyShape ; sh:path sh:select ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL SELECT query string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "select" ; sh:order "1"^^xsd:decimal ; . tosh:SPARQLUpdateExecutable-update a sh:PropertyShape ; sh:path sh:update ; dash:singleLine false ; sh:datatype xsd:string ; sh:description "The SPARQL UPDATE request string." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "update" ; sh:order "1"^^xsd:decimal ; . tosh:Script-js a sh:PropertyShape ; sh:path dash:js ; sh:datatype xsd:string ; sh:description "The implementation as JavaScript." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "JavaScript code" ; sh:order "20"^^xsd:decimal ; . tosh:Script-onAllValues a sh:PropertyShape ; sh:path dash:onAllValues ; sh:datatype xsd:boolean ; sh:description "If true then all value nodes will be available to the script at once, through the variable \"values\"." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "on all values" ; sh:order "0"^^xsd:decimal ; . tosh:ScriptConstraint-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this constraint." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:ScriptConstraint-message a sh:PropertyShape ; sh:path sh:message ; sh:description "The message(s) to use for violations produced by this script." ; sh:group tosh:DefinitionPropertyGroup ; sh:name "messages" ; sh:or dash:StringOrLangString ; sh:order "20"^^xsd:decimal ; . tosh:ScriptFunction-canWrite a sh:PropertyShape ; sh:path dash:canWrite ; sh:datatype xsd:boolean ; sh:description "True to allow this function to have side effects. By default, functions are not permitted to modify the graph as this would violate SPARQL contracts. However, if canWrite is true then the function will not be available as a SPARQL function and only be injected into the generated API in read/write mode." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "can write" ; sh:order "15"^^xsd:decimal ; . tosh:ScriptTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected result of the evaluation, as JSON object as produced by the servlet, or true or false." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "expected result" ; sh:or ( [ sh:datatype rdf:JSON ; ] [ sh:datatype xsd:boolean ; ] ) ; sh:order "0"^^xsd:decimal ; . tosh:ScriptTestCase-focusNode a sh:PropertyShape ; sh:path dash:focusNode ; sh:description "The selected resource, which will become value of focusNode for the script, with its \"most suitable\" JavaScript class as type. Defaults to the test case itself." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "focus node" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order "10"^^xsd:decimal ; . tosh:ScriptsPropertyGroup a sh:PropertyGroup ; rdfs:comment "Scripts based on Active Data Shapes." ; rdfs:label "Scripts" ; sh:order "30"^^xsd:decimal ; . tosh:Service-canWrite a sh:PropertyShape ; sh:path dash:canWrite ; sh:datatype xsd:boolean ; sh:description "True if this service can modify the data, i.e. it will execute in read/write mode. By default, all services are read-only." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "can write" ; . tosh:Service-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this service." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Service-responseContentType a sh:PropertyShape ; sh:path dash:responseContentType ; sh:datatype xsd:string ; sh:description "The content type (mime type) of the service response, defaulting to \"application/json\". Use \"void\" to return nothing." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:name "response content type" ; sh:order "10"^^xsd:decimal ; . tosh:SetToDefaultValueSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion to set the given predicate at the focus node to the default value declared at the shape that has caused the violation. Does nothing if the shape does not declare a sh:defaultValue. Deletes any old value of the property." ; rdfs:label "Set to default value suggestion generator" ; sh:message "Set to default value" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?defaultValue WHERE { GRAPH $shapesGraph { $sourceShape sh:defaultValue ?defaultValue . } }""" ; sh:update """DELETE { $focusNode $predicate ?oldValue . } INSERT { $focusNode $predicate ?defaultValue . } WHERE { OPTIONAL { $focusNode $predicate ?oldValue . } }""" ; . tosh:Shape-datatypes a sh:PropertyShape ; sh:path tosh:datatypes ; dash:neverMaterialize true ; dash:viewer tosh:DatatypesViewer ; sh:description "Zero of more datatypes that value nodes can take. In SHACL, the typical pattern is to either use a single sh:datatype or a sh:or of multiple sh:datatype constraints. This inferred property here provides a unified way to access these two design patterns." ; sh:group tosh:TypeOfValuesPropertyGroup ; sh:name "datatypes" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; sh:values [ sh:union ( [ sh:path sh:datatype ; ] [ sh:path ( sh:or [ sh:zeroOrMorePath rdf:rest ; ] rdf:first sh:datatype ) ; ] ) ; ] ; . tosh:Shape-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "True to deactivate this shape, making it literally invisible and without any effect." ; sh:group tosh:DefinitionPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "30"^^xsd:decimal ; . tosh:Shape-severity a sh:PropertyShape ; sh:path sh:severity ; dash:editor dash:InstancesSelectEditor ; sh:class sh:Severity ; sh:description "The severity to be used for validation results produced by the constraints." ; sh:group tosh:ValidationPropertyGroup ; sh:maxCount 1 ; sh:name "severity" ; sh:order "0"^^xsd:decimal ; . tosh:ShapeInGraphConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment """A constraint component that can be used to verify that the value nodes have a given shape, where the shape validation is executed in a given graph. This can, for example, be used to verify that a given value is declared as an instance of a given class in some specified (not imported) graph. A typical design pattern is as follows: ex:NodeShape sh:property [ sh:path ex:myProperty ; sh:nodeKind sh:IRI ; tosh:graph <http://example.org/externalGraph> ; tosh:shapeInGraph [ sh:class ex:ExternalClass ; ] ; tosh:editor tosh:InstancesInGraphSelectEditor ; tosh:viewer tosh:URIInGraphViewer ; ] .""" ; rdfs:label "Shape in graph constraint component" ; sh:labelTemplate "Values must have shape {$shapeInGraph} defined in graph {$graph}" ; sh:message "Value does not have shape {$shapeInGraph} defined in graph {$graph}" ; sh:parameter [ a sh:Parameter ; sh:path tosh:graph ; sh:nodeKind sh:IRI ; ] ; sh:parameter [ a sh:Parameter ; sh:path tosh:shapeInGraph ; sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { GRAPH $graph { FILTER tosh:hasShape($value, $shapeInGraph) } }""" ; sh:prefixes <http://topbraid.org/tosh> ; ] ; . tosh:StringConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "String Constraints" ; sh:order "70"^^xsd:decimal ; . tosh:SystemNamespaceShape a sh:NodeShape ; rdfs:comment "A shape that detects whether the focus node is a URI that has a namespace from one of the system namespaces - RDF, RDFS, OWL etc. The list of actual system namespaces is represented via tosh:systemNamespace true triples." ; rdfs:label "System namespace shape" ; sh:sparql [ a sh:SPARQLConstraint ; sh:message "Not a IRI from a system namespace" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this WHERE { FILTER (!isIRI($this) || (isIRI($this) && EXISTS { BIND (IRI(afn:namespace($this)) AS ?ns) . FILTER NOT EXISTS { ?ns tosh:systemNamespace true } . } )) . }""" ; ] ; . tosh:TargetsPropertyGroup a sh:PropertyGroup ; rdfs:label "Targets" ; sh:order "5"^^xsd:decimal ; . tosh:TeamworkPlatform a dash:ExecutionPlatform ; dash:includedExecutionPlatform tosh:TopBraidPlatform ; rdfs:comment "The platform consisting of TopBraid plus any teamwork features used by TopBraid EDG." ; rdfs:label "Teamwork platform" ; . tosh:TestCase-deactivated a sh:PropertyShape ; sh:path sh:deactivated ; sh:datatype xsd:boolean ; sh:description "If set to true, this test case will be skipped." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "deactivated" ; sh:order "50"^^xsd:decimal ; . tosh:TestPropertiesPropertyGroup a sh:PropertyGroup ; rdfs:label "Test Properties" ; sh:order "20"^^xsd:decimal ; . tosh:TopBraidPlatform a dash:ExecutionPlatform ; rdfs:comment "The platform consisting of TopBraid." ; rdfs:label "TopBraid platform" ; . tosh:TripleRule-object a sh:PropertyShape ; sh:path sh:object ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the object(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "object" ; sh:order 2 ; . tosh:TripleRule-predicate a sh:PropertyShape ; sh:path sh:predicate ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the predicate(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "predicate" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order 1 ; . tosh:TripleRule-subject a sh:PropertyShape ; sh:path sh:subject ; dash:viewer dash:NodeExpressionViewer ; sh:description "The node expression producing the subject(s) of the triple inferred by the rule." ; sh:group tosh:ImplementationPropertyGroup ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "subject" ; sh:nodeKind sh:BlankNodeOrIRI ; sh:order 0 ; . tosh:TypeOfValuesPropertyGroup a sh:PropertyGroup ; rdfs:label "Type of Values" ; sh:order "50"^^xsd:decimal ; . tosh:URIInGraphViewer a dash:SingleViewer ; rdfs:comment "A viewer for URI resources that have their data in a given graph that may be outside of the imports closure. The graph must be specified using a tosh:graph constraint for the property." ; rdfs:label "URI in graph viewer" ; . tosh:UseDeclaredDatatypeConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator [ a dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change datatype of the invalid value to the specified sh:datatype" ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """DELETE { $subject $predicate $object . } INSERT { $subject $predicate ?newObject . } WHERE { $subject sh:datatype ?datatype . BIND (spif:cast(?object, ?datatype) AS ?newObject) . }""" ; ] ; rdfs:comment "Constrains the value nodes to be either non-literals or literals that have the same datatype as the declared sh:datatype for the given constraint node. This is used, among others, in properties such as sh:hasValue and sh:minExclusive." ; rdfs:label | 8 | #69: work-around to suppress SLF4J warning; also other recent minor changes synchronized with TopBraid code base | 91 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
234 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Fixed a bug in tosh:isInTargetOf function related to classes that are also shapes, also: SPIN updates
<DFF> @@ -81,8 +81,6 @@ public class SH {
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
- public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
-
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
@@ -281,6 +279,8 @@ public class SH {
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
+ public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
+
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
| 2 | Fixed a bug in tosh:isInTargetOf function related to classes that are also shapes, also: SPIN updates | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
235 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Fixed a bug in tosh:isInTargetOf function related to classes that are also shapes, also: SPIN updates
<DFF> @@ -81,8 +81,6 @@ public class SH {
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
- public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
-
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
@@ -281,6 +279,8 @@ public class SH {
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
+ public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
+
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
| 2 | Fixed a bug in tosh:isInTargetOf function related to classes that are also shapes, also: SPIN updates | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
236 | <NME> TestDASHTestCases.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.util.FileUtils;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
import org.topbraid.shacl.util.SHACLSystemModel;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
List<TestCase> testCases = new LinkedList<TestCase>();
File rootFolder = new File("src/test/resources");
collectTestCases(rootFolder, testCases);
List<Object[]> results = new LinkedList<Object[]>();
for(TestCase testCase : testCases) {
results.add(new Object[]{ testCase });
}
return results;
}
private static void collectTestCases(File folder, List<TestCase> testCases) throws Exception {
for(File f : folder.listFiles()) {
if(f.isDirectory()) {
collectTestCases(f, testCases);
}
else if(f.isFile() && f.getName().endsWith(".ttl")) {
Model testModel = JenaUtil.createDefaultModel();
InputStream is = new FileInputStream(f);
testModel.read(is, "urn:dummy", FileUtils.langTurtle);
testModel.add(SHACLSystemModel.getSHACLModel());
Resource ontology = testModel.listStatements(null, OWL.imports, ResourceFactory.createResource(DASH.BASE_URI)).next().getSubject();
for(TestCaseType type : TestCaseTypes.getTypes()) {
testCases.addAll(type.getTestCases(testModel, ontology));
}
}
}
}
private TestCase testCase;
public TestDASHTestCases(TestCase testCase) {
this.testCase = testCase;
}
@Test
public void testTestCase() {
System.out.println(" - " + testCase.getResource());
Model results = JenaUtil.createMemoryModel();
try {
testCase.run(results);
}
catch(Exception ex) {
testCase.createFailure(results, "Exception during test case execution: " + ex);
ex.printStackTrace();
}
for(Statement s : results.listStatements(null, RDF.type, DASH.FailureTestCaseResult).toList()) {
String message = JenaUtil.getStringProperty(s.getSubject(), SH.resultMessage);
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(testCase.getResource() + ": " + message);
}
}
}
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(message);
}
}
}
<MSG> Latest snapshot from TopBraid code base
<DFF> @@ -118,7 +118,7 @@ public class TestDASHTestCases {
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
- Assert.fail(message);
+ Assert.fail(testCase.getResource() + ": " + message);
}
}
}
| 1 | Latest snapshot from TopBraid code base | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
237 | <NME> TestDASHTestCases.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.util.FileUtils;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.testcases.TestCase;
import org.topbraid.shacl.testcases.TestCaseType;
import org.topbraid.shacl.testcases.TestCaseTypes;
import org.topbraid.shacl.util.SHACLSystemModel;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
@RunWith(Parameterized.class)
public class TestDASHTestCases {
@Parameters(name="{0}")
public static Collection<Object[]> data() throws Exception {
List<TestCase> testCases = new LinkedList<TestCase>();
File rootFolder = new File("src/test/resources");
collectTestCases(rootFolder, testCases);
List<Object[]> results = new LinkedList<Object[]>();
for(TestCase testCase : testCases) {
results.add(new Object[]{ testCase });
}
return results;
}
private static void collectTestCases(File folder, List<TestCase> testCases) throws Exception {
for(File f : folder.listFiles()) {
if(f.isDirectory()) {
collectTestCases(f, testCases);
}
else if(f.isFile() && f.getName().endsWith(".ttl")) {
Model testModel = JenaUtil.createDefaultModel();
InputStream is = new FileInputStream(f);
testModel.read(is, "urn:dummy", FileUtils.langTurtle);
testModel.add(SHACLSystemModel.getSHACLModel());
Resource ontology = testModel.listStatements(null, OWL.imports, ResourceFactory.createResource(DASH.BASE_URI)).next().getSubject();
for(TestCaseType type : TestCaseTypes.getTypes()) {
testCases.addAll(type.getTestCases(testModel, ontology));
}
}
}
}
private TestCase testCase;
public TestDASHTestCases(TestCase testCase) {
this.testCase = testCase;
}
@Test
public void testTestCase() {
System.out.println(" - " + testCase.getResource());
Model results = JenaUtil.createMemoryModel();
try {
testCase.run(results);
}
catch(Exception ex) {
testCase.createFailure(results, "Exception during test case execution: " + ex);
ex.printStackTrace();
}
for(Statement s : results.listStatements(null, RDF.type, DASH.FailureTestCaseResult).toList()) {
String message = JenaUtil.getStringProperty(s.getSubject(), SH.resultMessage);
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(testCase.getResource() + ": " + message);
}
}
}
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
Assert.fail(message);
}
}
}
<MSG> Latest snapshot from TopBraid code base
<DFF> @@ -118,7 +118,7 @@ public class TestDASHTestCases {
if(message == null) {
message = "(No " + SH.PREFIX + ":" + SH.resultMessage.getLocalName() + " found in failure)";
}
- Assert.fail(message);
+ Assert.fail(testCase.getResource() + ": " + message);
}
}
}
| 1 | Latest snapshot from TopBraid code base | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
238 | <NME> user-name-schema.ttl
<BEF> ADDFILE
<MSG> Started test framework - some tests working
<DFF> @@ -0,0 +1,13 @@
+@prefix sh: <http://www.w3.org/ns/shacl#> .
+@prefix ex: <http://example.org/> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+ex:UserShape
+ a sh:Shape ;
+ sh:property [
+ sh:predicate foaf:name ;
+ sh:datatype xsd:string ;
+ sh:minCount 1 ;
+ ] ;
+.
| 13 | Started test framework - some tests working | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
239 | <NME> user-name-schema.ttl
<BEF> ADDFILE
<MSG> Started test framework - some tests working
<DFF> @@ -0,0 +1,13 @@
+@prefix sh: <http://www.w3.org/ns/shacl#> .
+@prefix ex: <http://example.org/> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+ex:UserShape
+ a sh:Shape ;
+ sh:property [
+ sh:predicate foaf:name ;
+ sh:datatype xsd:string ;
+ sh:minCount 1 ;
+ ] ;
+.
| 13 | Started test framework - some tests working | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
240 | <NME> ARQFactory.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.jenax.util;
import java.net.http.HttpClient;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.jena.graph.Node;
import org.apache.jena.http.HttpEnv;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.shared.PrefixMapping;
import org.apache.jena.sparql.core.DatasetImpl;
import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
import org.apache.jena.sparql.syntax.ElementNamedGraph;
import org.apache.jena.sparql.syntax.ElementVisitorBase;
import org.apache.jena.sparql.syntax.ElementWalker;
import org.apache.jena.update.UpdateRequest;
/**
* A singleton that can create ARQ SPARQL Queries and QueryExecution objects.
*
* SHACL and SPIN API users should use the provided methods here.
*
* @author Holger Knublauch
*/
public class ARQFactory {
private static ARQFactory singleton = new ARQFactory();
/**
* Caches Jena query objects for SPARQL command or expression Strings.
*/
private Map<String,Query> string2Query = new ConcurrentHashMap<>();
/**
* Caches Jena query objects for SPARQL command or expression Strings.
*/
private Map<String,UpdateRequest> string2Update = new ConcurrentHashMap<String,UpdateRequest>();
private boolean useCaches = true;
/**
* Gets the singleton instance of this class.
* @return the singleton
*/
public static ARQFactory get() {
return singleton;
}
/**
* Convenience method to get a named graph from the current ARQFactory's Dataset.
* @param graphURI the URI of the graph to get
* @return the named graph or null
*/
public static Model getNamedModel(String graphURI) {
return ARQFactory.get().getDataset(null).getNamedModel(graphURI);
}
/**
* Changes the singleton to some subclass.
* @param value the new ARQFactory (not null)
*/
public static void set(ARQFactory value) {
ARQFactory.singleton = value;
}
/**
* Can be overloaded to install extra things such as Lucene indices to all
* local QueryExecutions generated by this factory.
* Does nothing by default.
* @param qexec the QueryExecution to modify
*/
protected void adjustQueryExecution(QueryExecution qexec) {
}
/**
* Programmatically resets any cached queries.
*/
public void clearCaches() {
string2Query.clear();
string2Update.clear();
}
public Query createExpressionQuery(String expression) {
Query result = string2Query.get(expression);
if(result == null) {
String queryString = "SELECT (" + expression + ") WHERE {}";
result = doCreateQuery(queryString);
if(useCaches) {
string2Query.put(expression, result);
}
}
return result;
}
/**
* Same as <code>createPrefixDeclarations(model, true)</code>.
* @param model the Model to create prefix declarations for
* @return the prefix declarations
*/
public String createPrefixDeclarations(Model model) {
return createPrefixDeclarations(model, true);
}
/**
* Creates SPARQL prefix declarations for a given Model.
* @param model the Model to get the prefixes from
* @param includeExtraPrefixes true to also include implicit prefixes like afn
* @return the prefix declarations
*/
public String createPrefixDeclarations(Model model, boolean includeExtraPrefixes) {
StringBuffer queryString = new StringBuffer();
String defaultNamespace = JenaUtil.getNsPrefixURI(model, "");
if(defaultNamespace != null) {
queryString.append("PREFIX : <" + defaultNamespace + ">\n");
}
Map<String, String> map = model.getNsPrefixMap();
if(includeExtraPrefixes) {
Map<String,String> extraPrefixes = ExtraPrefixes.getExtraPrefixes();
for(String prefix : extraPrefixes.keySet()) {
String ns = extraPrefixes.get(prefix);
perhapsAppend(queryString, prefix, ns, map);
}
}
map.forEach((prefix,namespace) -> {
if(!prefix.isEmpty() && namespace != null) {
queryString.append("PREFIX " + prefix + ": <" + namespace + ">\n");
}
});
return queryString.toString();
}
public Query createQuery(String queryString) {
Query result = string2Query.get(queryString);
if(result == null) {
result = doCreateQuery(queryString);
if(useCaches) {
string2Query.put(queryString, result);
}
}
return result;
}
public Query doCreateQuery(String queryString) {
return doCreateQuery(queryString, null);
}
/**
* Creates the "physical" Jena Query instance.
* Can be overloaded to create engine-specific Query objects such as those
* for AllegroGraph.
* @param queryString the parsable query string
* @param prefixMapping an optional PrefixMapping to initialize the Query with
* (this object may be modified)
* @return the ARQ Query object
*/
protected Query doCreateQuery(String queryString, PrefixMapping prefixMapping) {
Query query = new Query();
if(prefixMapping != null) {
query.setPrefixMapping(prefixMapping);
}
return QueryFactory.parse(query, queryString, null, getSyntax());
}
/**
* Creates a new Query from a partial query (possibly lacking PREFIX declarations),
* using the ARQ syntax specified by <code>getSyntax</code>.
* This will also use the ExtraPrefixes, e.g. for function definitions.
* @param model the Model to use the prefixes from
* @param partialQuery the (partial) query string
* @return the Query
*/
public Query createQuery(Model model, String partialQuery) {
PrefixMapping pm = ExtraPrefixes.createPrefixMappingWithExtraPrefixes(model);
return doCreateQuery(partialQuery, pm);
}
/**
* Creates a new Query from a partial query (possibly lacking PREFIX declarations),
* using the ARQ syntax specified by <code>getSyntax</code>.
* @param partialQuery the (partial) query string
* @param prefixMapping the PrefixMapping to use
* @return the Query
*/
public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping pm) {
return doCreateQuery(partialQuery, pm);
}
/**
* Creates a QueryExecution for a given Query in a given Model,
* with no initial bindings.
* The implementation basically uses Jena's QueryExecutionFactory
* but with the option to use different Dataset as specified by
* <code>getDataset(model)</code>.
* @param query the Query
* @param model the Model to query
* @return a QueryExecution
*/
public QueryExecution createQueryExecution(Query query, Model model) {
return createQueryExecution(query, model, null);
}
/**
* Creates a QueryExecution for a given Query in a given Model, with
* some given initial bindings.
* The implementation basically uses Jena's QueryExecutionFactory
* but with the option to use different Dataset as specified by
* <code>getDataset(model)</code>.
* @param query the Query
* @param model the Model to query
* @param initialBinding the initial variable bindings or null
* @return a QueryExecution
*/
public QueryExecution createQueryExecution(Query query, Model model, QuerySolution initialBinding) {
Dataset dataset = getDataset(model);
if(dataset == null) {
dataset = DatasetFactory.create(model);
}
return createQueryExecution(query, dataset, initialBinding);
}
public QueryExecution createQueryExecution(Query query, Dataset dataset) {
return createQueryExecution(query, dataset, null);
}
/** Fine-grained control for development : switch on and off query printing */
public static boolean LOG_QUERIES = false;
public QueryExecution createQueryExecution(Query query, Dataset dataset, QuerySolution initialBinding) {
if(!query.getGraphURIs().isEmpty() || !query.getNamedGraphURIs().isEmpty()) {
dataset = new FromDataset(dataset, query);
}
if ( LOG_QUERIES ) {
// And the data - can be long.
// System.err.println("~~ ~~");
// RDFDataMgr.write(System.err, dataset.getDefaultModel(), Lang.TTL);
System.err.println("~~ ~~");
System.err.println(initialBinding);
System.err.println(query);
}
QueryExecution qexec = QueryExecutionFactoryFilter.get().create(query, dataset, initialBinding);
adjustQueryExecution(qexec);
return qexec;
}
/**
* Creates a remote QueryExecution on a given Query.
* @param query the Query to execute
* @return a remote QueryExecution
*/
public QueryExecutionHTTP createRemoteQueryExecution(Query query) {
List<String> graphURIs = query.getGraphURIs();
return createRemoteQueryExecution(query, graphURIs);
}
public QueryExecutionHTTP createRemoteQueryExecution(Query query, List<String> graphURIs) {
String service = graphURIs.get(0);
String serviceAsURI = service;
if(service.endsWith("/sparql")) {
serviceAsURI = service.substring(0, service.lastIndexOf('/'));
}
return createRemoteQueryExecution(service, query, Collections.singletonList(serviceAsURI), graphURIs, null, null);
}
public QueryExecutionHTTP createRemoteQueryExecution(
String service,
Query query,
List<String> defaultGraphURIs,
List<String> namedGraphURIs,
String user,
String password) {
HttpClient httpClient = buildHttpClient(user, password);
return QueryExecutionFactoryFilter.get().sparqlService(service, query, httpClient, defaultGraphURIs, namedGraphURIs);
}
public static HttpClient buildHttpClient(String user, String password) {
return (user == null) ?
HttpEnv.getDftHttpClient() :
HttpEnv.httpClientBuilder()
.authenticator(BasicAuthenticator.with(user, password))
.build();
}
public UpdateRequest createUpdateRequest(String parsableString) {
UpdateRequest result = string2Update.get(parsableString);
if(result == null) {
result = UpdateFactoryFilter.get().create(parsableString);
if(useCaches) {
string2Update.put(parsableString, result);
}
}
return result;
}
/**
* Specifies a Dataset that shall be used for query execution.
* Returns a new DatasetImpl by default but may be overloaded in subclasses.
* For example, TopBraid delegates this to the currently open Graphs.
* @param defaultModel the default Model of the Dataset
* @return the Dataset
*/
public Dataset getDataset(Model defaultModel) {
if(defaultModel != null) {
return new DatasetImpl(defaultModel);
}
else {
return new DatasetImpl(JenaUtil.createMemoryModel());
}
}
/**
* Gets a list of named graphs (GRAPH elements) mentioned in a given
* Query.
* @param query the Query to traverse
* @return a List of those GRAPHs
*/
public static List<String> getNamedGraphURIs(Query query) {
final List<String> results = new LinkedList<String>();
ElementWalker.walk(query.getQueryPattern(), new ElementVisitorBase() {
@Override
public void visit(ElementNamedGraph el) {
Node node = el.getGraphNameNode();
if(node != null && node.isURI()) {
String uri = node.getURI();
if(!results.contains(uri)) {
results.add(uri);
}
}
}
});
return results;
}
/**
* The ARQ Syntax used by default: Syntax.syntaxARQ.
* @return the default syntax
*/
public Syntax getSyntax() {
return Syntax.syntaxARQ;
}
public boolean isUsingCaches() {
return useCaches;
}
private static void perhapsAppend(StringBuffer queryString, String prefix, String namespace, Map<String,String> map) {
if(!map.containsKey(prefix) && namespace != null) {
queryString.append("PREFIX ");
queryString.append(prefix);
queryString.append(": <");
queryString.append(namespace);
queryString.append(">\n");
}
}
/**
* Tells the ARQFactory whether to use caches for the various createXY functions.
* These are on by default.
* Warning: there may be memory leaks if the first executed query of its kind keeps a reference to a
* E_Function which keeps a reference to a Function, and FunctionBase to a FunctionEnv with an active graph.
* @param value false to switch caches off
*/
public void setUseCaches(boolean value) {
this.useCaches = value;
}
}
<MSG> Fixed documentation mismatch
<DFF> @@ -223,8 +223,8 @@ public class ARQFactory {
* @param prefixMapping the PrefixMapping to use
* @return the Query
*/
- public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping pm) {
- return doCreateQuery(partialQuery, pm);
+ public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping prefixMapping) {
+ return doCreateQuery(partialQuery, prefixMapping);
}
| 2 | Fixed documentation mismatch | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
241 | <NME> ARQFactory.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.jenax.util;
import java.net.http.HttpClient;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.jena.graph.Node;
import org.apache.jena.http.HttpEnv;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.shared.PrefixMapping;
import org.apache.jena.sparql.core.DatasetImpl;
import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
import org.apache.jena.sparql.syntax.ElementNamedGraph;
import org.apache.jena.sparql.syntax.ElementVisitorBase;
import org.apache.jena.sparql.syntax.ElementWalker;
import org.apache.jena.update.UpdateRequest;
/**
* A singleton that can create ARQ SPARQL Queries and QueryExecution objects.
*
* SHACL and SPIN API users should use the provided methods here.
*
* @author Holger Knublauch
*/
public class ARQFactory {
private static ARQFactory singleton = new ARQFactory();
/**
* Caches Jena query objects for SPARQL command or expression Strings.
*/
private Map<String,Query> string2Query = new ConcurrentHashMap<>();
/**
* Caches Jena query objects for SPARQL command or expression Strings.
*/
private Map<String,UpdateRequest> string2Update = new ConcurrentHashMap<String,UpdateRequest>();
private boolean useCaches = true;
/**
* Gets the singleton instance of this class.
* @return the singleton
*/
public static ARQFactory get() {
return singleton;
}
/**
* Convenience method to get a named graph from the current ARQFactory's Dataset.
* @param graphURI the URI of the graph to get
* @return the named graph or null
*/
public static Model getNamedModel(String graphURI) {
return ARQFactory.get().getDataset(null).getNamedModel(graphURI);
}
/**
* Changes the singleton to some subclass.
* @param value the new ARQFactory (not null)
*/
public static void set(ARQFactory value) {
ARQFactory.singleton = value;
}
/**
* Can be overloaded to install extra things such as Lucene indices to all
* local QueryExecutions generated by this factory.
* Does nothing by default.
* @param qexec the QueryExecution to modify
*/
protected void adjustQueryExecution(QueryExecution qexec) {
}
/**
* Programmatically resets any cached queries.
*/
public void clearCaches() {
string2Query.clear();
string2Update.clear();
}
public Query createExpressionQuery(String expression) {
Query result = string2Query.get(expression);
if(result == null) {
String queryString = "SELECT (" + expression + ") WHERE {}";
result = doCreateQuery(queryString);
if(useCaches) {
string2Query.put(expression, result);
}
}
return result;
}
/**
* Same as <code>createPrefixDeclarations(model, true)</code>.
* @param model the Model to create prefix declarations for
* @return the prefix declarations
*/
public String createPrefixDeclarations(Model model) {
return createPrefixDeclarations(model, true);
}
/**
* Creates SPARQL prefix declarations for a given Model.
* @param model the Model to get the prefixes from
* @param includeExtraPrefixes true to also include implicit prefixes like afn
* @return the prefix declarations
*/
public String createPrefixDeclarations(Model model, boolean includeExtraPrefixes) {
StringBuffer queryString = new StringBuffer();
String defaultNamespace = JenaUtil.getNsPrefixURI(model, "");
if(defaultNamespace != null) {
queryString.append("PREFIX : <" + defaultNamespace + ">\n");
}
Map<String, String> map = model.getNsPrefixMap();
if(includeExtraPrefixes) {
Map<String,String> extraPrefixes = ExtraPrefixes.getExtraPrefixes();
for(String prefix : extraPrefixes.keySet()) {
String ns = extraPrefixes.get(prefix);
perhapsAppend(queryString, prefix, ns, map);
}
}
map.forEach((prefix,namespace) -> {
if(!prefix.isEmpty() && namespace != null) {
queryString.append("PREFIX " + prefix + ": <" + namespace + ">\n");
}
});
return queryString.toString();
}
public Query createQuery(String queryString) {
Query result = string2Query.get(queryString);
if(result == null) {
result = doCreateQuery(queryString);
if(useCaches) {
string2Query.put(queryString, result);
}
}
return result;
}
public Query doCreateQuery(String queryString) {
return doCreateQuery(queryString, null);
}
/**
* Creates the "physical" Jena Query instance.
* Can be overloaded to create engine-specific Query objects such as those
* for AllegroGraph.
* @param queryString the parsable query string
* @param prefixMapping an optional PrefixMapping to initialize the Query with
* (this object may be modified)
* @return the ARQ Query object
*/
protected Query doCreateQuery(String queryString, PrefixMapping prefixMapping) {
Query query = new Query();
if(prefixMapping != null) {
query.setPrefixMapping(prefixMapping);
}
return QueryFactory.parse(query, queryString, null, getSyntax());
}
/**
* Creates a new Query from a partial query (possibly lacking PREFIX declarations),
* using the ARQ syntax specified by <code>getSyntax</code>.
* This will also use the ExtraPrefixes, e.g. for function definitions.
* @param model the Model to use the prefixes from
* @param partialQuery the (partial) query string
* @return the Query
*/
public Query createQuery(Model model, String partialQuery) {
PrefixMapping pm = ExtraPrefixes.createPrefixMappingWithExtraPrefixes(model);
return doCreateQuery(partialQuery, pm);
}
/**
* Creates a new Query from a partial query (possibly lacking PREFIX declarations),
* using the ARQ syntax specified by <code>getSyntax</code>.
* @param partialQuery the (partial) query string
* @param prefixMapping the PrefixMapping to use
* @return the Query
*/
public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping pm) {
return doCreateQuery(partialQuery, pm);
}
/**
* Creates a QueryExecution for a given Query in a given Model,
* with no initial bindings.
* The implementation basically uses Jena's QueryExecutionFactory
* but with the option to use different Dataset as specified by
* <code>getDataset(model)</code>.
* @param query the Query
* @param model the Model to query
* @return a QueryExecution
*/
public QueryExecution createQueryExecution(Query query, Model model) {
return createQueryExecution(query, model, null);
}
/**
* Creates a QueryExecution for a given Query in a given Model, with
* some given initial bindings.
* The implementation basically uses Jena's QueryExecutionFactory
* but with the option to use different Dataset as specified by
* <code>getDataset(model)</code>.
* @param query the Query
* @param model the Model to query
* @param initialBinding the initial variable bindings or null
* @return a QueryExecution
*/
public QueryExecution createQueryExecution(Query query, Model model, QuerySolution initialBinding) {
Dataset dataset = getDataset(model);
if(dataset == null) {
dataset = DatasetFactory.create(model);
}
return createQueryExecution(query, dataset, initialBinding);
}
public QueryExecution createQueryExecution(Query query, Dataset dataset) {
return createQueryExecution(query, dataset, null);
}
/** Fine-grained control for development : switch on and off query printing */
public static boolean LOG_QUERIES = false;
public QueryExecution createQueryExecution(Query query, Dataset dataset, QuerySolution initialBinding) {
if(!query.getGraphURIs().isEmpty() || !query.getNamedGraphURIs().isEmpty()) {
dataset = new FromDataset(dataset, query);
}
if ( LOG_QUERIES ) {
// And the data - can be long.
// System.err.println("~~ ~~");
// RDFDataMgr.write(System.err, dataset.getDefaultModel(), Lang.TTL);
System.err.println("~~ ~~");
System.err.println(initialBinding);
System.err.println(query);
}
QueryExecution qexec = QueryExecutionFactoryFilter.get().create(query, dataset, initialBinding);
adjustQueryExecution(qexec);
return qexec;
}
/**
* Creates a remote QueryExecution on a given Query.
* @param query the Query to execute
* @return a remote QueryExecution
*/
public QueryExecutionHTTP createRemoteQueryExecution(Query query) {
List<String> graphURIs = query.getGraphURIs();
return createRemoteQueryExecution(query, graphURIs);
}
public QueryExecutionHTTP createRemoteQueryExecution(Query query, List<String> graphURIs) {
String service = graphURIs.get(0);
String serviceAsURI = service;
if(service.endsWith("/sparql")) {
serviceAsURI = service.substring(0, service.lastIndexOf('/'));
}
return createRemoteQueryExecution(service, query, Collections.singletonList(serviceAsURI), graphURIs, null, null);
}
public QueryExecutionHTTP createRemoteQueryExecution(
String service,
Query query,
List<String> defaultGraphURIs,
List<String> namedGraphURIs,
String user,
String password) {
HttpClient httpClient = buildHttpClient(user, password);
return QueryExecutionFactoryFilter.get().sparqlService(service, query, httpClient, defaultGraphURIs, namedGraphURIs);
}
public static HttpClient buildHttpClient(String user, String password) {
return (user == null) ?
HttpEnv.getDftHttpClient() :
HttpEnv.httpClientBuilder()
.authenticator(BasicAuthenticator.with(user, password))
.build();
}
public UpdateRequest createUpdateRequest(String parsableString) {
UpdateRequest result = string2Update.get(parsableString);
if(result == null) {
result = UpdateFactoryFilter.get().create(parsableString);
if(useCaches) {
string2Update.put(parsableString, result);
}
}
return result;
}
/**
* Specifies a Dataset that shall be used for query execution.
* Returns a new DatasetImpl by default but may be overloaded in subclasses.
* For example, TopBraid delegates this to the currently open Graphs.
* @param defaultModel the default Model of the Dataset
* @return the Dataset
*/
public Dataset getDataset(Model defaultModel) {
if(defaultModel != null) {
return new DatasetImpl(defaultModel);
}
else {
return new DatasetImpl(JenaUtil.createMemoryModel());
}
}
/**
* Gets a list of named graphs (GRAPH elements) mentioned in a given
* Query.
* @param query the Query to traverse
* @return a List of those GRAPHs
*/
public static List<String> getNamedGraphURIs(Query query) {
final List<String> results = new LinkedList<String>();
ElementWalker.walk(query.getQueryPattern(), new ElementVisitorBase() {
@Override
public void visit(ElementNamedGraph el) {
Node node = el.getGraphNameNode();
if(node != null && node.isURI()) {
String uri = node.getURI();
if(!results.contains(uri)) {
results.add(uri);
}
}
}
});
return results;
}
/**
* The ARQ Syntax used by default: Syntax.syntaxARQ.
* @return the default syntax
*/
public Syntax getSyntax() {
return Syntax.syntaxARQ;
}
public boolean isUsingCaches() {
return useCaches;
}
private static void perhapsAppend(StringBuffer queryString, String prefix, String namespace, Map<String,String> map) {
if(!map.containsKey(prefix) && namespace != null) {
queryString.append("PREFIX ");
queryString.append(prefix);
queryString.append(": <");
queryString.append(namespace);
queryString.append(">\n");
}
}
/**
* Tells the ARQFactory whether to use caches for the various createXY functions.
* These are on by default.
* Warning: there may be memory leaks if the first executed query of its kind keeps a reference to a
* E_Function which keeps a reference to a Function, and FunctionBase to a FunctionEnv with an active graph.
* @param value false to switch caches off
*/
public void setUseCaches(boolean value) {
this.useCaches = value;
}
}
<MSG> Fixed documentation mismatch
<DFF> @@ -223,8 +223,8 @@ public class ARQFactory {
* @param prefixMapping the PrefixMapping to use
* @return the Query
*/
- public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping pm) {
- return doCreateQuery(partialQuery, pm);
+ public Query createQueryWithPrefixMapping(String partialQuery, PrefixMapping prefixMapping) {
+ return doCreateQuery(partialQuery, prefixMapping);
}
| 2 | Fixed documentation mismatch | 2 | .java | java | apache-2.0 | TopQuadrant/shacl |
242 | <NME> ValidateTestClass.java
<BEF> ADDFILE
<MSG> Added support for Validate test, renamed SHACL class to SH
<DFF> @@ -0,0 +1,20 @@
+package org.topbraid.shacl;
+
+import org.topbraid.shacl.constraints.ModelConstraintValidator;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+public class ValidateTestClass extends AbstractSHACLTestClass {
+
+ public ValidateTestClass(Resource testResource) {
+ super(testResource);
+ }
+
+
+ public void testRun() throws Exception {
+ Model results = ModelConstraintValidator.get().validateModel(createDataset(),
+ getShapesGraphURI(), null, false, null);
+ compareResults(results);
+ }
+}
| 20 | Added support for Validate test, renamed SHACL class to SH | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
243 | <NME> ValidateTestClass.java
<BEF> ADDFILE
<MSG> Added support for Validate test, renamed SHACL class to SH
<DFF> @@ -0,0 +1,20 @@
+package org.topbraid.shacl;
+
+import org.topbraid.shacl.constraints.ModelConstraintValidator;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+public class ValidateTestClass extends AbstractSHACLTestClass {
+
+ public ValidateTestClass(Resource testResource) {
+ super(testResource);
+ }
+
+
+ public void testRun() throws Exception {
+ Model results = ModelConstraintValidator.get().validateModel(createDataset(),
+ getShapesGraphURI(), null, false, null);
+ compareResults(results);
+ }
+}
| 20 | Added support for Validate test, renamed SHACL class to SH | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
244 | <NME> ValidationEngine.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.rdf.model.*;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.util.ExceptionUtil;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.arq.SHACLPaths;
import org.topbraid.shacl.engine.*;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.js.SHACLScriptEngineManager;
import org.topbraid.shacl.util.FailureLog;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.sparql.path.eval.PathEval;
import org.apache.jena.sparql.util.Context;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
import java.net.URI;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* A ValidationEngine uses a given shapes graph (represented via an instance of VShapesGraph)
* and performs SHACL validation on a given Dataset.
import org.topbraid.shacl.engine.AbstractEngine;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.engine.SHACLScriptEngineManager;
import org.topbraid.shacl.engine.Shape;
import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.expr.NodeExpression;
import org.topbraid.shacl.expr.NodeExpressionFactory;
import org.topbraid.shacl.model.SHNodeShape;
import org.topbraid.shacl.model.SHPropertyShape;
import org.topbraid.shacl.targets.InstancesTarget;
import org.topbraid.shacl.targets.Target;
import org.topbraid.shacl.util.FailureLog;
import org.topbraid.shacl.util.SHACLPreferences;
import org.topbraid.shacl.util.SHACLUtil;
import org.topbraid.shacl.validation.sparql.SPARQLSubstitutions;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
/**
private Predicate<RDFNode> focusNodeFilter;
private Function<RDFNode,String> labelFunction = (node -> node.toString());
private Resource report;
public class ValidationEngine extends AbstractEngine {
// The currently active ValidationEngine for cases where no direct pointer can be acquired, e.g. from HasShapeFunction
private static ThreadLocal<ValidationEngine> current = new ThreadLocal<>();
public static ValidationEngine getCurrent() {
return current.get();
}
public static void setCurrent(ValidationEngine value) {
current.set(value);
}
// Avoids repeatedly walking up/down the class hierarchy for sh:class constraints
private ClassesCache classesCache;
private ValidationEngineConfiguration configuration;
// Can be used to drop certain focus nodes from validation
private Predicate<RDFNode> focusNodeFilter;
// The inferred triples if the shapes graph declares an entailment regime
private Model inferencesModel;
// The label function for rendering nodes in validation results (message templates etc)
private Function<RDFNode,String> labelFunction = (node -> RDFLabels.get().getNodeLabel(node));
// Avoids repeatedly fetching labels
private Map<RDFNode,String> labelsCache = new ConcurrentHashMap<>();
// Can be used to collect statistical data about execution time of constraint components and shapes
private ValidationProfile profile;
// The resulting validation report instance
private Resource report;
// Number of created results, e.g. for progress monitor
private int resultsCount = 0;
// Avoids repeatedly fetching the value nodes of a focus node / path combination
private Map<ValueNodesCacheKey,Collection<RDFNode>> valueNodes = new WeakHashMap<>();
// Number of created violations, e.g. for progress monitor
private int violationsCount = 0;
/**
* Constructs a new ValidationEngine.
* @param dataset the Dataset to operate on
* @param shapesGraphURI the URI of the shapes graph (must be in the dataset)
* @param shapesGraph the ShapesGraph with the shapes to validate against
* @param report the sh:ValidationReport object in the results Model, or null to create a new one
*/
protected ValidationEngine(Dataset dataset, URI shapesGraphURI, ShapesGraph shapesGraph, Resource report) {
super(dataset, shapesGraph, shapesGraphURI);
setConfiguration(new ValidationEngineConfiguration());
if(report == null) {
Model reportModel = JenaUtil.createMemoryModel();
reportModel.setNsPrefixes(dataset.getDefaultModel()); // This can be very expensive in some databases
reportModel.withDefaultMappings(shapesGraph.getShapesModel());
this.report = reportModel.createResource(SH.ValidationReport);
}
else {
this.report = report;
}
}
/**
* Checks if entailments are active for the current shapes graph and applies them for a given focus node.
* This will only work for the sh:Rules entailment, e.g. to compute sh:values and sh:defaultValue.
* If any inferred triples exist, the focus node will be returned attached to the model that includes those inferences.
* The dataset used internally will also be switched to use that new model as its default model, so that if
* a node gets validated it will "see" the inferred triples too.
* @param focusNode the focus node
* @return the focus node, possibly in a different Model than originally
*/
public RDFNode applyEntailments(Resource focusNode) {
Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString());
if(shapesModel.contains(null, SH.entailment, SH.Rules)) {
// Create union of data model and inferences if called for the first time
if(inferencesModel == null) {
inferencesModel = JenaUtil.createDefaultModel();
Model dataModel = dataset.getDefaultModel();
MultiUnion multiUnion = new MultiUnion(new Graph[]{
dataModel.getGraph(),
inferencesModel.getGraph()
});
multiUnion.setBaseGraph(dataModel.getGraph());
dataset.setDefaultModel(ModelFactory.createModelForGraph(multiUnion));
}
// Apply sh:values rules
Map<Property,RDFNode> defaultValueMap = new HashMap<>();
for(SHNodeShape nodeShape : SHACLUtil.getAllShapesAtNode(focusNode)) {
if(!nodeShape.hasProperty(SH.deactivated, JenaDatatypes.TRUE)) {
for(SHPropertyShape ps : nodeShape.getPropertyShapes()) {
if(!ps.hasProperty(SH.deactivated, JenaDatatypes.TRUE)) {
Resource path = ps.getPath();
if(path instanceof Resource) {
Statement values = ps.getProperty(SH.values);
if(values != null) {
NodeExpression ne = NodeExpressionFactory.get().create(values.getObject());
ne.eval(focusNode, this).forEachRemaining(v -> inferencesModel.getGraph().add(Triple.create(focusNode.asNode(), path.asNode(), v.asNode())));
}
Statement defaultValue = ps.getProperty(SH.defaultValue);
if(defaultValue != null) {
defaultValueMap.put(JenaUtil.asProperty(path), defaultValue.getObject());
}
}
}
}
}
}
// Add sh:defaultValue where needed
Model dataModel = dataset.getDefaultModel(); // This is now the union model
Resource newFocusNode = focusNode.inModel(dataModel);
for(Property predicate : defaultValueMap.keySet()) {
if(!newFocusNode.hasProperty(predicate)) {
NodeExpression ne = NodeExpressionFactory.get().create(defaultValueMap.get(predicate));
ne.eval(focusNode, this).forEachRemaining(v -> inferencesModel.add(focusNode, predicate, v));
}
}
return newFocusNode;
}
return focusNode;
}
public void addResultMessage(Resource result, Literal message, QuerySolution bindings) {
result.addProperty(SH.resultMessage, SPARQLSubstitutions.withSubstitutions(message, bindings, getLabelFunction()));
}
// Note: does not set sh:path
public Resource createResult(Resource type, Constraint constraint, RDFNode focusNode) {
Resource result = report.getModel().createResource(type);
report.addProperty(SH.result, result);
result.addProperty(SH.resultSeverity, constraint.getSeverity());
result.addProperty(SH.sourceConstraintComponent, constraint.getComponent());
result.addProperty(SH.sourceShape, constraint.getShapeResource());
if(focusNode != null) {
result.addProperty(SH.focusNode, focusNode);
}
checkMaximumNumberFailures(constraint);
resultsCount++;
return result;
}
public Resource createValidationResult(Constraint constraint, RDFNode focusNode, RDFNode value, Supplier<String> defaultMessage) {
Resource result = createResult(SH.ValidationResult, constraint, focusNode);
if(value != null) {
result.addProperty(SH.value, value);
}
if(!constraint.getShape().isNodeShape()) {
result.addProperty(SH.resultPath, SHACLPaths.clonePath(constraint.getShapeResource().getPath(), result.getModel()));
}
Collection<RDFNode> messages = constraint.getMessages();
if(messages.size() > 0) {
messages.stream().forEach(message -> result.addProperty(SH.resultMessage, message));
}
else if(defaultMessage != null) {
String m = defaultMessage.get();
if(m != null) {
result.addProperty(SH.resultMessage, m);
}
}
return result;
}
private void checkMaximumNumberFailures(Constraint constraint) {
if (SH.Violation.equals(constraint.getShape().getSeverity())) {
this.violationsCount++;
if (configuration.getValidationErrorBatch() != -1 && violationsCount >= configuration.getValidationErrorBatch()) {
throw new MaximumNumberViolations(violationsCount);
}
}
}
public ClassesCache getClassesCache() {
return classesCache;
}
public ValidationEngineConfiguration getConfiguration() {
return configuration;
}
public String getLabel(RDFNode node) {
return labelsCache.computeIfAbsent(node, n -> getLabelFunction().apply(n));
}
public Function<RDFNode,String> getLabelFunction() {
return labelFunction;
}
public ValidationProfile getProfile() {
return profile;
}
/**
* Gets the validation report as a Resource in the report Model.
* @return the report Resource
*/
public Resource getReport() {
return report;
}
/**
* Gets a Set of all shapes that should be evaluated for a given resource.
* @param focusNode the focus node to get the shapes for
* @param dataset the Dataset containing the resource
* @param shapesModel the shapes Model
* @return a Set of shape resources
*/
private Set<Resource> getShapesForNode(RDFNode focusNode, Dataset dataset, Model shapesModel) {
Set<Resource> shapes = new HashSet<>();
for(Shape rootShape : shapesGraph.getRootShapes()) {
for(Target target : rootShape.getTargets()) {
if(!(target instanceof InstancesTarget)) {
if(target.contains(dataset, focusNode)) {
shapes.add(rootShape.getShapeResource());
}
}
}
}
// rdf:type / sh:targetClass
if(focusNode instanceof Resource) {
for(Resource type : JenaUtil.getAllTypes((Resource)focusNode)) {
if(JenaUtil.hasIndirectType(type.inModel(shapesModel), SH.Shape)) {
shapes.add(type);
}
for(Statement s : shapesModel.listStatements(null, SH.targetClass, type).toList()) {
shapes.add(s.getSubject());
}
}
}
return shapes;
}
public ValidationReport getValidationReport() {
return new ResourceValidationReport(report);
}
public Collection<RDFNode> getValueNodes(Constraint constraint, RDFNode focusNode) {
if(constraint.getShape().isNodeShape()) {
return Collections.singletonList(focusNode);
}
else {
// We use a cache here because many shapes contains for example both sh:datatype and sh:minCount, and fetching
// the value nodes each time may be expensive, esp for sh:minCount/maxCount constraints.
ValueNodesCacheKey key = new ValueNodesCacheKey(focusNode, constraint.getShape().getPath());
return valueNodes.computeIfAbsent(key, k -> getValueNodesHelper(focusNode, constraint));
}
}
private Collection<RDFNode> getValueNodesHelper(RDFNode focusNode, Constraint constraint) {
Property predicate = constraint.getShape().getPredicate();
if(predicate != null) {
List<RDFNode> results = new LinkedList<>();
if(focusNode instanceof Resource) {
Iterator<Statement> it = ((Resource)focusNode).listProperties(predicate);
while(it.hasNext()) {
results.add(it.next().getObject());
}
}
return results;
}
else {
Path jenaPath = constraint.getShape().getJenaPath();
if(jenaPath instanceof P_Inverse && ((P_Inverse)jenaPath).getSubPath() instanceof P_Link) {
List<RDFNode> results = new LinkedList<>();
Property inversePredicate = ResourceFactory.createProperty(((P_Link)((P_Inverse)jenaPath).getSubPath()).getNode().getURI());
Iterator<Statement> it = focusNode.getModel().listStatements(null, inversePredicate, focusNode);
while(it.hasNext()) {
results.add(it.next().getSubject());
}
return results;
}
Set<RDFNode> results = new HashSet<>();
Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), jenaPath, Context.emptyContext());
while(it.hasNext()) {
Node node = it.next();
results.add(focusNode.getModel().asRDFNode(node));
}
return results;
}
}
/**
* Validates a given list of focus nodes against a given Shape, and stops as soon
* as one validation result is reported. No results are recorded.
* @param focusNodes the nodes to validate
* @param shape the sh:Shape to validate against
* @return true if there were no validation results, false for violations
*/
public boolean nodesConformToShape(List<RDFNode> focusNodes, Node shape) {
if(!shapesGraph.isIgnored(shape)) {
Resource oldReport = report;
report = JenaUtil.createMemoryModel().createResource();
try {
Shape vs = shapesGraph.getShape(shape);
if(!vs.isDeactivated()) {
boolean nested = SHACLScriptEngineManager.get().begin();
try {
for(Constraint constraint : vs.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
if(report.hasProperty(SH.result)) {
return false;
}
}
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
}
}
finally {
this.report = oldReport;
}
}
return true;
}
public void setClassesCache(ClassesCache value) {
this.classesCache = value;
}
/**
* Sets a filter that can be used to skip certain focus node from validation.
* The filter must return true if the given candidate focus node shall be validated,
* and false to skip it.
* @param value the new filter
*/
public void setFocusNodeFilter(Predicate<RDFNode> value) {
this.focusNodeFilter = value;
}
public void setLabelFunction(Function<RDFNode,String> value) {
this.labelFunction = value;
}
public void updateConforms() {
boolean conforms = true;
StmtIterator it = report.listProperties(SH.result);
while(it.hasNext()) {
Statement s = it.next();
if(s.getResource().hasProperty(RDF.type, SH.ValidationResult)) {
conforms = false;
it.close();
break;
}
}
if(report.hasProperty(SH.conforms)) {
report.removeAll(SH.conforms);
}
report.addProperty(SH.conforms, conforms ? JenaDatatypes.TRUE : JenaDatatypes.FALSE);
}
/**
* Validates all target nodes against all of their shapes.
* To further narrow down which nodes to validate, use {@link #setFocusNodeFilter(Predicate)}.
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateAll() throws InterruptedException {
List<Shape> rootShapes = shapesGraph.getRootShapes();
return validateShapes(rootShapes);
}
/**
* Validates a given focus node against all of the shapes that have matching targets.
* @param focusNode the node to validate
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateNode(Node focusNode) throws InterruptedException {
Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString());
RDFNode focusRDFNode = dataset.getDefaultModel().asRDFNode(focusNode);
Set<Resource> shapes = getShapesForNode(focusRDFNode, dataset, shapesModel);
boolean nested = SHACLScriptEngineManager.get().begin();
try {
for(Resource shape : shapes) {
if(monitor != null && monitor.isCanceled()) {
throw new InterruptedException();
}
validateNodesAgainstShape(Collections.singletonList(focusRDFNode), shape.asNode());
}
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
return report;
}
/**
* Validates a given list of focus node against a given Shape.
* @param focusNodes the nodes to validate
* @param shape the sh:Shape to validate against
* @return an instance of sh:ValidationReport in the results Model
*/
public Resource validateNodesAgainstShape(List<RDFNode> focusNodes, Node shape) {
if(!shapesGraph.isIgnored(shape)) {
Shape vs = shapesGraph.getShape(shape);
if(!vs.isDeactivated()) {
boolean nested = SHACLScriptEngineManager.get().begin();
ValidationEngine oldEngine = current.get();
current.set(this);
try {
for(Constraint constraint : vs.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
}
}
finally {
current.set(oldEngine);
SHACLScriptEngineManager.get().end(nested);
}
}
}
return report;
}
/**
* Validates all target nodes of a given collection of shapes against these shapes.
* To further narrow down which nodes to validate, use {@link #setFocusNodeFilter(Predicate)}.
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateShapes(Collection<Shape> shapes) throws InterruptedException {
boolean nested = SHACLScriptEngineManager.get().begin();
try {
if(monitor != null) {
monitor.beginTask("Validating " + shapes.size() + " shapes", shapes.size());
}
if(classesCache == null) {
// If we are doing everything then the cache should be used, but not for validation of individual focus nodes
classesCache = new ClassesCache();
}
int i = 0;
for(Shape shape : shapes) {
if(monitor != null) {
String label = "Shape " + (++i) + ": " + getLabelFunction().apply(shape.getShapeResource());
if(resultsCount > 0) {
label = "" + resultsCount + " results. " + label;
}
monitor.subTask(label);
}
Collection<RDFNode> focusNodes = shape.getTargetNodes(dataset);
if(focusNodeFilter != null) {
List<RDFNode> filteredFocusNodes = new LinkedList<>();
for(RDFNode focusNode : focusNodes) {
if(focusNodeFilter.test(focusNode)) {
filteredFocusNodes.add(focusNode);
}
}
focusNodes = filteredFocusNodes;
}
if(!focusNodes.isEmpty()) {
for(Constraint constraint : shape.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
}
}
if(monitor != null) {
monitor.worked(1);
if(monitor.isCanceled()) {
throw new InterruptedException();
}
}
}
}
catch(MaximumNumberViolations ex) {
// Ignore as this is just our way to stop validation when max number of violations is reached
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
updateConforms();
return report;
}
protected void validateNodesAgainstConstraint(Collection<RDFNode> focusNodes, Constraint constraint) {
if(configuration != null && configuration.isSkippedConstraintComponent(constraint.getComponent())) {
return;
}
ConstraintExecutor executor;
try {
executor = constraint.getExecutor();
}
catch(Exception ex) {
Resource result = createResult(DASH.FailureResult, constraint, constraint.getShapeResource());
result.addProperty(SH.resultMessage, "Failed to create validator: " + ExceptionUtil.getStackTrace(ex));
return;
}
if(executor != null) {
if(SHACLPreferences.isProduceFailuresMode()) {
try {
executor.executeConstraint(constraint, this, focusNodes);
}
catch(Exception ex) {
Resource result = createResult(DASH.FailureResult, constraint, constraint.getShapeResource());
result.addProperty(SH.resultMessage, "Exception during validation: " + ExceptionUtil.getStackTrace(ex));
}
}
else {
executor.executeConstraint(constraint, this, focusNodes);
}
}
else {
FailureLog.get().logWarning("No suitable validator found for constraint " + constraint);
}
}
public void setConfiguration(ValidationEngineConfiguration configuration) {
this.configuration = configuration;
if(!configuration.getValidateShapes()) {
shapesGraph.setShapeFilter(new ExcludeMetaShapesFilter());
}
}
public void setProfile(ValidationProfile profile) {
this.profile = profile;
}
// Used to avoid repeated computation of value nodes for a focus node / path combination
private static class ValueNodesCacheKey {
Resource path;
RDFNode focusNode;
ValueNodesCacheKey(RDFNode focusNode, Resource path) {
this.path = path;
this.focusNode = focusNode;
}
public boolean equals(Object o) {
if(o instanceof ValueNodesCacheKey) {
return path.equals(((ValueNodesCacheKey)o).path) && focusNode.equals(((ValueNodesCacheKey)o).focusNode);
}
else {
return false;
}
}
@Override
public int hashCode() {
return path.hashCode() + focusNode.hashCode();
}
@Override
public String toString() {
return focusNode.toString() + " . " + path;
}
}
}
<MSG> #58 made RDFLabels function the default
<DFF> @@ -16,17 +16,36 @@
*/
package org.topbraid.shacl.validation;
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
-import org.apache.jena.rdf.model.*;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.util.ExceptionUtil;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
+import org.topbraid.jenax.util.RDFLabels;
import org.topbraid.shacl.arq.SHACLPaths;
-import org.topbraid.shacl.engine.*;
+import org.topbraid.shacl.engine.AbstractEngine;
+import org.topbraid.shacl.engine.ConfigurableEngine;
+import org.topbraid.shacl.engine.Constraint;
+import org.topbraid.shacl.engine.Shape;
+import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.js.SHACLScriptEngineManager;
import org.topbraid.shacl.util.FailureLog;
@@ -36,11 +55,6 @@ import org.topbraid.shacl.validation.sparql.SPARQLSubstitutions;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
-import java.net.URI;
-import java.util.*;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
/**
* A ValidationEngine uses a given shapes graph (represented via an instance of VShapesGraph)
* and performs SHACL validation on a given Dataset.
@@ -67,7 +81,7 @@ public class ValidationEngine extends AbstractEngine implements ConfigurableEngi
private Predicate<RDFNode> focusNodeFilter;
- private Function<RDFNode,String> labelFunction = (node -> node.toString());
+ private Function<RDFNode,String> labelFunction = (node -> RDFLabels.get().getNodeLabel(node));
private Resource report;
| 22 | #58 made RDFLabels function the default | 8 | .java | java | apache-2.0 | TopQuadrant/shacl |
245 | <NME> ValidationEngine.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.validation;
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.rdf.model.*;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.util.ExceptionUtil;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.arq.SHACLPaths;
import org.topbraid.shacl.engine.*;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.js.SHACLScriptEngineManager;
import org.topbraid.shacl.util.FailureLog;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.sparql.path.eval.PathEval;
import org.apache.jena.sparql.util.Context;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
import java.net.URI;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* A ValidationEngine uses a given shapes graph (represented via an instance of VShapesGraph)
* and performs SHACL validation on a given Dataset.
import org.topbraid.shacl.engine.AbstractEngine;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.engine.SHACLScriptEngineManager;
import org.topbraid.shacl.engine.Shape;
import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.expr.NodeExpression;
import org.topbraid.shacl.expr.NodeExpressionFactory;
import org.topbraid.shacl.model.SHNodeShape;
import org.topbraid.shacl.model.SHPropertyShape;
import org.topbraid.shacl.targets.InstancesTarget;
import org.topbraid.shacl.targets.Target;
import org.topbraid.shacl.util.FailureLog;
import org.topbraid.shacl.util.SHACLPreferences;
import org.topbraid.shacl.util.SHACLUtil;
import org.topbraid.shacl.validation.sparql.SPARQLSubstitutions;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
/**
private Predicate<RDFNode> focusNodeFilter;
private Function<RDFNode,String> labelFunction = (node -> node.toString());
private Resource report;
public class ValidationEngine extends AbstractEngine {
// The currently active ValidationEngine for cases where no direct pointer can be acquired, e.g. from HasShapeFunction
private static ThreadLocal<ValidationEngine> current = new ThreadLocal<>();
public static ValidationEngine getCurrent() {
return current.get();
}
public static void setCurrent(ValidationEngine value) {
current.set(value);
}
// Avoids repeatedly walking up/down the class hierarchy for sh:class constraints
private ClassesCache classesCache;
private ValidationEngineConfiguration configuration;
// Can be used to drop certain focus nodes from validation
private Predicate<RDFNode> focusNodeFilter;
// The inferred triples if the shapes graph declares an entailment regime
private Model inferencesModel;
// The label function for rendering nodes in validation results (message templates etc)
private Function<RDFNode,String> labelFunction = (node -> RDFLabels.get().getNodeLabel(node));
// Avoids repeatedly fetching labels
private Map<RDFNode,String> labelsCache = new ConcurrentHashMap<>();
// Can be used to collect statistical data about execution time of constraint components and shapes
private ValidationProfile profile;
// The resulting validation report instance
private Resource report;
// Number of created results, e.g. for progress monitor
private int resultsCount = 0;
// Avoids repeatedly fetching the value nodes of a focus node / path combination
private Map<ValueNodesCacheKey,Collection<RDFNode>> valueNodes = new WeakHashMap<>();
// Number of created violations, e.g. for progress monitor
private int violationsCount = 0;
/**
* Constructs a new ValidationEngine.
* @param dataset the Dataset to operate on
* @param shapesGraphURI the URI of the shapes graph (must be in the dataset)
* @param shapesGraph the ShapesGraph with the shapes to validate against
* @param report the sh:ValidationReport object in the results Model, or null to create a new one
*/
protected ValidationEngine(Dataset dataset, URI shapesGraphURI, ShapesGraph shapesGraph, Resource report) {
super(dataset, shapesGraph, shapesGraphURI);
setConfiguration(new ValidationEngineConfiguration());
if(report == null) {
Model reportModel = JenaUtil.createMemoryModel();
reportModel.setNsPrefixes(dataset.getDefaultModel()); // This can be very expensive in some databases
reportModel.withDefaultMappings(shapesGraph.getShapesModel());
this.report = reportModel.createResource(SH.ValidationReport);
}
else {
this.report = report;
}
}
/**
* Checks if entailments are active for the current shapes graph and applies them for a given focus node.
* This will only work for the sh:Rules entailment, e.g. to compute sh:values and sh:defaultValue.
* If any inferred triples exist, the focus node will be returned attached to the model that includes those inferences.
* The dataset used internally will also be switched to use that new model as its default model, so that if
* a node gets validated it will "see" the inferred triples too.
* @param focusNode the focus node
* @return the focus node, possibly in a different Model than originally
*/
public RDFNode applyEntailments(Resource focusNode) {
Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString());
if(shapesModel.contains(null, SH.entailment, SH.Rules)) {
// Create union of data model and inferences if called for the first time
if(inferencesModel == null) {
inferencesModel = JenaUtil.createDefaultModel();
Model dataModel = dataset.getDefaultModel();
MultiUnion multiUnion = new MultiUnion(new Graph[]{
dataModel.getGraph(),
inferencesModel.getGraph()
});
multiUnion.setBaseGraph(dataModel.getGraph());
dataset.setDefaultModel(ModelFactory.createModelForGraph(multiUnion));
}
// Apply sh:values rules
Map<Property,RDFNode> defaultValueMap = new HashMap<>();
for(SHNodeShape nodeShape : SHACLUtil.getAllShapesAtNode(focusNode)) {
if(!nodeShape.hasProperty(SH.deactivated, JenaDatatypes.TRUE)) {
for(SHPropertyShape ps : nodeShape.getPropertyShapes()) {
if(!ps.hasProperty(SH.deactivated, JenaDatatypes.TRUE)) {
Resource path = ps.getPath();
if(path instanceof Resource) {
Statement values = ps.getProperty(SH.values);
if(values != null) {
NodeExpression ne = NodeExpressionFactory.get().create(values.getObject());
ne.eval(focusNode, this).forEachRemaining(v -> inferencesModel.getGraph().add(Triple.create(focusNode.asNode(), path.asNode(), v.asNode())));
}
Statement defaultValue = ps.getProperty(SH.defaultValue);
if(defaultValue != null) {
defaultValueMap.put(JenaUtil.asProperty(path), defaultValue.getObject());
}
}
}
}
}
}
// Add sh:defaultValue where needed
Model dataModel = dataset.getDefaultModel(); // This is now the union model
Resource newFocusNode = focusNode.inModel(dataModel);
for(Property predicate : defaultValueMap.keySet()) {
if(!newFocusNode.hasProperty(predicate)) {
NodeExpression ne = NodeExpressionFactory.get().create(defaultValueMap.get(predicate));
ne.eval(focusNode, this).forEachRemaining(v -> inferencesModel.add(focusNode, predicate, v));
}
}
return newFocusNode;
}
return focusNode;
}
public void addResultMessage(Resource result, Literal message, QuerySolution bindings) {
result.addProperty(SH.resultMessage, SPARQLSubstitutions.withSubstitutions(message, bindings, getLabelFunction()));
}
// Note: does not set sh:path
public Resource createResult(Resource type, Constraint constraint, RDFNode focusNode) {
Resource result = report.getModel().createResource(type);
report.addProperty(SH.result, result);
result.addProperty(SH.resultSeverity, constraint.getSeverity());
result.addProperty(SH.sourceConstraintComponent, constraint.getComponent());
result.addProperty(SH.sourceShape, constraint.getShapeResource());
if(focusNode != null) {
result.addProperty(SH.focusNode, focusNode);
}
checkMaximumNumberFailures(constraint);
resultsCount++;
return result;
}
public Resource createValidationResult(Constraint constraint, RDFNode focusNode, RDFNode value, Supplier<String> defaultMessage) {
Resource result = createResult(SH.ValidationResult, constraint, focusNode);
if(value != null) {
result.addProperty(SH.value, value);
}
if(!constraint.getShape().isNodeShape()) {
result.addProperty(SH.resultPath, SHACLPaths.clonePath(constraint.getShapeResource().getPath(), result.getModel()));
}
Collection<RDFNode> messages = constraint.getMessages();
if(messages.size() > 0) {
messages.stream().forEach(message -> result.addProperty(SH.resultMessage, message));
}
else if(defaultMessage != null) {
String m = defaultMessage.get();
if(m != null) {
result.addProperty(SH.resultMessage, m);
}
}
return result;
}
private void checkMaximumNumberFailures(Constraint constraint) {
if (SH.Violation.equals(constraint.getShape().getSeverity())) {
this.violationsCount++;
if (configuration.getValidationErrorBatch() != -1 && violationsCount >= configuration.getValidationErrorBatch()) {
throw new MaximumNumberViolations(violationsCount);
}
}
}
public ClassesCache getClassesCache() {
return classesCache;
}
public ValidationEngineConfiguration getConfiguration() {
return configuration;
}
public String getLabel(RDFNode node) {
return labelsCache.computeIfAbsent(node, n -> getLabelFunction().apply(n));
}
public Function<RDFNode,String> getLabelFunction() {
return labelFunction;
}
public ValidationProfile getProfile() {
return profile;
}
/**
* Gets the validation report as a Resource in the report Model.
* @return the report Resource
*/
public Resource getReport() {
return report;
}
/**
* Gets a Set of all shapes that should be evaluated for a given resource.
* @param focusNode the focus node to get the shapes for
* @param dataset the Dataset containing the resource
* @param shapesModel the shapes Model
* @return a Set of shape resources
*/
private Set<Resource> getShapesForNode(RDFNode focusNode, Dataset dataset, Model shapesModel) {
Set<Resource> shapes = new HashSet<>();
for(Shape rootShape : shapesGraph.getRootShapes()) {
for(Target target : rootShape.getTargets()) {
if(!(target instanceof InstancesTarget)) {
if(target.contains(dataset, focusNode)) {
shapes.add(rootShape.getShapeResource());
}
}
}
}
// rdf:type / sh:targetClass
if(focusNode instanceof Resource) {
for(Resource type : JenaUtil.getAllTypes((Resource)focusNode)) {
if(JenaUtil.hasIndirectType(type.inModel(shapesModel), SH.Shape)) {
shapes.add(type);
}
for(Statement s : shapesModel.listStatements(null, SH.targetClass, type).toList()) {
shapes.add(s.getSubject());
}
}
}
return shapes;
}
public ValidationReport getValidationReport() {
return new ResourceValidationReport(report);
}
public Collection<RDFNode> getValueNodes(Constraint constraint, RDFNode focusNode) {
if(constraint.getShape().isNodeShape()) {
return Collections.singletonList(focusNode);
}
else {
// We use a cache here because many shapes contains for example both sh:datatype and sh:minCount, and fetching
// the value nodes each time may be expensive, esp for sh:minCount/maxCount constraints.
ValueNodesCacheKey key = new ValueNodesCacheKey(focusNode, constraint.getShape().getPath());
return valueNodes.computeIfAbsent(key, k -> getValueNodesHelper(focusNode, constraint));
}
}
private Collection<RDFNode> getValueNodesHelper(RDFNode focusNode, Constraint constraint) {
Property predicate = constraint.getShape().getPredicate();
if(predicate != null) {
List<RDFNode> results = new LinkedList<>();
if(focusNode instanceof Resource) {
Iterator<Statement> it = ((Resource)focusNode).listProperties(predicate);
while(it.hasNext()) {
results.add(it.next().getObject());
}
}
return results;
}
else {
Path jenaPath = constraint.getShape().getJenaPath();
if(jenaPath instanceof P_Inverse && ((P_Inverse)jenaPath).getSubPath() instanceof P_Link) {
List<RDFNode> results = new LinkedList<>();
Property inversePredicate = ResourceFactory.createProperty(((P_Link)((P_Inverse)jenaPath).getSubPath()).getNode().getURI());
Iterator<Statement> it = focusNode.getModel().listStatements(null, inversePredicate, focusNode);
while(it.hasNext()) {
results.add(it.next().getSubject());
}
return results;
}
Set<RDFNode> results = new HashSet<>();
Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), jenaPath, Context.emptyContext());
while(it.hasNext()) {
Node node = it.next();
results.add(focusNode.getModel().asRDFNode(node));
}
return results;
}
}
/**
* Validates a given list of focus nodes against a given Shape, and stops as soon
* as one validation result is reported. No results are recorded.
* @param focusNodes the nodes to validate
* @param shape the sh:Shape to validate against
* @return true if there were no validation results, false for violations
*/
public boolean nodesConformToShape(List<RDFNode> focusNodes, Node shape) {
if(!shapesGraph.isIgnored(shape)) {
Resource oldReport = report;
report = JenaUtil.createMemoryModel().createResource();
try {
Shape vs = shapesGraph.getShape(shape);
if(!vs.isDeactivated()) {
boolean nested = SHACLScriptEngineManager.get().begin();
try {
for(Constraint constraint : vs.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
if(report.hasProperty(SH.result)) {
return false;
}
}
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
}
}
finally {
this.report = oldReport;
}
}
return true;
}
public void setClassesCache(ClassesCache value) {
this.classesCache = value;
}
/**
* Sets a filter that can be used to skip certain focus node from validation.
* The filter must return true if the given candidate focus node shall be validated,
* and false to skip it.
* @param value the new filter
*/
public void setFocusNodeFilter(Predicate<RDFNode> value) {
this.focusNodeFilter = value;
}
public void setLabelFunction(Function<RDFNode,String> value) {
this.labelFunction = value;
}
public void updateConforms() {
boolean conforms = true;
StmtIterator it = report.listProperties(SH.result);
while(it.hasNext()) {
Statement s = it.next();
if(s.getResource().hasProperty(RDF.type, SH.ValidationResult)) {
conforms = false;
it.close();
break;
}
}
if(report.hasProperty(SH.conforms)) {
report.removeAll(SH.conforms);
}
report.addProperty(SH.conforms, conforms ? JenaDatatypes.TRUE : JenaDatatypes.FALSE);
}
/**
* Validates all target nodes against all of their shapes.
* To further narrow down which nodes to validate, use {@link #setFocusNodeFilter(Predicate)}.
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateAll() throws InterruptedException {
List<Shape> rootShapes = shapesGraph.getRootShapes();
return validateShapes(rootShapes);
}
/**
* Validates a given focus node against all of the shapes that have matching targets.
* @param focusNode the node to validate
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateNode(Node focusNode) throws InterruptedException {
Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString());
RDFNode focusRDFNode = dataset.getDefaultModel().asRDFNode(focusNode);
Set<Resource> shapes = getShapesForNode(focusRDFNode, dataset, shapesModel);
boolean nested = SHACLScriptEngineManager.get().begin();
try {
for(Resource shape : shapes) {
if(monitor != null && monitor.isCanceled()) {
throw new InterruptedException();
}
validateNodesAgainstShape(Collections.singletonList(focusRDFNode), shape.asNode());
}
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
return report;
}
/**
* Validates a given list of focus node against a given Shape.
* @param focusNodes the nodes to validate
* @param shape the sh:Shape to validate against
* @return an instance of sh:ValidationReport in the results Model
*/
public Resource validateNodesAgainstShape(List<RDFNode> focusNodes, Node shape) {
if(!shapesGraph.isIgnored(shape)) {
Shape vs = shapesGraph.getShape(shape);
if(!vs.isDeactivated()) {
boolean nested = SHACLScriptEngineManager.get().begin();
ValidationEngine oldEngine = current.get();
current.set(this);
try {
for(Constraint constraint : vs.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
}
}
finally {
current.set(oldEngine);
SHACLScriptEngineManager.get().end(nested);
}
}
}
return report;
}
/**
* Validates all target nodes of a given collection of shapes against these shapes.
* To further narrow down which nodes to validate, use {@link #setFocusNodeFilter(Predicate)}.
* @return an instance of sh:ValidationReport in the results Model
* @throws InterruptedException if the monitor has canceled this
*/
public Resource validateShapes(Collection<Shape> shapes) throws InterruptedException {
boolean nested = SHACLScriptEngineManager.get().begin();
try {
if(monitor != null) {
monitor.beginTask("Validating " + shapes.size() + " shapes", shapes.size());
}
if(classesCache == null) {
// If we are doing everything then the cache should be used, but not for validation of individual focus nodes
classesCache = new ClassesCache();
}
int i = 0;
for(Shape shape : shapes) {
if(monitor != null) {
String label = "Shape " + (++i) + ": " + getLabelFunction().apply(shape.getShapeResource());
if(resultsCount > 0) {
label = "" + resultsCount + " results. " + label;
}
monitor.subTask(label);
}
Collection<RDFNode> focusNodes = shape.getTargetNodes(dataset);
if(focusNodeFilter != null) {
List<RDFNode> filteredFocusNodes = new LinkedList<>();
for(RDFNode focusNode : focusNodes) {
if(focusNodeFilter.test(focusNode)) {
filteredFocusNodes.add(focusNode);
}
}
focusNodes = filteredFocusNodes;
}
if(!focusNodes.isEmpty()) {
for(Constraint constraint : shape.getConstraints()) {
validateNodesAgainstConstraint(focusNodes, constraint);
}
}
if(monitor != null) {
monitor.worked(1);
if(monitor.isCanceled()) {
throw new InterruptedException();
}
}
}
}
catch(MaximumNumberViolations ex) {
// Ignore as this is just our way to stop validation when max number of violations is reached
}
finally {
SHACLScriptEngineManager.get().end(nested);
}
updateConforms();
return report;
}
protected void validateNodesAgainstConstraint(Collection<RDFNode> focusNodes, Constraint constraint) {
if(configuration != null && configuration.isSkippedConstraintComponent(constraint.getComponent())) {
return;
}
ConstraintExecutor executor;
try {
executor = constraint.getExecutor();
}
catch(Exception ex) {
Resource result = createResult(DASH.FailureResult, constraint, constraint.getShapeResource());
result.addProperty(SH.resultMessage, "Failed to create validator: " + ExceptionUtil.getStackTrace(ex));
return;
}
if(executor != null) {
if(SHACLPreferences.isProduceFailuresMode()) {
try {
executor.executeConstraint(constraint, this, focusNodes);
}
catch(Exception ex) {
Resource result = createResult(DASH.FailureResult, constraint, constraint.getShapeResource());
result.addProperty(SH.resultMessage, "Exception during validation: " + ExceptionUtil.getStackTrace(ex));
}
}
else {
executor.executeConstraint(constraint, this, focusNodes);
}
}
else {
FailureLog.get().logWarning("No suitable validator found for constraint " + constraint);
}
}
public void setConfiguration(ValidationEngineConfiguration configuration) {
this.configuration = configuration;
if(!configuration.getValidateShapes()) {
shapesGraph.setShapeFilter(new ExcludeMetaShapesFilter());
}
}
public void setProfile(ValidationProfile profile) {
this.profile = profile;
}
// Used to avoid repeated computation of value nodes for a focus node / path combination
private static class ValueNodesCacheKey {
Resource path;
RDFNode focusNode;
ValueNodesCacheKey(RDFNode focusNode, Resource path) {
this.path = path;
this.focusNode = focusNode;
}
public boolean equals(Object o) {
if(o instanceof ValueNodesCacheKey) {
return path.equals(((ValueNodesCacheKey)o).path) && focusNode.equals(((ValueNodesCacheKey)o).focusNode);
}
else {
return false;
}
}
@Override
public int hashCode() {
return path.hashCode() + focusNode.hashCode();
}
@Override
public String toString() {
return focusNode.toString() + " . " + path;
}
}
}
<MSG> #58 made RDFLabels function the default
<DFF> @@ -16,17 +16,36 @@
*/
package org.topbraid.shacl.validation;
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
import org.apache.jena.graph.Node;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
-import org.apache.jena.rdf.model.*;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.sparql.path.Path;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.jenax.util.ExceptionUtil;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
+import org.topbraid.jenax.util.RDFLabels;
import org.topbraid.shacl.arq.SHACLPaths;
-import org.topbraid.shacl.engine.*;
+import org.topbraid.shacl.engine.AbstractEngine;
+import org.topbraid.shacl.engine.ConfigurableEngine;
+import org.topbraid.shacl.engine.Constraint;
+import org.topbraid.shacl.engine.Shape;
+import org.topbraid.shacl.engine.ShapesGraph;
import org.topbraid.shacl.engine.filters.ExcludeMetaShapesFilter;
import org.topbraid.shacl.js.SHACLScriptEngineManager;
import org.topbraid.shacl.util.FailureLog;
@@ -36,11 +55,6 @@ import org.topbraid.shacl.validation.sparql.SPARQLSubstitutions;
import org.topbraid.shacl.vocabulary.DASH;
import org.topbraid.shacl.vocabulary.SH;
-import java.net.URI;
-import java.util.*;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
/**
* A ValidationEngine uses a given shapes graph (represented via an instance of VShapesGraph)
* and performs SHACL validation on a given Dataset.
@@ -67,7 +81,7 @@ public class ValidationEngine extends AbstractEngine implements ConfigurableEngi
private Predicate<RDFNode> focusNodeFilter;
- private Function<RDFNode,String> labelFunction = (node -> node.toString());
+ private Function<RDFNode,String> labelFunction = (node -> RDFLabels.get().getNodeLabel(node));
private Resource report;
| 22 | #58 made RDFLabels function the default | 8 | .java | java | apache-2.0 | TopQuadrant/shacl |
246 | <NME> scope-003.ttl
<BEF> ADDFILE
<MSG> Several fixes related to sh:scope handling. Switched to a property function, preventing variable scoping issues and adding flexibility for non-SPARQL scopes
<DFF> @@ -0,0 +1,53 @@
+# baseURI: http://www.w3.org/ns/shacl/test/features/core/scope-003
+
+@prefix ex: <http://example.org/> .
+@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#> .
+
+<>
+ a sh:Graph ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+
+# Shapes ----------------------------------------------------------------------
+
+ex:MyShape
+ a sh:Shape ;
+ sh:scope [
+ a sh:PropertyScope ;
+ sh:predicate ex:myProperty ;
+ ] ;
+ sh:scopeClass ex:MyClass ;
+ sh:property [
+ sh:predicate ex:myProperty ;
+ sh:maxCount 1 ;
+ ] ;
+.
+
+# Instances -------------------------------------------------------------------
+
+ex:MyClass
+ a rdfs:Class ;
+.
+
+ex:ValidInstance1
+ a ex:MyClass ;
+ ex:myProperty "A" ;
+.
+
+ex:ValidInstance2
+ ex:myProperty "A" ;
+.
+
+ex:InvalidInstance1
+ a ex:MyClass ;
+ ex:myProperty "A" ;
+ ex:myProperty "B" ;
+.
+
+ex:InvalidInstance2
+ ex:myProperty "A" ;
+ ex:myProperty "B" ;
+.
| 53 | Several fixes related to sh:scope handling. Switched to a property function, preventing variable scoping issues and adding flexibility for non-SPARQL scopes | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
247 | <NME> scope-003.ttl
<BEF> ADDFILE
<MSG> Several fixes related to sh:scope handling. Switched to a property function, preventing variable scoping issues and adding flexibility for non-SPARQL scopes
<DFF> @@ -0,0 +1,53 @@
+# baseURI: http://www.w3.org/ns/shacl/test/features/core/scope-003
+
+@prefix ex: <http://example.org/> .
+@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#> .
+
+<>
+ a sh:Graph ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+
+# Shapes ----------------------------------------------------------------------
+
+ex:MyShape
+ a sh:Shape ;
+ sh:scope [
+ a sh:PropertyScope ;
+ sh:predicate ex:myProperty ;
+ ] ;
+ sh:scopeClass ex:MyClass ;
+ sh:property [
+ sh:predicate ex:myProperty ;
+ sh:maxCount 1 ;
+ ] ;
+.
+
+# Instances -------------------------------------------------------------------
+
+ex:MyClass
+ a rdfs:Class ;
+.
+
+ex:ValidInstance1
+ a ex:MyClass ;
+ ex:myProperty "A" ;
+.
+
+ex:ValidInstance2
+ ex:myProperty "A" ;
+.
+
+ex:InvalidInstance1
+ a ex:MyClass ;
+ ex:myProperty "A" ;
+ ex:myProperty "B" ;
+.
+
+ex:InvalidInstance2
+ ex:myProperty "A" ;
+ ex:myProperty "B" ;
+.
| 53 | Several fixes related to sh:scope handling. Switched to a property function, preventing variable scoping issues and adding flexibility for non-SPARQL scopes | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
248 | <NME> ClosedConstraintExecutor.java
<BEF> package org.topbraid.shacl.validation.java;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.rdf.model.RDFList;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.validation.AbstractNativeConstraintExecutor;
import org.topbraid.shacl.validation.ValidationEngine;
import org.topbraid.shacl.vocabulary.SH;
/**
* Validator for sh:closed constraints.
*
* @author Holger Knublauch
*/
class ClosedConstraintExecutor extends AbstractNativeConstraintExecutor {
private Set<RDFNode> allowedProperties = new HashSet<>();
private boolean closed;
ClosedConstraintExecutor(Constraint constraint) {
this.closed = constraint.getShapeResource().hasProperty(SH.closed, JenaDatatypes.TRUE);
RDFList list = JenaUtil.getListProperty(constraint.getShapeResource(), SH.ignoredProperties);
if(list != null) {
list.iterator().forEachRemaining(allowedProperties::add);
}
for(Resource ps : JenaUtil.getResourceProperties(constraint.getShapeResource(), SH.property)) {
Resource path = ps.getPropertyResourceValue(SH.path);
if(path.isURIResource()) {
allowedProperties.add(path);
}
}
}
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
Resource result = engine.createValidationResult(constraint, focusNode, s.getObject(), () -> "Unexpected value for property " + engine.getLabelFunction().apply(s.getPredicate()));
result.removeAll(SH.resultPath);
result.addProperty(SH.resultPath, s.getPredicate());
}
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());
}
}
}
engine.checkCanceled();
}
addStatistics(engine, constraint, startTime, focusNodes.size(), focusNodes.size());
}
}
}
<MSG> restore closed shape message
<DFF> @@ -48,7 +48,7 @@ class ClosedConstraintExecutor extends AbstractNativeConstraintExecutor {
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
- Resource result = engine.createValidationResult(constraint, focusNode, s.getObject(), () -> "Unexpected value for property " + engine.getLabelFunction().apply(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());
}
| 1 | restore closed shape message | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
249 | <NME> ClosedConstraintExecutor.java
<BEF> package org.topbraid.shacl.validation.java;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.rdf.model.RDFList;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import org.topbraid.jenax.util.JenaDatatypes;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.validation.AbstractNativeConstraintExecutor;
import org.topbraid.shacl.validation.ValidationEngine;
import org.topbraid.shacl.vocabulary.SH;
/**
* Validator for sh:closed constraints.
*
* @author Holger Knublauch
*/
class ClosedConstraintExecutor extends AbstractNativeConstraintExecutor {
private Set<RDFNode> allowedProperties = new HashSet<>();
private boolean closed;
ClosedConstraintExecutor(Constraint constraint) {
this.closed = constraint.getShapeResource().hasProperty(SH.closed, JenaDatatypes.TRUE);
RDFList list = JenaUtil.getListProperty(constraint.getShapeResource(), SH.ignoredProperties);
if(list != null) {
list.iterator().forEachRemaining(allowedProperties::add);
}
for(Resource ps : JenaUtil.getResourceProperties(constraint.getShapeResource(), SH.property)) {
Resource path = ps.getPropertyResourceValue(SH.path);
if(path.isURIResource()) {
allowedProperties.add(path);
}
}
}
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
Resource result = engine.createValidationResult(constraint, focusNode, s.getObject(), () -> "Unexpected value for property " + engine.getLabelFunction().apply(s.getPredicate()));
result.removeAll(SH.resultPath);
result.addProperty(SH.resultPath, s.getPredicate());
}
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());
}
}
}
engine.checkCanceled();
}
addStatistics(engine, constraint, startTime, focusNodes.size(), focusNodes.size());
}
}
}
<MSG> restore closed shape message
<DFF> @@ -48,7 +48,7 @@ class ClosedConstraintExecutor extends AbstractNativeConstraintExecutor {
while(it.hasNext()) {
Statement s = it.next();
if(!allowedProperties.contains(s.getPredicate())) {
- Resource result = engine.createValidationResult(constraint, focusNode, s.getObject(), () -> "Unexpected value for property " + engine.getLabelFunction().apply(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());
}
| 1 | restore closed shape message | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
250 | <NME> ValidationExample.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
import org.topbraid.spin.util.JenaUtil;
public class ValidationExample {
/**
* Loads an example SHACL file and validates all focus nodes against all shapes.
*/
public static void main(String[] args) throws Exception {
// Load the main data model
Model dataModel = JenaUtil.createMemoryModel();
dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
// Perform the validation of everything, using the data model
// also as the shapes model - you may have them separated
Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
// Print violations
System.out.println(ModelPrinter.get().print(report.getModel()));
}
}
<MSG> Towards release 1.1.0: Removed dependency on SPIN code
<DFF> @@ -19,9 +19,9 @@ package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
+import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
-import org.topbraid.spin.util.JenaUtil;
public class ValidationExample {
| 1 | Towards release 1.1.0: Removed dependency on SPIN code | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
251 | <NME> ValidationExample.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
import org.topbraid.spin.util.JenaUtil;
public class ValidationExample {
/**
* Loads an example SHACL file and validates all focus nodes against all shapes.
*/
public static void main(String[] args) throws Exception {
// Load the main data model
Model dataModel = JenaUtil.createMemoryModel();
dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
// Perform the validation of everything, using the data model
// also as the shapes model - you may have them separated
Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
// Print violations
System.out.println(ModelPrinter.get().print(report.getModel()));
}
}
<MSG> Towards release 1.1.0: Removed dependency on SPIN code
<DFF> @@ -19,9 +19,9 @@ package org.topbraid.shacl;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileUtils;
+import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.util.ModelPrinter;
import org.topbraid.shacl.validation.ValidationUtil;
-import org.topbraid.spin.util.JenaUtil;
public class ValidationExample {
| 1 | Towards release 1.1.0: Removed dependency on SPIN code | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
252 | <NME> shaclvalidate.sh
<BEF> #!/bin/sh
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
resolveLink() {
local NAME=$1
if [ -L "$NAME" ]; then
case "$OSTYPE" in
darwin*|bsd*)
# BSD style readlink behaves differently to GNU readlink
# Have to manually follow links
while [ -L "$NAME" ]; do
NAME=$( cd $NAME && pwd -P ) ;
done
;;
*)
# Assuming standard GNU readlink with -f for
# canonicalize and follow
NAME=$(readlink -f "$NAME")
;;
esac
fi
echo "$NAME"
}
# If SHACL_HOME is empty
if [ -z "$SHACL_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
SCRIPT=$(resolveLink "$0")
# If link is relative
case "$SCRIPT" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SCRIPT=$( dirname "$0" )/$SCRIPT
;;
esac
fi
# Work out root from script location
SHACL_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
export SHACL_HOME
fi
# If SHACL_HOME is a symbolic link need to resolve
if [ -L "${SHACL_HOME}" ]; then
SHACL_HOME=$(resolveLink "$SHACL_HOME")
# If link is relative
case "$SHACL_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SHACL_HOME=$(dirname "$SHACL_HOME")
;;
esac
export SHACL_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
# Expand SHACL_HOME but literal *
SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
CYGWIN*) SHACL_CP="$(cygpath -wp "$SHACL_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
# important for tdbloader spill
if [ -n "$TMPDIR" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMPDIR\""
elif [ -n "$TMP" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
java $JVM_ARGS $LOGGING -cp "$SHACL_CP" org.topbraid.shacl.tools.Validate "$@"
<MSG> #130: Updated config to log4j2
<DFF> @@ -68,7 +68,7 @@ fi
# Expand SHACL_HOME but literal *
SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
-LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
+LOGGING="${LOGGING:--Dlog4j.configurationFile=file:$SHACL_HOME/log4j2.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
| 1 | #130: Updated config to log4j2 | 1 | .sh | sh | apache-2.0 | TopQuadrant/shacl |
253 | <NME> shaclvalidate.sh
<BEF> #!/bin/sh
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
resolveLink() {
local NAME=$1
if [ -L "$NAME" ]; then
case "$OSTYPE" in
darwin*|bsd*)
# BSD style readlink behaves differently to GNU readlink
# Have to manually follow links
while [ -L "$NAME" ]; do
NAME=$( cd $NAME && pwd -P ) ;
done
;;
*)
# Assuming standard GNU readlink with -f for
# canonicalize and follow
NAME=$(readlink -f "$NAME")
;;
esac
fi
echo "$NAME"
}
# If SHACL_HOME is empty
if [ -z "$SHACL_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
SCRIPT=$(resolveLink "$0")
# If link is relative
case "$SCRIPT" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SCRIPT=$( dirname "$0" )/$SCRIPT
;;
esac
fi
# Work out root from script location
SHACL_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
export SHACL_HOME
fi
# If SHACL_HOME is a symbolic link need to resolve
if [ -L "${SHACL_HOME}" ]; then
SHACL_HOME=$(resolveLink "$SHACL_HOME")
# If link is relative
case "$SHACL_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SHACL_HOME=$(dirname "$SHACL_HOME")
;;
esac
export SHACL_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
# Expand SHACL_HOME but literal *
SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
CYGWIN*) SHACL_CP="$(cygpath -wp "$SHACL_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
# important for tdbloader spill
if [ -n "$TMPDIR" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMPDIR\""
elif [ -n "$TMP" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
java $JVM_ARGS $LOGGING -cp "$SHACL_CP" org.topbraid.shacl.tools.Validate "$@"
<MSG> #130: Updated config to log4j2
<DFF> @@ -68,7 +68,7 @@ fi
# Expand SHACL_HOME but literal *
SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
-LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
+LOGGING="${LOGGING:--Dlog4j.configurationFile=file:$SHACL_HOME/log4j2.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
| 1 | #130: Updated config to log4j2 | 1 | .sh | sh | apache-2.0 | TopQuadrant/shacl |
254 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Property final_ = ResourceFactory.createProperty(NS + "final");
public final static Property graph = ResourceFactory.createProperty(NS + "graph");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property root = ResourceFactory.createProperty(NS + "root");
public final static Property scope = ResourceFactory.createProperty(NS + "scope");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property source = ResourceFactory.createProperty(NS + "source");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public static final Var predicateVar = Var.alloc(predicate.getLocalName());
public static final Var rootVar = Var.alloc(root.getLocalName());
public static final Var severityVar = Var.alloc(severity.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Latest spec changes about result format (sh:root -> sh:focusNode, sh:source -> sh:sourceConstraint and sh:sourceShape), generalized sh:severity
<DFF> @@ -102,6 +102,8 @@ public class SH {
public final static Property final_ = ResourceFactory.createProperty(NS + "final");
+ public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
+
public final static Property graph = ResourceFactory.createProperty(NS + "graph");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
@@ -145,8 +147,6 @@ public class SH {
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
-
- public final static Property root = ResourceFactory.createProperty(NS + "root");
public final static Property scope = ResourceFactory.createProperty(NS + "scope");
@@ -158,7 +158,9 @@ public class SH {
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
- public final static Property source = ResourceFactory.createProperty(NS + "source");
+ public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
+
+ public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
@@ -177,8 +179,6 @@ public class SH {
public static final Var predicateVar = Var.alloc(predicate.getLocalName());
- public static final Var rootVar = Var.alloc(root.getLocalName());
-
public static final Var severityVar = Var.alloc(severity.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
| 5 | Latest spec changes about result format (sh:root -> sh:focusNode, sh:source -> sh:sourceConstraint and sh:sourceShape), generalized sh:severity | 5 | .java | java | apache-2.0 | TopQuadrant/shacl |
255 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Property final_ = ResourceFactory.createProperty(NS + "final");
public final static Property graph = ResourceFactory.createProperty(NS + "graph");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property root = ResourceFactory.createProperty(NS + "root");
public final static Property scope = ResourceFactory.createProperty(NS + "scope");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property source = ResourceFactory.createProperty(NS + "source");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public static final Var predicateVar = Var.alloc(predicate.getLocalName());
public static final Var rootVar = Var.alloc(root.getLocalName());
public static final Var severityVar = Var.alloc(severity.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Latest spec changes about result format (sh:root -> sh:focusNode, sh:source -> sh:sourceConstraint and sh:sourceShape), generalized sh:severity
<DFF> @@ -102,6 +102,8 @@ public class SH {
public final static Property final_ = ResourceFactory.createProperty(NS + "final");
+ public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
+
public final static Property graph = ResourceFactory.createProperty(NS + "graph");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
@@ -145,8 +147,6 @@ public class SH {
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
-
- public final static Property root = ResourceFactory.createProperty(NS + "root");
public final static Property scope = ResourceFactory.createProperty(NS + "scope");
@@ -158,7 +158,9 @@ public class SH {
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
- public final static Property source = ResourceFactory.createProperty(NS + "source");
+ public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
+
+ public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
@@ -177,8 +179,6 @@ public class SH {
public static final Var predicateVar = Var.alloc(predicate.getLocalName());
- public static final Var rootVar = Var.alloc(root.getLocalName());
-
public static final Var severityVar = Var.alloc(severity.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
| 5 | Latest spec changes about result format (sh:root -> sh:focusNode, sh:source -> sh:sourceConstraint and sh:sourceShape), generalized sh:severity | 5 | .java | java | apache-2.0 | TopQuadrant/shacl |
256 | <NME> XoneConstraintExecutor.java
<BEF> ADDFILE
<MSG> Added native Java implementations of all SHACL Core constraint components to boost performance (formerly limited to TopBraid commercial products)
<DFF> @@ -0,0 +1,36 @@
+package org.topbraid.shacl.validation.java;
+
+import java.util.Collection;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.topbraid.shacl.engine.Constraint;
+import org.topbraid.shacl.validation.ValidationEngine;
+
+class XoneConstraintExecutor extends AbstractShapeListConstraintExecutor {
+
+ XoneConstraintExecutor(Constraint constraint) {
+ super(constraint);
+ }
+
+
+ @Override
+ public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
+
+ long startTime = System.currentTimeMillis();
+
+ for(RDFNode focusNode : focusNodes) {
+ for(RDFNode valueNode : engine.getValueNodes(constraint, focusNode)) {
+ long count = shapes.stream().filter(shape -> {
+ Model nestedResults = hasShape(engine, constraint, focusNode, valueNode, shape, true);
+ return nestedResults != null;
+ }).count();
+ if(count != 1) {
+ engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value has " + count + " shapes out of " + shapes.size() + " in the sh:xone enumeration");
+ }
+ }
+ }
+
+ addStatistics(constraint, startTime);
+ }
+}
| 36 | Added native Java implementations of all SHACL Core constraint components to boost performance (formerly limited to TopBraid commercial products) | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
257 | <NME> XoneConstraintExecutor.java
<BEF> ADDFILE
<MSG> Added native Java implementations of all SHACL Core constraint components to boost performance (formerly limited to TopBraid commercial products)
<DFF> @@ -0,0 +1,36 @@
+package org.topbraid.shacl.validation.java;
+
+import java.util.Collection;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.topbraid.shacl.engine.Constraint;
+import org.topbraid.shacl.validation.ValidationEngine;
+
+class XoneConstraintExecutor extends AbstractShapeListConstraintExecutor {
+
+ XoneConstraintExecutor(Constraint constraint) {
+ super(constraint);
+ }
+
+
+ @Override
+ public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
+
+ long startTime = System.currentTimeMillis();
+
+ for(RDFNode focusNode : focusNodes) {
+ for(RDFNode valueNode : engine.getValueNodes(constraint, focusNode)) {
+ long count = shapes.stream().filter(shape -> {
+ Model nestedResults = hasShape(engine, constraint, focusNode, valueNode, shape, true);
+ return nestedResults != null;
+ }).count();
+ if(count != 1) {
+ engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value has " + count + " shapes out of " + shapes.size() + " in the sh:xone enumeration");
+ }
+ }
+ }
+
+ addStatistics(constraint, startTime);
+ }
+}
| 36 | Added native Java implementations of all SHACL Core constraint components to boost performance (formerly limited to TopBraid commercial products) | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
258 | <NME> term-factory.js
<BEF> ADDFILE
<MSG> Factoring out some parts out of rdfquery
<DFF> @@ -0,0 +1,75 @@
+// In some environments such as Nashorn this may already have a value
+// In TopBraid this is redirecting to native Jena calls
+var TermFactory = {
+
+ impl: require("rdflib"), // This needs to be connected to an API such as $rdf
+
+ // Globally registered prefixes for TTL short cuts
+ namespaces: {},
+
+ /**
+ * Registers a new namespace prefix for global TTL short cuts (qnames).
+ * @param prefix the prefix to add
+ * @param namespace the namespace to add for the prefix
+ */
+ registerNamespace: function (prefix, namespace) {
+ if (this.namespaces.prefix) {
+ throw "Prefix " + prefix + " already registered"
+ }
+ this.namespaces[prefix] = namespace;
+ },
+
+ /**
+ * Produces an RDF* term from a TTL string representation.
+ * Also uses the registered prefixes.
+ * @param str a string, e.g. "owl:Thing" or "true" or '"Hello"@en'.
+ * @return an RDF term
+ */
+ term: function (str) {
+ // TODO: this implementation currently only supports booleans and qnames - better overload to rdflib.js
+ if ("true" === str || "false" === str) {
+ return this.literal(str, this.term("xsd:boolean"))
+ }
+ var col = str.indexOf(":");
+ if (col < 0) {
+ throw "Expected qname with a ':', but found: " + str;
+ }
+ var ns = this.namespaces[str.substring(0, col)];
+ if (!ns) {
+ throw "Unregistered prefix " + str.substring(0, col) + " of node " + str;
+ }
+ return this.namedNode(ns + str.substring(col + 1));
+ },
+
+ /**
+ * Produces a new blank node.
+ * @param id an optional ID for the node
+ */
+ blankNode: function (id) {
+ return this.impl.blankNode(id);
+ },
+
+ /**
+ * Produces a new literal. For example .literal("42", T("xsd:integer")).
+ * @param lex the lexical form, e.g. "42"
+ * @param langOrDatatype either a language string or a URI node with the datatype
+ */
+ literal: function (lex, langOrDatatype) {
+ return this.impl.literal(lex, langOrDatatype)
+ },
+
+ // This function is basically left for Task Force compatibility, but the preferred function is uri()
+ namedNode: function (uri) {
+ return this.impl.namedNode(uri)
+ },
+
+ /**
+ * Produces a new URI node.
+ * @param uri the URI of the node
+ */
+ uri: function (uri) {
+ return TermFactory.namedNode(uri);
+ }
+};
+
+module.exports = TermFactory;
\ No newline at end of file
| 75 | Factoring out some parts out of rdfquery | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
259 | <NME> term-factory.js
<BEF> ADDFILE
<MSG> Factoring out some parts out of rdfquery
<DFF> @@ -0,0 +1,75 @@
+// In some environments such as Nashorn this may already have a value
+// In TopBraid this is redirecting to native Jena calls
+var TermFactory = {
+
+ impl: require("rdflib"), // This needs to be connected to an API such as $rdf
+
+ // Globally registered prefixes for TTL short cuts
+ namespaces: {},
+
+ /**
+ * Registers a new namespace prefix for global TTL short cuts (qnames).
+ * @param prefix the prefix to add
+ * @param namespace the namespace to add for the prefix
+ */
+ registerNamespace: function (prefix, namespace) {
+ if (this.namespaces.prefix) {
+ throw "Prefix " + prefix + " already registered"
+ }
+ this.namespaces[prefix] = namespace;
+ },
+
+ /**
+ * Produces an RDF* term from a TTL string representation.
+ * Also uses the registered prefixes.
+ * @param str a string, e.g. "owl:Thing" or "true" or '"Hello"@en'.
+ * @return an RDF term
+ */
+ term: function (str) {
+ // TODO: this implementation currently only supports booleans and qnames - better overload to rdflib.js
+ if ("true" === str || "false" === str) {
+ return this.literal(str, this.term("xsd:boolean"))
+ }
+ var col = str.indexOf(":");
+ if (col < 0) {
+ throw "Expected qname with a ':', but found: " + str;
+ }
+ var ns = this.namespaces[str.substring(0, col)];
+ if (!ns) {
+ throw "Unregistered prefix " + str.substring(0, col) + " of node " + str;
+ }
+ return this.namedNode(ns + str.substring(col + 1));
+ },
+
+ /**
+ * Produces a new blank node.
+ * @param id an optional ID for the node
+ */
+ blankNode: function (id) {
+ return this.impl.blankNode(id);
+ },
+
+ /**
+ * Produces a new literal. For example .literal("42", T("xsd:integer")).
+ * @param lex the lexical form, e.g. "42"
+ * @param langOrDatatype either a language string or a URI node with the datatype
+ */
+ literal: function (lex, langOrDatatype) {
+ return this.impl.literal(lex, langOrDatatype)
+ },
+
+ // This function is basically left for Task Force compatibility, but the preferred function is uri()
+ namedNode: function (uri) {
+ return this.impl.namedNode(uri)
+ },
+
+ /**
+ * Produces a new URI node.
+ * @param uri the URI of the node
+ */
+ uri: function (uri) {
+ return TermFactory.namedNode(uri);
+ }
+};
+
+module.exports = TermFactory;
\ No newline at end of file
| 75 | Factoring out some parts out of rdfquery | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
260 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features - may end up in another namespace
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Fixed an issue with producing sh:message in JS component executor (affecting Qualified Value constraints everywhere).
Other periodic updates with TopBraid code base.
<DFF> @@ -241,7 +241,7 @@ public class SH {
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
- // Advanced features - may end up in another namespace
+ // Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
| 1 | Fixed an issue with producing sh:message in JS component executor (affecting Qualified Value constraints everywhere). Other periodic updates with TopBraid code base. | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
261 | <NME> SH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Resource NotConstraintComponent = ResourceFactory.createResource(NS + "NotConstraintComponent");
public final static Resource OrConstraintComponent = ResourceFactory.createResource(NS + "OrConstraintComponent");
public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter");
public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable");
public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent");
public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration");
public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features - may end up in another namespace
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Fixed an issue with producing sh:message in JS component executor (affecting Qualified Value constraints everywhere).
Other periodic updates with TopBraid code base.
<DFF> @@ -241,7 +241,7 @@ public class SH {
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
- // Advanced features - may end up in another namespace
+ // Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
| 1 | Fixed an issue with producing sh:message in JS component executor (affecting Qualified Value constraints everywhere). Other periodic updates with TopBraid code base. | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
262 | <NME> ValidationExample.java
<BEF> ADDFILE
<MSG> Removed /js folder which is now at https://github.com/TopQuadrant/shacl-js
Restored ValidationExample.java
<DFF> @@ -0,0 +1,28 @@
+package org.topbraid.shacl;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.util.FileUtils;
+import org.topbraid.shacl.util.ModelPrinter;
+import org.topbraid.shacl.validation.ValidationUtil;
+import org.topbraid.spin.util.JenaUtil;
+
+public class ValidationExample {
+
+ /**
+ * Loads an example SHACL file and validates all focus nodes against all shapes.
+ */
+ public static void main(String[] args) throws Exception {
+
+ // Load the main data model
+ Model dataModel = JenaUtil.createMemoryModel();
+ dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
+
+ // Perform the validation of everything, using the data model
+ // also as the shapes model - you may have them separated
+ Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
+
+ // Print violations
+ System.out.println(ModelPrinter.get().print(report.getModel()));
+ }
+}
\ No newline at end of file
| 28 | Removed /js folder which is now at https://github.com/TopQuadrant/shacl-js Restored ValidationExample.java | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
263 | <NME> ValidationExample.java
<BEF> ADDFILE
<MSG> Removed /js folder which is now at https://github.com/TopQuadrant/shacl-js
Restored ValidationExample.java
<DFF> @@ -0,0 +1,28 @@
+package org.topbraid.shacl;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.util.FileUtils;
+import org.topbraid.shacl.util.ModelPrinter;
+import org.topbraid.shacl.validation.ValidationUtil;
+import org.topbraid.spin.util.JenaUtil;
+
+public class ValidationExample {
+
+ /**
+ * Loads an example SHACL file and validates all focus nodes against all shapes.
+ */
+ public static void main(String[] args) throws Exception {
+
+ // Load the main data model
+ Model dataModel = JenaUtil.createMemoryModel();
+ dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
+
+ // Perform the validation of everything, using the data model
+ // also as the shapes model - you may have them separated
+ Resource report = ValidationUtil.validateModel(dataModel, dataModel, true);
+
+ // Print violations
+ System.out.println(ModelPrinter.get().print(report.getModel()));
+ }
+}
\ No newline at end of file
| 28 | Removed /js folder which is now at https://github.com/TopQuadrant/shacl-js Restored ValidationExample.java | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
264 | <NME> DASH.java
<BEF> ADDFILE
<MSG> Some clean up, minor changes
<DFF> @@ -0,0 +1,58 @@
+package org.topbraid.shacl.vocabulary;
+
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+/**
+ * Vocabulary for http://datashapes.org/dash
+ *
+ * Automatically generated with TopBraid Composer.
+ */
+public class DASH {
+
+ public final static String BASE_URI = "http://datashapes.org/dash";
+
+ public final static String NS = BASE_URI + "#";
+
+ public final static String PREFIX = "dash";
+
+
+ public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult");
+
+ public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult");
+
+ public final static Resource FunctionTestCase = ResourceFactory.createResource(NS + "FunctionTestCase");
+
+ public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase");
+
+ public final static Resource NodeValidationTestCase = ResourceFactory.createResource(NS + "NodeValidationTestCase");
+
+ public final static Resource PrimaryKeyPropertyConstraint = ResourceFactory.createResource(NS + "PrimaryKeyPropertyConstraint");
+
+ public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult");
+
+ public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult");
+
+ public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase");
+
+ public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase");
+
+
+ public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult");
+
+ public final static Property expression = ResourceFactory.createProperty(NS + "expression");
+
+ public final static Property node = ResourceFactory.createProperty(NS + "node");
+
+ public final static Property testCase = ResourceFactory.createProperty(NS + "testCase");
+
+ public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph");
+
+ public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart");
+
+
+ public static String getURI() {
+ return NS;
+ }
+}
| 58 | Some clean up, minor changes | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
265 | <NME> DASH.java
<BEF> ADDFILE
<MSG> Some clean up, minor changes
<DFF> @@ -0,0 +1,58 @@
+package org.topbraid.shacl.vocabulary;
+
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+/**
+ * Vocabulary for http://datashapes.org/dash
+ *
+ * Automatically generated with TopBraid Composer.
+ */
+public class DASH {
+
+ public final static String BASE_URI = "http://datashapes.org/dash";
+
+ public final static String NS = BASE_URI + "#";
+
+ public final static String PREFIX = "dash";
+
+
+ public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult");
+
+ public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult");
+
+ public final static Resource FunctionTestCase = ResourceFactory.createResource(NS + "FunctionTestCase");
+
+ public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase");
+
+ public final static Resource NodeValidationTestCase = ResourceFactory.createResource(NS + "NodeValidationTestCase");
+
+ public final static Resource PrimaryKeyPropertyConstraint = ResourceFactory.createResource(NS + "PrimaryKeyPropertyConstraint");
+
+ public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult");
+
+ public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult");
+
+ public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase");
+
+ public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase");
+
+
+ public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult");
+
+ public final static Property expression = ResourceFactory.createProperty(NS + "expression");
+
+ public final static Property node = ResourceFactory.createProperty(NS + "node");
+
+ public final static Property testCase = ResourceFactory.createProperty(NS + "testCase");
+
+ public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph");
+
+ public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart");
+
+
+ public static String getURI() {
+ return NS;
+ }
+}
| 58 | Some clean up, minor changes | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
266 | <NME> shacl-validator.js
<BEF> ADDFILE
<MSG> Tracking latest version from TopBraid code base
<DFF> @@ -0,0 +1,586 @@
+/* Copyright (C) TopQuadrant, Inc - licensed under AGPL
+ * Written by Holger Knublauch <holger@topquadrant.com>, 2017
+ */
+
+// A simple SHACL validator in JavaScript based on SHACL-JS.
+
+// Design:
+//
+// First, derive a ShapesGraph object from the definitions in $shapes.
+// This manages a map of parameters to ConstraintComponents.
+// Each ConstraintComponent manages its list of parameters and a link to the validators.
+//
+// The ShapesGraph also manages a list of Shapes, each which has a list of Constraints.
+// A Constraint is a specific combination of parameters for a constraint component,
+// and has functions to access the target nodes.
+//
+// Each ShapesGraph can be reused between validation calls, and thus often only needs
+// to be created once per application.
+//
+// The validation process is started by creating a ValidationEngine that relies on
+// a given ShapesGraph and operates on the current $data.
+// It basically walks through all Shapes that have target nodes and runs the validators
+// for each Constraint of the shape, producing results along the way.
+
+TermFactory.registerNamespace("dash", "http://datashapes.org/dash#");
+
+
+var SHACL = {
+
+ depth : 0,
+
+ compareNodes : function(node1, node2) {
+ // TODO: Does not handle the case where nodes cannot be compared
+ return compareTerms(node1, node2);
+ },
+
+ nodeConformsToShape : function(focusNode, shapeNode) {
+ var localEngine = new ValidationEngine(currentShapesGraph, true);
+ var shape = currentShapesGraph.getShape(shapeNode);
+ try {
+ SHACL.depth++;
+ return !localEngine.validateNodeAgainstShape(focusNode, shape);
+ }
+ finally {
+ SHACL.depth--;
+ }
+ }
+}
+
+
+// class Constraint
+
+function Constraint(shape, component, paramValue) {
+ this.shape = shape;
+ this.component = component;
+ this.paramValue = paramValue;
+ var parameterValues = {};
+ var params = component.getParameters();
+ for(var i = 0; i < params.length; i++) {
+ var param = params[i];
+ var value = paramValue ? paramValue : RDFQuery($shapes).match(shape.shapeNode, param, "?value").getNode("?value");
+ if(value) {
+ var localName = getLocalName(param.uri);
+ parameterValues[localName] = value;
+ }
+ }
+ this.parameterValues = parameterValues;
+}
+
+Constraint.prototype.getParameterValue = function(paramName) {
+ return this.parameterValues[paramName];
+}
+
+
+// class ConstraintComponent
+
+function ConstraintComponent(node) {
+ this.node = node;
+ var parameters = [];
+ var parameterNodes = [];
+ var requiredParameters = [];
+ var optionals = {};
+ $shapes.query().
+ match(node, "sh:parameter", "?parameter").
+ match("?parameter", "sh:path", "?path").forEach(function(sol) {
+ parameters.push(sol.path);
+ parameterNodes.push(sol.parameter);
+ if($shapes.query().match(sol.parameter, "sh:optional", "true").hasSolution()) {
+ optionals[sol.path.uri] = true;
+ }
+ else {
+ requiredParameters.push(sol.path);
+ }
+ });
+ this.optionals = optionals;
+ this.parameters = parameters;
+ this.parameterNodes = parameterNodes;
+ this.requiredParameters = requiredParameters;
+ this.nodeValidationFunction = this.findValidationFunction(T("sh:nodeValidator"));
+ if(!this.nodeValidationFunction) {
+ this.nodeValidationFunction = this.findValidationFunction(T("sh:validator"));
+ this.nodeValidationFunctionGeneric = true;
+ }
+ this.propertyValidationFunction = this.findValidationFunction(T("sh:propertyValidator"));
+ if(!this.propertyValidationFunction) {
+ this.propertyValidationFunction = this.findValidationFunction(T("sh:validator"));
+ this.propertyValidationFunctionGeneric = true;
+ }
+}
+
+ConstraintComponent.prototype.findValidationFunction = function(predicate) {
+ var functionName = $shapes.query().
+ match(this.node, predicate, "?validator").
+ match("?validator", "rdf:type", "sh:JSValidator").
+ match("?validator", "sh:jsFunctionName", "?functionName").
+ getNode("?functionName");
+ if(functionName) {
+ return new ValidationFunction(functionName.lex, this.parameters);
+ }
+ else {
+ return null;
+ }
+}
+
+ConstraintComponent.prototype.getParameters = function() {
+ return this.parameters;
+}
+
+ConstraintComponent.prototype.isComplete = function(shapeNode) {
+ for(var i = 0; i < this.parameters.length; i++) {
+ var parameter = this.parameters[i];
+ if(!this.isOptional(parameter.uri)) {
+ if(!RDFQuery($shapes).match(shapeNode, parameter, null).hasSolution()) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+ConstraintComponent.prototype.isOptional = function(parameterURI) {
+ return this.optionals[parameterURI];
+}
+
+
+// class Shape
+
+function Shape(shapesGraph, shapeNode) {
+
+ this.severity = $shapes.query().match(shapeNode, "sh:severity", "?severity").getNode("?severity");
+ if(!this.severity) {
+ this.severity = T("sh:Violation");
+ }
+
+ this.deactivated = $shapes.query().match(shapeNode, "sh:deactivated", "true").hasSolution();
+ this.path = $shapes.query().match(shapeNode, "sh:path", "?path").getNode("?path");
+ this.shapeNode = shapeNode;
+ this.shapesGraph = shapesGraph;
+ this.constraints = [];
+
+ var handled = new NodeSet();
+ var self = this;
+ RDFQuery($shapes).match(shapeNode, "?predicate", "?object").forEach(function(sol) {
+ var component = shapesGraph.getComponentWithParameter(sol.predicate);
+ if(component && !handled.contains(component.node)) {
+ var params = component.getParameters();
+ if(params.length == 1) {
+ self.constraints.push(new Constraint(self, component, sol.object));
+ }
+ else if(component.isComplete(shapeNode)) {
+ self.constraints.push(new Constraint(self, component));
+ handled.add(component.node);
+ }
+ }
+ });
+}
+
+Shape.prototype.getConstraints = function() {
+ return this.constraints;
+}
+
+Shape.prototype.getTargetNodes = function() {
+ var results = new NodeSet();
+ var dataUtil = new RDFQueryUtil($data);
+ var shapesUtil = new RDFQueryUtil($shapes);
+
+ if(shapesUtil.isInstanceOf(this.shapeNode, T("rdfs:Class"))) {
+ results.addAll(dataUtil.getInstancesOf(this.shapeNode).toArray());
+ }
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetClass", "?targetClass").forEachNode("?targetClass", function(targetClass) {
+ results.addAll(dataUtil.getInstancesOf(targetClass).toArray());
+ });
+
+ results.addAll($shapes.query().
+ match(this.shapeNode, "sh:targetNode", "?targetNode").getNodeArray("?targetNode"));
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetSubjectsOf", "?subjectsOf").
+ forEachNode("?subjectsOf", function(predicate) {
+ results.addAll(RDFQuery($data).match("?subject", predicate, null).getNodeArray("?subject"));
+ });
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetObjectsOf", "?objectsOf").
+ forEachNode("?objectsOf", function(predicate) {
+ results.addAll(RDFQuery($data).match(null, predicate, "?object").getNodeArray("?object"));
+ });
+
+ return results.toArray();
+}
+
+
+Shape.prototype.getValueNodes = function(focusNode) {
+ if(this.path) {
+ return $data.query().path(focusNode, this.path, "?object").getNodeArray("?object");
+ }
+ else {
+ return [ focusNode ];
+ }
+}
+
+Shape.prototype.isPropertyShape = function() {
+ return this.path != null;
+}
+
+
+// class ShapesGraph
+
+function ShapesGraph() {
+
+ // Collect all defined constraint components
+ var components = [];
+ new RDFQueryUtil($shapes).getInstancesOf(T("sh:ConstraintComponent")).forEach(function(node) {
+ if(!T("dash:ParameterConstraintComponent").equals(node)) {
+ components.push(new ConstraintComponent(node));
+ }
+ });
+ this.components = components;
+
+ // Build map from parameters to constraint components
+ this.parametersMap = {};
+ for(var i = 0; i < this.components.length; i++) {
+ var component = this.components[i];
+ var parameters = component.getParameters();
+ for(var j = 0; j < parameters.length; j++) {
+ this.parametersMap[parameters[j].value] = component;
+ }
+ }
+
+ // Collection of shapes is populated on demand - here we remember the instances
+ this.shapes = {}; // Keys are the URIs/bnode ids of the shape nodes
+}
+
+
+ShapesGraph.prototype.getComponentWithParameter = function(parameter) {
+ return this.parametersMap[parameter.value];
+}
+
+ShapesGraph.prototype.getShape = function(shapeNode) {
+ var shape = this.shapes[shapeNode.value];
+ if(!shape) {
+ shape = new Shape(this, shapeNode);
+ this.shapes[shapeNode.value] = shape;
+ }
+ return shape;
+}
+
+ShapesGraph.prototype.getShapeNodesWithConstraints = function() {
+ if(!this.shapeNodesWithConstraints) {
+ var set = new NodeSet();
+ for(var i = 0; i < this.components.length; i++) {
+ var params = this.components[i].requiredParameters;
+ for(var j = 0; j < params.length; j++) {
+ RDFQuery($shapes).match("?shape", params[j], null).addAllNodes("?shape", set);
+ }
+ }
+ this.shapeNodesWithConstraints = set.toArray();
+ }
+ return this.shapeNodesWithConstraints;
+}
+
+ShapesGraph.prototype.getShapesWithTarget = function() {
+
+ if(!this.targetShapes) {
+ this.targetShapes = [];
+ var cs = this.getShapeNodesWithConstraints();
+ var util = new RDFQueryUtil($shapes);
+ for(var i = 0; i < cs.length; i++) {
+ var shapeNode = cs[i];
+ if(util.isInstanceOf(shapeNode, T("rdfs:Class")) ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetClass", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetNode", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetSubjectsOf", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetObjectsOf", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:target", null).hasSolution()) {
+ this.targetShapes.push(this.getShape(shapeNode));
+ }
+ }
+ }
+
+ return this.targetShapes;
+}
+
+
+// class ValidationFunction
+
+var globalObject = this;
+
+function ValidationFunction(functionName, parameters) {
+
+ this.funcName = functionName;
+ this.func = globalObject[functionName];
+ if(!this.func) {
+ throw "Cannot find validator function " + functionName;
+ }
+ // Get list of argument of the function, see
+ // https://davidwalsh.name/javascript-arguments
+ var args = this.func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
+ var funcArgsRaw = args.split(',').map(function(arg) {
+ return arg.replace(/\/\*.*\*\//, '').trim();
+ }).filter(function(arg) {
+ return arg;
+ });
+ this.funcArgs = [];
+ this.parameters = [];
+ for(var i = 0; i < funcArgsRaw.length; i++) {
+ var arg = funcArgsRaw[i];
+ if(arg.indexOf("$") == 0) {
+ arg = arg.substring(1);
+ }
+ this.funcArgs.push(arg);
+ for(var j = 0; j < parameters.length; j++) {
+ var parameter = parameters[j];
+ var localName = getLocalName(parameter.value);
+ if(arg === localName) {
+ this.parameters[i] = parameter;
+ break;
+ }
+ }
+ }
+}
+
+ValidationFunction.prototype.doExecute = function(args) {
+ return this.func.apply(globalObject, args);
+}
+
+ValidationFunction.prototype.execute = function(focusNode, valueNode, constraint) {
+ var args = [];
+ for(var i = 0; i < this.funcArgs.length; i++) {
+ var arg = this.funcArgs[i];
+ var param = this.parameters[i];
+ if(param) {
+ var value = constraint.getParameterValue(arg);
+ args.push(value);
+ }
+ else if(arg === "focusNode") {
+ args.push(focusNode);
+ }
+ else if(arg === "value") {
+ args.push(valueNode);
+ }
+ else if(arg === "currentShape") {
+ args.push(constraint.shape.shapeNode);
+ }
+ else if(arg === "path") {
+ args.push(constraint.shape.path);
+ }
+ else if(arg == "shapesGraph") {
+ args.push("DummyShapesGraph");
+ }
+ else {
+ throw "Unexpected validator function argument " + arg + " for function " + this.funcName;
+ }
+ }
+ return this.doExecute(args);
+}
+
+
+// class ValidationEngine
+
+var currentShapesGraph; // Singleton needed for access by the SHACL object
+
+function ValidationEngine(shapesGraph, conformanceOnly) {
+ this.conformanceOnly = conformanceOnly;
+ this.conforms = true;
+ this.results = [];
+ this.shapesGraph = shapesGraph;
+}
+
+ValidationEngine.prototype.addResultProperty = function(result, predicate, object) {
+ this.results.push([result, predicate, object]);
+}
+
+ValidationEngine.prototype.createResult = function(constraint, focusNode, valueNode) {
+ var result = this.createResultObject();
+ this.conforms = false;
+ this.addResultProperty(result, T("rdf:type"), T("sh:ValidationResult"));
+ this.addResultProperty(result, T("sh:resultSeverity"), constraint.shape.severity);
+ this.addResultProperty(result, T("sh:sourceConstraintComponent"), constraint.component.node);
+ this.addResultProperty(result, T("sh:sourceShape"), constraint.shape.shapeNode);
+ this.addResultProperty(result, T("sh:focusNode"), focusNode);
+ if(valueNode) {
+ this.addResultProperty(result, T("sh:value"), valueNode);
+ }
+ return result;
+}
+
+ValidationEngine.prototype.createResultObject = function() {
+ return TermFactory.blankNode();
+}
+
+ValidationEngine.prototype.createResultFromObject = function(obj, constraint, focusNode, valueNode) {
+ if(obj === false) {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode, valueNode);
+ if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ this.createResultMessages(result, constraint);
+ }
+ else if(typeof obj === 'string') {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode, valueNode);
+ if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(obj, T("xsd:string")));
+ this.createResultMessages(result, constraint);
+ }
+ else if(typeof obj === 'object') {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode);
+ if(result.path) {
+ this.addResultProperty(result, T("sh:resultPath"), obj.path); // TODO: Make deep copy
+ }
+ else if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ if(result.value) {
+ this.addResultProperty(result, T("sh:value"), result.value);
+ }
+ else if(valueNode) {
+ this.addResultProperty(result, T("sh:value"), valueNode);
+ }
+ if(result.message) {
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(obj, T("xsd:string")));
+ }
+ else {
+ this.createResultMessages(result, constraint);
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.createResultMessages = function(result, constraint) {
+ var ms = $shapes.query().
+ match(constraint.shape.shapeNode, "sh:message", "?message").
+ getNodeArray("?message");
+ if(ms.length == 0) {
+ var generic = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunctionGeneric :
+ constraint.component.nodeValidationFunctionGeneric;
+ var predicate = generic ? T("sh:validator") : (constraint.shape.isPropertyShape() ? T("sh:propertyValidator") : T("sh:nodeValidator"));
+ ms = $shapes.query().
+ match(constraint.component.node, predicate, "?validator").
+ match("?validator", "sh:message", "?message").
+ getNodeArray("?message");
+ }
+ if(ms.length == 0) {
+ ms = $shapes.query().
+ match(constraint.component.node, "sh:message", "?message").
+ getNodeArray("?message");
+ }
+ for(var i = 0; i < ms.length; i++) {
+ var m = ms[i];
+ var str = this.withSubstitutions(m, constraint);
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(str, m.language || T("xsd:string")));
+ }
+}
+
+ValidationEngine.prototype.validateAll = function() {
+ var shapes = this.shapesGraph.getShapesWithTarget();
+ for(var i = 0; i < shapes.length; i++) {
+ var shape = shapes[i];
+ var focusNodes = shape.getTargetNodes();
+ for(var j = 0; j < focusNodes.length; j++) {
+ if(this.validateNodeAgainstShape(focusNodes[j], shape)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// Returns true if any violation has been found
+ValidationEngine.prototype.validateNodeAgainstShape = function(focusNode, shape) {
+ if(shape.deactivated) {
+ return false;
+ }
+ var constraints = shape.getConstraints();
+ var valueNodes = shape.getValueNodes(focusNode);
+ for(var i = 0; i < constraints.length; i++) {
+ if(this.validateNodeAgainstConstraint(focusNode, valueNodes, constraints[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.validateNodeAgainstConstraint = function(focusNode, valueNodes, constraint) {
+ currentShapesGraph = this.shapesGraph;
+ if(T("sh:PropertyConstraintComponent").equals(constraint.component.node)) {
+ for(var i = 0; i < valueNodes.length; i++) {
+ if(this.validateNodeAgainstShape(valueNodes[i], this.shapesGraph.getShape(constraint.paramValue))) {
+ return true;
+ }
+ }
+ }
+ else {
+ var validationFunction = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunction :
+ constraint.component.nodeValidationFunction;
+ if(validationFunction) {
+ var generic = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunctionGeneric :
+ constraint.component.nodeValidationFunctionGeneric;
+ if(generic) {
+ // Generic sh:validator is called for each value node separately
+ for(var i = 0; i < valueNodes.length; i++) {
+ var valueNode = valueNodes[i];
+ var obj = validationFunction.execute(focusNode, valueNode, constraint);
+ if(Array.isArray(obj)) {
+ for(var a = 0; a < obj.length; a++) {
+ if(this.createResultFromObject(obj[a], constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ else {
+ if(this.createResultFromObject(obj, constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ }
+ else {
+ var obj = validationFunction.execute(focusNode, null, constraint);
+ if(Array.isArray(obj)) {
+ for(var a = 0; a < obj.length; a++) {
+ if(this.createResultFromObject(obj[a], constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ else {
+ if(this.createResultFromObject(obj, constraint, focusNode)) {
+ return true;
+ }
+ }
+ }
+ }
+ else {
+ throw "Cannot find validator for constraint component " + constraint.component.node.value;
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.withSubstitutions = function(msg, constraint) {
+ var str = msg.lex;
+ var values = constraint.parameterValues;
+ for(var key in values) {
+ var label = nodeLabel(values[key], shapesStore);
+ str = str.replace("{$" + key + "}", label);
+ str = str.replace("{?" + key + "}", label);
+ }
+ return TermFactory.literal(str, msg.language | msg.datatype);
+}
| 586 | Tracking latest version from TopBraid code base | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
267 | <NME> shacl-validator.js
<BEF> ADDFILE
<MSG> Tracking latest version from TopBraid code base
<DFF> @@ -0,0 +1,586 @@
+/* Copyright (C) TopQuadrant, Inc - licensed under AGPL
+ * Written by Holger Knublauch <holger@topquadrant.com>, 2017
+ */
+
+// A simple SHACL validator in JavaScript based on SHACL-JS.
+
+// Design:
+//
+// First, derive a ShapesGraph object from the definitions in $shapes.
+// This manages a map of parameters to ConstraintComponents.
+// Each ConstraintComponent manages its list of parameters and a link to the validators.
+//
+// The ShapesGraph also manages a list of Shapes, each which has a list of Constraints.
+// A Constraint is a specific combination of parameters for a constraint component,
+// and has functions to access the target nodes.
+//
+// Each ShapesGraph can be reused between validation calls, and thus often only needs
+// to be created once per application.
+//
+// The validation process is started by creating a ValidationEngine that relies on
+// a given ShapesGraph and operates on the current $data.
+// It basically walks through all Shapes that have target nodes and runs the validators
+// for each Constraint of the shape, producing results along the way.
+
+TermFactory.registerNamespace("dash", "http://datashapes.org/dash#");
+
+
+var SHACL = {
+
+ depth : 0,
+
+ compareNodes : function(node1, node2) {
+ // TODO: Does not handle the case where nodes cannot be compared
+ return compareTerms(node1, node2);
+ },
+
+ nodeConformsToShape : function(focusNode, shapeNode) {
+ var localEngine = new ValidationEngine(currentShapesGraph, true);
+ var shape = currentShapesGraph.getShape(shapeNode);
+ try {
+ SHACL.depth++;
+ return !localEngine.validateNodeAgainstShape(focusNode, shape);
+ }
+ finally {
+ SHACL.depth--;
+ }
+ }
+}
+
+
+// class Constraint
+
+function Constraint(shape, component, paramValue) {
+ this.shape = shape;
+ this.component = component;
+ this.paramValue = paramValue;
+ var parameterValues = {};
+ var params = component.getParameters();
+ for(var i = 0; i < params.length; i++) {
+ var param = params[i];
+ var value = paramValue ? paramValue : RDFQuery($shapes).match(shape.shapeNode, param, "?value").getNode("?value");
+ if(value) {
+ var localName = getLocalName(param.uri);
+ parameterValues[localName] = value;
+ }
+ }
+ this.parameterValues = parameterValues;
+}
+
+Constraint.prototype.getParameterValue = function(paramName) {
+ return this.parameterValues[paramName];
+}
+
+
+// class ConstraintComponent
+
+function ConstraintComponent(node) {
+ this.node = node;
+ var parameters = [];
+ var parameterNodes = [];
+ var requiredParameters = [];
+ var optionals = {};
+ $shapes.query().
+ match(node, "sh:parameter", "?parameter").
+ match("?parameter", "sh:path", "?path").forEach(function(sol) {
+ parameters.push(sol.path);
+ parameterNodes.push(sol.parameter);
+ if($shapes.query().match(sol.parameter, "sh:optional", "true").hasSolution()) {
+ optionals[sol.path.uri] = true;
+ }
+ else {
+ requiredParameters.push(sol.path);
+ }
+ });
+ this.optionals = optionals;
+ this.parameters = parameters;
+ this.parameterNodes = parameterNodes;
+ this.requiredParameters = requiredParameters;
+ this.nodeValidationFunction = this.findValidationFunction(T("sh:nodeValidator"));
+ if(!this.nodeValidationFunction) {
+ this.nodeValidationFunction = this.findValidationFunction(T("sh:validator"));
+ this.nodeValidationFunctionGeneric = true;
+ }
+ this.propertyValidationFunction = this.findValidationFunction(T("sh:propertyValidator"));
+ if(!this.propertyValidationFunction) {
+ this.propertyValidationFunction = this.findValidationFunction(T("sh:validator"));
+ this.propertyValidationFunctionGeneric = true;
+ }
+}
+
+ConstraintComponent.prototype.findValidationFunction = function(predicate) {
+ var functionName = $shapes.query().
+ match(this.node, predicate, "?validator").
+ match("?validator", "rdf:type", "sh:JSValidator").
+ match("?validator", "sh:jsFunctionName", "?functionName").
+ getNode("?functionName");
+ if(functionName) {
+ return new ValidationFunction(functionName.lex, this.parameters);
+ }
+ else {
+ return null;
+ }
+}
+
+ConstraintComponent.prototype.getParameters = function() {
+ return this.parameters;
+}
+
+ConstraintComponent.prototype.isComplete = function(shapeNode) {
+ for(var i = 0; i < this.parameters.length; i++) {
+ var parameter = this.parameters[i];
+ if(!this.isOptional(parameter.uri)) {
+ if(!RDFQuery($shapes).match(shapeNode, parameter, null).hasSolution()) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+ConstraintComponent.prototype.isOptional = function(parameterURI) {
+ return this.optionals[parameterURI];
+}
+
+
+// class Shape
+
+function Shape(shapesGraph, shapeNode) {
+
+ this.severity = $shapes.query().match(shapeNode, "sh:severity", "?severity").getNode("?severity");
+ if(!this.severity) {
+ this.severity = T("sh:Violation");
+ }
+
+ this.deactivated = $shapes.query().match(shapeNode, "sh:deactivated", "true").hasSolution();
+ this.path = $shapes.query().match(shapeNode, "sh:path", "?path").getNode("?path");
+ this.shapeNode = shapeNode;
+ this.shapesGraph = shapesGraph;
+ this.constraints = [];
+
+ var handled = new NodeSet();
+ var self = this;
+ RDFQuery($shapes).match(shapeNode, "?predicate", "?object").forEach(function(sol) {
+ var component = shapesGraph.getComponentWithParameter(sol.predicate);
+ if(component && !handled.contains(component.node)) {
+ var params = component.getParameters();
+ if(params.length == 1) {
+ self.constraints.push(new Constraint(self, component, sol.object));
+ }
+ else if(component.isComplete(shapeNode)) {
+ self.constraints.push(new Constraint(self, component));
+ handled.add(component.node);
+ }
+ }
+ });
+}
+
+Shape.prototype.getConstraints = function() {
+ return this.constraints;
+}
+
+Shape.prototype.getTargetNodes = function() {
+ var results = new NodeSet();
+ var dataUtil = new RDFQueryUtil($data);
+ var shapesUtil = new RDFQueryUtil($shapes);
+
+ if(shapesUtil.isInstanceOf(this.shapeNode, T("rdfs:Class"))) {
+ results.addAll(dataUtil.getInstancesOf(this.shapeNode).toArray());
+ }
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetClass", "?targetClass").forEachNode("?targetClass", function(targetClass) {
+ results.addAll(dataUtil.getInstancesOf(targetClass).toArray());
+ });
+
+ results.addAll($shapes.query().
+ match(this.shapeNode, "sh:targetNode", "?targetNode").getNodeArray("?targetNode"));
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetSubjectsOf", "?subjectsOf").
+ forEachNode("?subjectsOf", function(predicate) {
+ results.addAll(RDFQuery($data).match("?subject", predicate, null).getNodeArray("?subject"));
+ });
+
+ $shapes.query().
+ match(this.shapeNode, "sh:targetObjectsOf", "?objectsOf").
+ forEachNode("?objectsOf", function(predicate) {
+ results.addAll(RDFQuery($data).match(null, predicate, "?object").getNodeArray("?object"));
+ });
+
+ return results.toArray();
+}
+
+
+Shape.prototype.getValueNodes = function(focusNode) {
+ if(this.path) {
+ return $data.query().path(focusNode, this.path, "?object").getNodeArray("?object");
+ }
+ else {
+ return [ focusNode ];
+ }
+}
+
+Shape.prototype.isPropertyShape = function() {
+ return this.path != null;
+}
+
+
+// class ShapesGraph
+
+function ShapesGraph() {
+
+ // Collect all defined constraint components
+ var components = [];
+ new RDFQueryUtil($shapes).getInstancesOf(T("sh:ConstraintComponent")).forEach(function(node) {
+ if(!T("dash:ParameterConstraintComponent").equals(node)) {
+ components.push(new ConstraintComponent(node));
+ }
+ });
+ this.components = components;
+
+ // Build map from parameters to constraint components
+ this.parametersMap = {};
+ for(var i = 0; i < this.components.length; i++) {
+ var component = this.components[i];
+ var parameters = component.getParameters();
+ for(var j = 0; j < parameters.length; j++) {
+ this.parametersMap[parameters[j].value] = component;
+ }
+ }
+
+ // Collection of shapes is populated on demand - here we remember the instances
+ this.shapes = {}; // Keys are the URIs/bnode ids of the shape nodes
+}
+
+
+ShapesGraph.prototype.getComponentWithParameter = function(parameter) {
+ return this.parametersMap[parameter.value];
+}
+
+ShapesGraph.prototype.getShape = function(shapeNode) {
+ var shape = this.shapes[shapeNode.value];
+ if(!shape) {
+ shape = new Shape(this, shapeNode);
+ this.shapes[shapeNode.value] = shape;
+ }
+ return shape;
+}
+
+ShapesGraph.prototype.getShapeNodesWithConstraints = function() {
+ if(!this.shapeNodesWithConstraints) {
+ var set = new NodeSet();
+ for(var i = 0; i < this.components.length; i++) {
+ var params = this.components[i].requiredParameters;
+ for(var j = 0; j < params.length; j++) {
+ RDFQuery($shapes).match("?shape", params[j], null).addAllNodes("?shape", set);
+ }
+ }
+ this.shapeNodesWithConstraints = set.toArray();
+ }
+ return this.shapeNodesWithConstraints;
+}
+
+ShapesGraph.prototype.getShapesWithTarget = function() {
+
+ if(!this.targetShapes) {
+ this.targetShapes = [];
+ var cs = this.getShapeNodesWithConstraints();
+ var util = new RDFQueryUtil($shapes);
+ for(var i = 0; i < cs.length; i++) {
+ var shapeNode = cs[i];
+ if(util.isInstanceOf(shapeNode, T("rdfs:Class")) ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetClass", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetNode", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetSubjectsOf", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:targetObjectsOf", null).hasSolution() ||
+ RDFQuery($shapes).match(shapeNode, "sh:target", null).hasSolution()) {
+ this.targetShapes.push(this.getShape(shapeNode));
+ }
+ }
+ }
+
+ return this.targetShapes;
+}
+
+
+// class ValidationFunction
+
+var globalObject = this;
+
+function ValidationFunction(functionName, parameters) {
+
+ this.funcName = functionName;
+ this.func = globalObject[functionName];
+ if(!this.func) {
+ throw "Cannot find validator function " + functionName;
+ }
+ // Get list of argument of the function, see
+ // https://davidwalsh.name/javascript-arguments
+ var args = this.func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
+ var funcArgsRaw = args.split(',').map(function(arg) {
+ return arg.replace(/\/\*.*\*\//, '').trim();
+ }).filter(function(arg) {
+ return arg;
+ });
+ this.funcArgs = [];
+ this.parameters = [];
+ for(var i = 0; i < funcArgsRaw.length; i++) {
+ var arg = funcArgsRaw[i];
+ if(arg.indexOf("$") == 0) {
+ arg = arg.substring(1);
+ }
+ this.funcArgs.push(arg);
+ for(var j = 0; j < parameters.length; j++) {
+ var parameter = parameters[j];
+ var localName = getLocalName(parameter.value);
+ if(arg === localName) {
+ this.parameters[i] = parameter;
+ break;
+ }
+ }
+ }
+}
+
+ValidationFunction.prototype.doExecute = function(args) {
+ return this.func.apply(globalObject, args);
+}
+
+ValidationFunction.prototype.execute = function(focusNode, valueNode, constraint) {
+ var args = [];
+ for(var i = 0; i < this.funcArgs.length; i++) {
+ var arg = this.funcArgs[i];
+ var param = this.parameters[i];
+ if(param) {
+ var value = constraint.getParameterValue(arg);
+ args.push(value);
+ }
+ else if(arg === "focusNode") {
+ args.push(focusNode);
+ }
+ else if(arg === "value") {
+ args.push(valueNode);
+ }
+ else if(arg === "currentShape") {
+ args.push(constraint.shape.shapeNode);
+ }
+ else if(arg === "path") {
+ args.push(constraint.shape.path);
+ }
+ else if(arg == "shapesGraph") {
+ args.push("DummyShapesGraph");
+ }
+ else {
+ throw "Unexpected validator function argument " + arg + " for function " + this.funcName;
+ }
+ }
+ return this.doExecute(args);
+}
+
+
+// class ValidationEngine
+
+var currentShapesGraph; // Singleton needed for access by the SHACL object
+
+function ValidationEngine(shapesGraph, conformanceOnly) {
+ this.conformanceOnly = conformanceOnly;
+ this.conforms = true;
+ this.results = [];
+ this.shapesGraph = shapesGraph;
+}
+
+ValidationEngine.prototype.addResultProperty = function(result, predicate, object) {
+ this.results.push([result, predicate, object]);
+}
+
+ValidationEngine.prototype.createResult = function(constraint, focusNode, valueNode) {
+ var result = this.createResultObject();
+ this.conforms = false;
+ this.addResultProperty(result, T("rdf:type"), T("sh:ValidationResult"));
+ this.addResultProperty(result, T("sh:resultSeverity"), constraint.shape.severity);
+ this.addResultProperty(result, T("sh:sourceConstraintComponent"), constraint.component.node);
+ this.addResultProperty(result, T("sh:sourceShape"), constraint.shape.shapeNode);
+ this.addResultProperty(result, T("sh:focusNode"), focusNode);
+ if(valueNode) {
+ this.addResultProperty(result, T("sh:value"), valueNode);
+ }
+ return result;
+}
+
+ValidationEngine.prototype.createResultObject = function() {
+ return TermFactory.blankNode();
+}
+
+ValidationEngine.prototype.createResultFromObject = function(obj, constraint, focusNode, valueNode) {
+ if(obj === false) {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode, valueNode);
+ if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ this.createResultMessages(result, constraint);
+ }
+ else if(typeof obj === 'string') {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode, valueNode);
+ if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(obj, T("xsd:string")));
+ this.createResultMessages(result, constraint);
+ }
+ else if(typeof obj === 'object') {
+ if(this.conformanceOnly) {
+ return true;
+ }
+ var result = this.createResult(constraint, focusNode);
+ if(result.path) {
+ this.addResultProperty(result, T("sh:resultPath"), obj.path); // TODO: Make deep copy
+ }
+ else if(constraint.shape.isPropertyShape()) {
+ this.addResultProperty(result, T("sh:resultPath"), constraint.shape.path); // TODO: Make deep copy
+ }
+ if(result.value) {
+ this.addResultProperty(result, T("sh:value"), result.value);
+ }
+ else if(valueNode) {
+ this.addResultProperty(result, T("sh:value"), valueNode);
+ }
+ if(result.message) {
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(obj, T("xsd:string")));
+ }
+ else {
+ this.createResultMessages(result, constraint);
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.createResultMessages = function(result, constraint) {
+ var ms = $shapes.query().
+ match(constraint.shape.shapeNode, "sh:message", "?message").
+ getNodeArray("?message");
+ if(ms.length == 0) {
+ var generic = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunctionGeneric :
+ constraint.component.nodeValidationFunctionGeneric;
+ var predicate = generic ? T("sh:validator") : (constraint.shape.isPropertyShape() ? T("sh:propertyValidator") : T("sh:nodeValidator"));
+ ms = $shapes.query().
+ match(constraint.component.node, predicate, "?validator").
+ match("?validator", "sh:message", "?message").
+ getNodeArray("?message");
+ }
+ if(ms.length == 0) {
+ ms = $shapes.query().
+ match(constraint.component.node, "sh:message", "?message").
+ getNodeArray("?message");
+ }
+ for(var i = 0; i < ms.length; i++) {
+ var m = ms[i];
+ var str = this.withSubstitutions(m, constraint);
+ this.addResultProperty(result, T("sh:resultMessage"), TermFactory.literal(str, m.language || T("xsd:string")));
+ }
+}
+
+ValidationEngine.prototype.validateAll = function() {
+ var shapes = this.shapesGraph.getShapesWithTarget();
+ for(var i = 0; i < shapes.length; i++) {
+ var shape = shapes[i];
+ var focusNodes = shape.getTargetNodes();
+ for(var j = 0; j < focusNodes.length; j++) {
+ if(this.validateNodeAgainstShape(focusNodes[j], shape)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// Returns true if any violation has been found
+ValidationEngine.prototype.validateNodeAgainstShape = function(focusNode, shape) {
+ if(shape.deactivated) {
+ return false;
+ }
+ var constraints = shape.getConstraints();
+ var valueNodes = shape.getValueNodes(focusNode);
+ for(var i = 0; i < constraints.length; i++) {
+ if(this.validateNodeAgainstConstraint(focusNode, valueNodes, constraints[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.validateNodeAgainstConstraint = function(focusNode, valueNodes, constraint) {
+ currentShapesGraph = this.shapesGraph;
+ if(T("sh:PropertyConstraintComponent").equals(constraint.component.node)) {
+ for(var i = 0; i < valueNodes.length; i++) {
+ if(this.validateNodeAgainstShape(valueNodes[i], this.shapesGraph.getShape(constraint.paramValue))) {
+ return true;
+ }
+ }
+ }
+ else {
+ var validationFunction = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunction :
+ constraint.component.nodeValidationFunction;
+ if(validationFunction) {
+ var generic = constraint.shape.isPropertyShape() ?
+ constraint.component.propertyValidationFunctionGeneric :
+ constraint.component.nodeValidationFunctionGeneric;
+ if(generic) {
+ // Generic sh:validator is called for each value node separately
+ for(var i = 0; i < valueNodes.length; i++) {
+ var valueNode = valueNodes[i];
+ var obj = validationFunction.execute(focusNode, valueNode, constraint);
+ if(Array.isArray(obj)) {
+ for(var a = 0; a < obj.length; a++) {
+ if(this.createResultFromObject(obj[a], constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ else {
+ if(this.createResultFromObject(obj, constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ }
+ else {
+ var obj = validationFunction.execute(focusNode, null, constraint);
+ if(Array.isArray(obj)) {
+ for(var a = 0; a < obj.length; a++) {
+ if(this.createResultFromObject(obj[a], constraint, focusNode, valueNode)) {
+ return true;
+ }
+ }
+ }
+ else {
+ if(this.createResultFromObject(obj, constraint, focusNode)) {
+ return true;
+ }
+ }
+ }
+ }
+ else {
+ throw "Cannot find validator for constraint component " + constraint.component.node.value;
+ }
+ }
+ return false;
+}
+
+ValidationEngine.prototype.withSubstitutions = function(msg, constraint) {
+ var str = msg.lex;
+ var values = constraint.parameterValues;
+ for(var key in values) {
+ var label = nodeLabel(values[key], shapesStore);
+ str = str.replace("{$" + key + "}", label);
+ str = str.replace("{?" + key + "}", label);
+ }
+ return TermFactory.literal(str, msg.language | msg.datatype);
+}
| 586 | Tracking latest version from TopBraid code base | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
268 | <NME> TestValidatorConfiguration.java
<BEF> ADDFILE
<MSG> Merge pull request #36 from mulesoft-labs/partial_validation
Configuration object and partial validation
<DFF> @@ -0,0 +1,36 @@
+package org.topbraid.shacl;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.util.FileUtils;
+import org.junit.Test;
+import org.topbraid.jenax.util.JenaUtil;
+import org.topbraid.shacl.validation.ValidationEngineConfiguration;
+import org.topbraid.shacl.validation.ValidationUtil;
+import org.topbraid.shacl.vocabulary.SH;
+
+public class TestValidatorConfiguration {
+
+ @Test
+ public void testMaxErrors() {
+ Model dataModel = JenaUtil.createMemoryModel();
+ dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
+
+ ValidationEngineConfiguration configuration = new ValidationEngineConfiguration();
+ configuration.setValidationErrorBatch(-1);
+
+ Resource reportNoMaximum = ValidationUtil.validateModel(dataModel, dataModel, configuration);
+
+ Model resultModel = reportNoMaximum.getModel();
+ assert(resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() == 2);
+
+
+ configuration.setValidationErrorBatch(1);
+ Resource reportMaximum = ValidationUtil.validateModel(dataModel, dataModel, configuration);
+
+ resultModel = reportMaximum.getModel();
+ System.out.println("FOUND " + resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() );
+ assert(resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() == 1);
+
+ }
+}
| 36 | Merge pull request #36 from mulesoft-labs/partial_validation | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
269 | <NME> TestValidatorConfiguration.java
<BEF> ADDFILE
<MSG> Merge pull request #36 from mulesoft-labs/partial_validation
Configuration object and partial validation
<DFF> @@ -0,0 +1,36 @@
+package org.topbraid.shacl;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.util.FileUtils;
+import org.junit.Test;
+import org.topbraid.jenax.util.JenaUtil;
+import org.topbraid.shacl.validation.ValidationEngineConfiguration;
+import org.topbraid.shacl.validation.ValidationUtil;
+import org.topbraid.shacl.vocabulary.SH;
+
+public class TestValidatorConfiguration {
+
+ @Test
+ public void testMaxErrors() {
+ Model dataModel = JenaUtil.createMemoryModel();
+ dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle);
+
+ ValidationEngineConfiguration configuration = new ValidationEngineConfiguration();
+ configuration.setValidationErrorBatch(-1);
+
+ Resource reportNoMaximum = ValidationUtil.validateModel(dataModel, dataModel, configuration);
+
+ Model resultModel = reportNoMaximum.getModel();
+ assert(resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() == 2);
+
+
+ configuration.setValidationErrorBatch(1);
+ Resource reportMaximum = ValidationUtil.validateModel(dataModel, dataModel, configuration);
+
+ resultModel = reportMaximum.getModel();
+ System.out.println("FOUND " + resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() );
+ assert(resultModel.listStatements(null, SH.resultSeverity, SH.Violation).toList().size() == 1);
+
+ }
+}
| 36 | Merge pull request #36 from mulesoft-labs/partial_validation | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
270 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
**The code is not really optimized for performance, just for correctness.**
Coverage:
* SHACL Core and SHACL-SPARQL validation
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes)
and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves).
The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release).
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
```
SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
As another example, for Linux, add to .bashrc these lines:
```
# for shacl
export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin
export PATH=$SHACLROOT:$PATH
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Cosmetics
<DFF> @@ -9,11 +9,11 @@ This API also serves as a reference implementation developed in parallel to the
**The code is not really optimized for performance, just for correctness.**
Coverage:
-* SHACL Core and SHACL-SPARQL validation
-* SHACL Advanced Features (Rules etc)
-* SHACL JavaScript Extensions
+* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
+* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
+* [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/)
-See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
+See [SHACL-JS](https://github.com/TopQuadrant/shacl-js) for a pure JavaScript implementation.
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
| 4 | Cosmetics | 4 | .md | md | apache-2.0 | TopQuadrant/shacl |
271 | <NME> README.md
<BEF> # TopBraid SHACL API
**An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.**
Contact: Holger Knublauch (holger@topquadrant.com)
Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application.
This API also serves as a reference implementation of the SHACL spec.
**The code is not really optimized for performance, just for correctness.**
Coverage:
* SHACL Core and SHACL-SPARQL validation
* SHACL Advanced Features (Rules etc)
* SHACL JavaScript Extensions
See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes)
and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves).
The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release).
Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list:
https://groups.google.com/forum/#!forum/topbraid-users
Please prefix your messages with [SHACL API]
To get started, look at the class ValidationUtil in
the package org.topbraid.shacl.validation.
There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java)
## Application dependency
Releases are available in the central maven repository:
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>*VER*</version>
</dependency>
```
## Command Line Usage
Download the latest release from:
`https://repo1.maven.org/maven2/org/topbraid/shacl/`
The binary distribution is:
`https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`.
Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing).
To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena).
For example, on Windows:
```
SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin
SET PATH=%PATH%;%SHACLROOT%\bin
```
As another example, for Linux, add to .bashrc these lines:
```
# for shacl
export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin
export PATH=$SHACLROOT:$PATH
```
Both tools take the following parameters, for example:
`shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl`
where `-shapesfile` is optional and falls back to using the data graph as shapes graph.
Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular).
Currently only Turtle (.ttl) files are supported.
The tools print the validation report or the inferences graph to the output screen.
<MSG> Cosmetics
<DFF> @@ -9,11 +9,11 @@ This API also serves as a reference implementation developed in parallel to the
**The code is not really optimized for performance, just for correctness.**
Coverage:
-* SHACL Core and SHACL-SPARQL validation
-* SHACL Advanced Features (Rules etc)
-* SHACL JavaScript Extensions
+* [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
+* [SHACL Advanced Features (Rules etc)](https://www.w3.org/TR/shacl-af/)
+* [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/)
-See [SHACL-JS https://github.com/TopQuadrant/shacl-js] for a pure JavaScript implementation.
+See [SHACL-JS](https://github.com/TopQuadrant/shacl-js) for a pure JavaScript implementation.
The same code is used in the TopBraid products (currently aligned with the upcoming TopBraid 5.4 release).
For interoperability with TopBraid this library uses code from org.topbraid.spin packages.
| 4 | Cosmetics | 4 | .md | md | apache-2.0 | TopQuadrant/shacl |
272 | <NME> ClassConstraintExecutor.java
<BEF> package org.topbraid.shacl.validation.java;
import java.util.Collection;
import java.util.function.Predicate;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.validation.AbstractNativeConstraintExecutor;
import org.topbraid.shacl.validation.ClassesCache;
import org.topbraid.shacl.validation.ValidationEngine;
/**
* Validator for sh:class constraints.
*
* @author Holger Knublauch
*/
class ClassConstraintExecutor extends AbstractNativeConstraintExecutor {
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
long startTime = System.currentTimeMillis();
long valueNodeCount;
Resource classNode = (Resource) constraint.getParameterValue();
if(!constraint.getShape().isNodeShape()) {
valueNodeCount = 0;
for(RDFNode focusNode : focusNodes) {
if(!focusNode.isLiteral()) {
for(RDFNode valueNode : engine.getValueNodes(constraint, focusNode)) {
valueNodeCount++;
validate(constraint, engine, classNode, focusNode, valueNode);
}
}
engine.checkCanceled();
}
}
else {
valueNodeCount = focusNodes.size();
for(RDFNode focusNode : focusNodes) {
validate(constraint, engine, classNode, focusNode, focusNode);
engine.checkCanceled();
}
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
Predicate<Resource> pred = cache.getPredicate(classNode);
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
Predicate<Resource> pred = cache.getPredicate(classNode.inModel(valueNode.getModel()));
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
}
else if(!JenaUtil.hasIndirectType((Resource)valueNode, classNode)) {
// No cache: possibly walk superclasses for each call
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
}
}
}
<MSG> #76: sh:class cache did not operate on data graph but shapes graph only
<DFF> @@ -44,7 +44,7 @@ class ClassConstraintExecutor extends AbstractNativeConstraintExecutor {
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
- Predicate<Resource> pred = cache.getPredicate(classNode);
+ Predicate<Resource> pred = cache.getPredicate(classNode.inModel(valueNode.getModel()));
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
| 1 | #76: sh:class cache did not operate on data graph but shapes graph only | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
273 | <NME> ClassConstraintExecutor.java
<BEF> package org.topbraid.shacl.validation.java;
import java.util.Collection;
import java.util.function.Predicate;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.topbraid.jenax.util.JenaUtil;
import org.topbraid.shacl.engine.Constraint;
import org.topbraid.shacl.validation.AbstractNativeConstraintExecutor;
import org.topbraid.shacl.validation.ClassesCache;
import org.topbraid.shacl.validation.ValidationEngine;
/**
* Validator for sh:class constraints.
*
* @author Holger Knublauch
*/
class ClassConstraintExecutor extends AbstractNativeConstraintExecutor {
@Override
public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) {
long startTime = System.currentTimeMillis();
long valueNodeCount;
Resource classNode = (Resource) constraint.getParameterValue();
if(!constraint.getShape().isNodeShape()) {
valueNodeCount = 0;
for(RDFNode focusNode : focusNodes) {
if(!focusNode.isLiteral()) {
for(RDFNode valueNode : engine.getValueNodes(constraint, focusNode)) {
valueNodeCount++;
validate(constraint, engine, classNode, focusNode, valueNode);
}
}
engine.checkCanceled();
}
}
else {
valueNodeCount = focusNodes.size();
for(RDFNode focusNode : focusNodes) {
validate(constraint, engine, classNode, focusNode, focusNode);
engine.checkCanceled();
}
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
Predicate<Resource> pred = cache.getPredicate(classNode);
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
Predicate<Resource> pred = cache.getPredicate(classNode.inModel(valueNode.getModel()));
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
}
else if(!JenaUtil.hasIndirectType((Resource)valueNode, classNode)) {
// No cache: possibly walk superclasses for each call
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
}
}
}
<MSG> #76: sh:class cache did not operate on data graph but shapes graph only
<DFF> @@ -44,7 +44,7 @@ class ClassConstraintExecutor extends AbstractNativeConstraintExecutor {
else {
ClassesCache cache = engine.getClassesCache();
if(cache != null) {
- Predicate<Resource> pred = cache.getPredicate(classNode);
+ Predicate<Resource> pred = cache.getPredicate(classNode.inModel(valueNode.getModel()));
if(!pred.test((Resource)valueNode)) {
engine.createValidationResult(constraint, focusNode, valueNode, () -> "Value must be an instance of " + engine.getLabel(classNode));
}
| 1 | #76: sh:class cache did not operate on data graph but shapes graph only | 1 | .java | java | apache-2.0 | TopQuadrant/shacl |
274 | <NME> validation-function.js
<BEF> ADDFILE
<MSG> Adding logging and more changes in validation function
<DFF> @@ -0,0 +1,85 @@
+// class ValidationFunction
+
+var rdfquery = require("./rdfquery");
+var debug = require("debug")("validation-function");
+
+
+var globalObject = typeof(window) != null ? window : global;
+
+
+var ValidationFunction = function (functionName, parameters) {
+
+ this.funcName = functionName;
+ this.func = ValidationFunction.functionRegistry[functionName];
+ if (!this.func) {
+ throw "Cannot find validator function " + functionName;
+ }
+ // Get list of argument of the function, see
+ // https://davidwalsh.name/javascript-arguments
+ var args = this.func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
+ var funcArgsRaw = args.split(',').map(function (arg) {
+ return arg.replace(/\/\*.*\*\//, '').trim();
+ }).filter(function (arg) {
+ return arg;
+ });
+ this.funcArgs = [];
+ this.parameters = [];
+ for (var i = 0; i < funcArgsRaw.length; i++) {
+ var arg = funcArgsRaw[i];
+ if (arg.indexOf("$") == 0) {
+ arg = arg.substring(1);
+ }
+ this.funcArgs.push(arg);
+ for (var j = 0; j < parameters.length; j++) {
+ var parameter = parameters[j];
+ var localName = rdfquery.getLocalName(parameter.value);
+ if (arg === localName) {
+ this.parameters[i] = parameter;
+ break;
+ }
+ }
+ }
+};
+
+ValidationFunction.functionRegistry = {};
+
+ValidationFunction.prototype.doExecute = function (args) {
+ return this.func.apply(globalObject, args);
+};
+
+ValidationFunction.prototype.execute = function (focusNode, valueNode, constraint) {
+ debug("Validating " + this.funcName);
+ var args = [];
+ for (var i = 0; i < this.funcArgs.length; i++) {
+ var arg = this.funcArgs[i];
+ var param = this.parameters[i];
+ if (param) {
+ var value = constraint.getParameterValue(arg);
+ args.push(value);
+ }
+ else if (arg === "focusNode") {
+ args.push(focusNode);
+ }
+ else if (arg === "value") {
+ args.push(valueNode);
+ }
+ else if (arg === "currentShape") {
+ args.push(constraint.shape.shapeNode);
+ }
+ else if (arg === "path") {
+ args.push(constraint.shape.path);
+ }
+ else if (arg == "shapesGraph") {
+ args.push("DummyShapesGraph");
+ }
+ else if (arg === "this") {
+ args.push(focusNode);
+ }
+ else {
+ throw "Unexpected validator function argument " + arg + " for function " + this.funcName;
+ }
+ }
+ return this.doExecute(args);
+};
+
+module.exports = ValidationFunction;
\ No newline at end of file
| 85 | Adding logging and more changes in validation function | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
275 | <NME> validation-function.js
<BEF> ADDFILE
<MSG> Adding logging and more changes in validation function
<DFF> @@ -0,0 +1,85 @@
+// class ValidationFunction
+
+var rdfquery = require("./rdfquery");
+var debug = require("debug")("validation-function");
+
+
+var globalObject = typeof(window) != null ? window : global;
+
+
+var ValidationFunction = function (functionName, parameters) {
+
+ this.funcName = functionName;
+ this.func = ValidationFunction.functionRegistry[functionName];
+ if (!this.func) {
+ throw "Cannot find validator function " + functionName;
+ }
+ // Get list of argument of the function, see
+ // https://davidwalsh.name/javascript-arguments
+ var args = this.func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
+ var funcArgsRaw = args.split(',').map(function (arg) {
+ return arg.replace(/\/\*.*\*\//, '').trim();
+ }).filter(function (arg) {
+ return arg;
+ });
+ this.funcArgs = [];
+ this.parameters = [];
+ for (var i = 0; i < funcArgsRaw.length; i++) {
+ var arg = funcArgsRaw[i];
+ if (arg.indexOf("$") == 0) {
+ arg = arg.substring(1);
+ }
+ this.funcArgs.push(arg);
+ for (var j = 0; j < parameters.length; j++) {
+ var parameter = parameters[j];
+ var localName = rdfquery.getLocalName(parameter.value);
+ if (arg === localName) {
+ this.parameters[i] = parameter;
+ break;
+ }
+ }
+ }
+};
+
+ValidationFunction.functionRegistry = {};
+
+ValidationFunction.prototype.doExecute = function (args) {
+ return this.func.apply(globalObject, args);
+};
+
+ValidationFunction.prototype.execute = function (focusNode, valueNode, constraint) {
+ debug("Validating " + this.funcName);
+ var args = [];
+ for (var i = 0; i < this.funcArgs.length; i++) {
+ var arg = this.funcArgs[i];
+ var param = this.parameters[i];
+ if (param) {
+ var value = constraint.getParameterValue(arg);
+ args.push(value);
+ }
+ else if (arg === "focusNode") {
+ args.push(focusNode);
+ }
+ else if (arg === "value") {
+ args.push(valueNode);
+ }
+ else if (arg === "currentShape") {
+ args.push(constraint.shape.shapeNode);
+ }
+ else if (arg === "path") {
+ args.push(constraint.shape.path);
+ }
+ else if (arg == "shapesGraph") {
+ args.push("DummyShapesGraph");
+ }
+ else if (arg === "this") {
+ args.push(focusNode);
+ }
+ else {
+ throw "Unexpected validator function argument " + arg + " for function " + this.funcName;
+ }
+ }
+ return this.doExecute(args);
+};
+
+module.exports = ValidationFunction;
\ No newline at end of file
| 85 | Adding logging and more changes in validation function | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
276 | <NME> pattern-001.ttl
<BEF> ADDFILE
<MSG> Official support for minExclusive etc, with test cases
<DFF> @@ -0,0 +1,55 @@
+# baseURI: http://www.w3.org/ns/shacl/test/features/core/pattern-001
+
+@prefix ex: <http://example.org/> .
+@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#> .
+
+<>
+ a sh:Graph ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+
+
+# Shapes ----------------------------------------------------------------------
+
+ex:MyShape
+ a sh:Shape ;
+ sh:property [
+ sh:predicate ex:property ;
+ sh:pattern "^123" ;
+ ] ;
+.
+
+
+# Instances -------------------------------------------------------------------
+
+# Valid
+ex:ValidResource1
+ sh:nodeShape ex:MyShape ;
+ ex:property "12345" ;
+.
+
+# Valid
+ex:ValidResource2
+ sh:nodeShape ex:MyShape ;
+ ex:property 123 ;
+.
+
+# Invalid: does not start with 123
+ex:InvalidResource1
+ sh:nodeShape ex:MyShape ;
+ ex:property "The 123" ;
+.
+
+# Invalid: pattern not found
+ex:InvalidResource2
+ sh:nodeShape ex:MyShape ;
+ ex:property "132" ;
+.
+
+# Invalid: Blank node
+ex:InvalidResource3
+ sh:nodeShape ex:MyShape ;
+ ex:property [] ;
+.
| 55 | Official support for minExclusive etc, with test cases | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
277 | <NME> pattern-001.ttl
<BEF> ADDFILE
<MSG> Official support for minExclusive etc, with test cases
<DFF> @@ -0,0 +1,55 @@
+# baseURI: http://www.w3.org/ns/shacl/test/features/core/pattern-001
+
+@prefix ex: <http://example.org/> .
+@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#> .
+
+<>
+ a sh:Graph ;
+ sh:shapesGraph <http://www.w3.org/ns/shacl> ;
+.
+
+
+# Shapes ----------------------------------------------------------------------
+
+ex:MyShape
+ a sh:Shape ;
+ sh:property [
+ sh:predicate ex:property ;
+ sh:pattern "^123" ;
+ ] ;
+.
+
+
+# Instances -------------------------------------------------------------------
+
+# Valid
+ex:ValidResource1
+ sh:nodeShape ex:MyShape ;
+ ex:property "12345" ;
+.
+
+# Valid
+ex:ValidResource2
+ sh:nodeShape ex:MyShape ;
+ ex:property 123 ;
+.
+
+# Invalid: does not start with 123
+ex:InvalidResource1
+ sh:nodeShape ex:MyShape ;
+ ex:property "The 123" ;
+.
+
+# Invalid: pattern not found
+ex:InvalidResource2
+ sh:nodeShape ex:MyShape ;
+ ex:property "132" ;
+.
+
+# Invalid: Blank node
+ex:InvalidResource3
+ sh:nodeShape ex:MyShape ;
+ ex:property [] ;
+.
| 55 | Official support for minExclusive etc, with test cases | 0 | .ttl | ttl | apache-2.0 | TopQuadrant/shacl |
278 | <NME> TOSH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
public final static String PREFIX = "tosh";
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static String NS = BASE_URI + "#";
public final static String PREFIX = "tosh";
public final static Resource count = ResourceFactory.createResource(NS + "count");
public final static Resource DatatypePropertyShapeView = ResourceFactory.createResource(NS + "DatatypePropertyShapeView");
public final static Resource DeleteTripleSuggestionGenerator = ResourceFactory.createResource(NS + "DeleteTripleSuggestionGenerator");
public final static Resource NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor");
public final static Resource NodeShapeConstraintsShape = ResourceFactory.createResource(NS + "NodeShapeConstraintsShape");
public final static Resource ObjectPropertyShapeView = ResourceFactory.createResource(NS + "ObjectPropertyShapeView");
public final static Resource ResultsGenerators = ResourceFactory.createResource(NS + "ResultsGenerators");
public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform");
public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform");
public final static Resource evalExpr = ResourceFactory.createResource(NS + "evalExpr");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource isInTargetOf = ResourceFactory.createResource(NS + "isInTargetOf");
public final static Resource targetContains = ResourceFactory.createResource(NS + "targetContains");
public final static Resource values = ResourceFactory.createResource(NS + "values");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property editGroupDescription = ResourceFactory.createProperty(NS + "editGroupDescription");
public final static Property javaMethod = ResourceFactory.createProperty(NS + "javaMethod");
public final static Property useDeclaredDatatype = ResourceFactory.createProperty(NS + "useDeclaredDatatype");
// Note this property may be deleted in future versions
public final static Property viewGadget = ResourceFactory.createProperty(NS + "viewGadget");
public final static Property viewGroupDescription = ResourceFactory.createProperty(NS + "viewGroupDescription");
public final static Property viewWidget = ResourceFactory.createProperty(NS + "viewWidget");
public static String getURI() {
return NS;
}
}
<MSG> Tracking latest TopBraid changes
<DFF> @@ -18,7 +18,13 @@ public class TOSH {
public final static String PREFIX = "tosh";
+ public final static Resource evalExpr = ResourceFactory.createResource(NS + "evalExpr");
+
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
+
+ public final static Resource isInTargetOf = ResourceFactory.createResource(NS + "isInTargetOf");
+
+ public final static Resource targetContains = ResourceFactory.createResource(NS + "targetContains");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
| 6 | Tracking latest TopBraid changes | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
279 | <NME> TOSH.java
<BEF> /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
public final static String PREFIX = "tosh";
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static String NS = BASE_URI + "#";
public final static String PREFIX = "tosh";
public final static Resource count = ResourceFactory.createResource(NS + "count");
public final static Resource DatatypePropertyShapeView = ResourceFactory.createResource(NS + "DatatypePropertyShapeView");
public final static Resource DeleteTripleSuggestionGenerator = ResourceFactory.createResource(NS + "DeleteTripleSuggestionGenerator");
public final static Resource NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor");
public final static Resource NodeShapeConstraintsShape = ResourceFactory.createResource(NS + "NodeShapeConstraintsShape");
public final static Resource ObjectPropertyShapeView = ResourceFactory.createResource(NS + "ObjectPropertyShapeView");
public final static Resource ResultsGenerators = ResourceFactory.createResource(NS + "ResultsGenerators");
public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform");
public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform");
public final static Resource evalExpr = ResourceFactory.createResource(NS + "evalExpr");
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
public final static Resource isInTargetOf = ResourceFactory.createResource(NS + "isInTargetOf");
public final static Resource targetContains = ResourceFactory.createResource(NS + "targetContains");
public final static Resource values = ResourceFactory.createResource(NS + "values");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property editGroupDescription = ResourceFactory.createProperty(NS + "editGroupDescription");
public final static Property javaMethod = ResourceFactory.createProperty(NS + "javaMethod");
public final static Property useDeclaredDatatype = ResourceFactory.createProperty(NS + "useDeclaredDatatype");
// Note this property may be deleted in future versions
public final static Property viewGadget = ResourceFactory.createProperty(NS + "viewGadget");
public final static Property viewGroupDescription = ResourceFactory.createProperty(NS + "viewGroupDescription");
public final static Property viewWidget = ResourceFactory.createProperty(NS + "viewWidget");
public static String getURI() {
return NS;
}
}
<MSG> Tracking latest TopBraid changes
<DFF> @@ -18,7 +18,13 @@ public class TOSH {
public final static String PREFIX = "tosh";
+ public final static Resource evalExpr = ResourceFactory.createResource(NS + "evalExpr");
+
public final static Resource hasShape = ResourceFactory.createResource(NS + "hasShape");
+
+ public final static Resource isInTargetOf = ResourceFactory.createResource(NS + "isInTargetOf");
+
+ public final static Resource targetContains = ResourceFactory.createResource(NS + "targetContains");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
| 6 | Tracking latest TopBraid changes | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
280 | <NME> sparql-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/sparql/node/sparql-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/sparql/node/sparql-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/sparql/node/sparql-001.test>
rdf:type owl:Ontology ;
rdfs:label "Test of sh:sparql at node shape 001" ;
owl:imports <http://datashapes.org/dash> ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource1 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid resource 1" ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid label 1" ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid label 2" ;
] ;
] ;
.
ex:InvalidResource1
rdf:type rdfs:Resource ;
rdfs:label "Invalid resource 1" ;
.
ex:InvalidResource2
rdf:type rdfs:Resource ;
rdfs:label "Invalid label 1" ;
rdfs:label "Invalid label 2" ;
.
ex:TestShape
rdf:type sh:NodeShape ;
rdfs:label "Test shape" ;
sh:sparql [
sh:message "Cannot have a label" ;
sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
sh:select """
SELECT $this ?path ?value
WHERE {
$this ?path ?value .
FILTER (?path = rdfs:label) .
}""" ;
] ;
sh:targetNode ex:InvalidResource1 ;
sh:targetNode ex:InvalidResource2 ;
sh:targetNode ex:ValidResource1 ;
.
ex:ValidResource1
rdf:type rdfs:Resource ;
.
<MSG> Tests now also include sh:sourceShape and sh:sourceConstraint
<DFF> @@ -25,7 +25,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource1 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid resource 1" ;
] ;
sh:result [
@@ -33,7 +35,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid label 1" ;
] ;
sh:result [
@@ -41,7 +45,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid label 2" ;
] ;
] ;
@@ -58,20 +64,21 @@ ex:InvalidResource2
ex:TestShape
rdf:type sh:NodeShape ;
rdfs:label "Test shape" ;
- sh:sparql [
- sh:message "Cannot have a label" ;
- sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
- sh:select """
- SELECT $this ?path ?value
- WHERE {
- $this ?path ?value .
- FILTER (?path = rdfs:label) .
- }""" ;
- ] ;
+ sh:sparql ex:TestShape-sparql ;
sh:targetNode ex:InvalidResource1 ;
sh:targetNode ex:InvalidResource2 ;
sh:targetNode ex:ValidResource1 ;
.
+ex:TestShape-sparql
+ sh:message "Cannot have a label" ;
+ sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
+ sh:select """
+ SELECT $this ?path ?value
+ WHERE {
+ $this ?path ?value .
+ FILTER (?path = rdfs:label) .
+ }""" ;
+.
ex:ValidResource1
rdf:type rdfs:Resource ;
.
| 17 | Tests now also include sh:sourceShape and sh:sourceConstraint | 10 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
281 | <NME> sparql-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/sparql/node/sparql-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/sparql/node/sparql-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/sparql/node/sparql-001.test>
rdf:type owl:Ontology ;
rdfs:label "Test of sh:sparql at node shape 001" ;
owl:imports <http://datashapes.org/dash> ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource1 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid resource 1" ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid label 1" ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:value "Invalid label 2" ;
] ;
] ;
.
ex:InvalidResource1
rdf:type rdfs:Resource ;
rdfs:label "Invalid resource 1" ;
.
ex:InvalidResource2
rdf:type rdfs:Resource ;
rdfs:label "Invalid label 1" ;
rdfs:label "Invalid label 2" ;
.
ex:TestShape
rdf:type sh:NodeShape ;
rdfs:label "Test shape" ;
sh:sparql [
sh:message "Cannot have a label" ;
sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
sh:select """
SELECT $this ?path ?value
WHERE {
$this ?path ?value .
FILTER (?path = rdfs:label) .
}""" ;
] ;
sh:targetNode ex:InvalidResource1 ;
sh:targetNode ex:InvalidResource2 ;
sh:targetNode ex:ValidResource1 ;
.
ex:ValidResource1
rdf:type rdfs:Resource ;
.
<MSG> Tests now also include sh:sourceShape and sh:sourceConstraint
<DFF> @@ -25,7 +25,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource1 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid resource 1" ;
] ;
sh:result [
@@ -33,7 +35,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid label 1" ;
] ;
sh:result [
@@ -41,7 +45,9 @@ ex:GraphValidationTestCase
sh:focusNode ex:InvalidResource2 ;
sh:resultPath rdfs:label ;
sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
sh:value "Invalid label 2" ;
] ;
] ;
@@ -58,20 +64,21 @@ ex:InvalidResource2
ex:TestShape
rdf:type sh:NodeShape ;
rdfs:label "Test shape" ;
- sh:sparql [
- sh:message "Cannot have a label" ;
- sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
- sh:select """
- SELECT $this ?path ?value
- WHERE {
- $this ?path ?value .
- FILTER (?path = rdfs:label) .
- }""" ;
- ] ;
+ sh:sparql ex:TestShape-sparql ;
sh:targetNode ex:InvalidResource1 ;
sh:targetNode ex:InvalidResource2 ;
sh:targetNode ex:ValidResource1 ;
.
+ex:TestShape-sparql
+ sh:message "Cannot have a label" ;
+ sh:prefixes <http://datashapes.org/sh/tests/sparql/node/sparql-001.test> ;
+ sh:select """
+ SELECT $this ?path ?value
+ WHERE {
+ $this ?path ?value .
+ FILTER (?path = rdfs:label) .
+ }""" ;
+.
ex:ValidResource1
rdf:type rdfs:Resource ;
.
| 17 | Tests now also include sh:sourceShape and sh:sourceConstraint | 10 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
282 | <NME> shaclvalidate.sh
<BEF> #!/bin/sh
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
resolveLink() {
local NAME=$1
if [ -L "$NAME" ]; then
case "$OSTYPE" in
darwin*|bsd*)
# BSD style readlink behaves differently to GNU readlink
# Have to manually follow links
while [ -L "$NAME" ]; do
NAME=$( cd $NAME && pwd -P ) ;
done
;;
*)
# Assuming standard GNU readlink with -f for
# canonicalize and follow
NAME=$(readlink -f "$NAME")
;;
esac
fi
echo "$NAME"
}
# If JENA_HOME is empty
if [ -z "$JENA_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
SCRIPT=$(resolveLink "$0")
# If link is relative
case "$SCRIPT" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SCRIPT=$( dirname "$0" )/$SCRIPT
;;
esac
fi
# Work out root from script location
JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
export JENA_HOME
fi
# If JENA_HOME is a symbolic link need to resolve
if [ -L "${JENA_HOME}" ]; then
JENA_HOME=$(resolveLink "$JENA_HOME")
# If link is relative
case "$JENA_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
JENA_HOME=$(dirname "$JENA_HOME")
;;
esac
export JENA_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
# Expand JENA_HOME but literal *
JENA_CP="$JENA_HOME"'/lib/*'
SOCKS=
LOGGING="${LOGGING:--Dlog4j.configuration=file:$JENA_HOME/jena-log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
CYGWIN*) JENA_CP="$(cygpath -wp "$JENA_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
# important for tdbloader spill
if [ -n "$TMPDIR" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMPDIR\""
elif [ -n "$TMP" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
java $JVM_ARGS $LOGGING -cp "$JENA_CP" org.topbraid.shacl.tools.Validate "$@"
<MSG> Fixed Linux line endings, switched from JENAROOT to SHACLROOT
<DFF> @@ -24,8 +24,8 @@ resolveLink() {
echo "$NAME"
}
-# If JENA_HOME is empty
-if [ -z "$JENA_HOME" ]; then
+# If SHACL_HOME is empty
+if [ -z "$SHACL_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
@@ -43,37 +43,37 @@ if [ -z "$JENA_HOME" ]; then
fi
# Work out root from script location
- JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
- export JENA_HOME
+ SHACL_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
+ export SHACL_HOME
fi
-# If JENA_HOME is a symbolic link need to resolve
-if [ -L "${JENA_HOME}" ]; then
- JENA_HOME=$(resolveLink "$JENA_HOME")
+# If SHACL_HOME is a symbolic link need to resolve
+if [ -L "${SHACL_HOME}" ]; then
+ SHACL_HOME=$(resolveLink "$SHACL_HOME")
# If link is relative
- case "$JENA_HOME" in
+ case "$SHACL_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
- JENA_HOME=$(dirname "$JENA_HOME")
+ SHACL_HOME=$(dirname "$SHACL_HOME")
;;
esac
- export JENA_HOME
+ export SHACL_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
-# Expand JENA_HOME but literal *
-JENA_CP="$JENA_HOME"'/lib/*'
+# Expand SHACL_HOME but literal *
+SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
-LOGGING="${LOGGING:--Dlog4j.configuration=file:$JENA_HOME/jena-log4j.properties}"
+LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
- CYGWIN*) JENA_CP="$(cygpath -wp "$JENA_CP");";;
+ CYGWIN*) SHACL_CP="$(cygpath -wp "$SHACL_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
@@ -86,4 +86,4 @@ elif [ -n "$TMP" ]
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
-java $JVM_ARGS $LOGGING -cp "$JENA_CP" org.topbraid.shacl.tools.Validate "$@"
+java $JVM_ARGS $LOGGING -cp "$SHACL_CP" org.topbraid.shacl.tools.Validate "$@"
| 15 | Fixed Linux line endings, switched from JENAROOT to SHACLROOT | 15 | .sh | sh | apache-2.0 | TopQuadrant/shacl |
283 | <NME> shaclvalidate.sh
<BEF> #!/bin/sh
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
resolveLink() {
local NAME=$1
if [ -L "$NAME" ]; then
case "$OSTYPE" in
darwin*|bsd*)
# BSD style readlink behaves differently to GNU readlink
# Have to manually follow links
while [ -L "$NAME" ]; do
NAME=$( cd $NAME && pwd -P ) ;
done
;;
*)
# Assuming standard GNU readlink with -f for
# canonicalize and follow
NAME=$(readlink -f "$NAME")
;;
esac
fi
echo "$NAME"
}
# If JENA_HOME is empty
if [ -z "$JENA_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
SCRIPT=$(resolveLink "$0")
# If link is relative
case "$SCRIPT" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
SCRIPT=$( dirname "$0" )/$SCRIPT
;;
esac
fi
# Work out root from script location
JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
export JENA_HOME
fi
# If JENA_HOME is a symbolic link need to resolve
if [ -L "${JENA_HOME}" ]; then
JENA_HOME=$(resolveLink "$JENA_HOME")
# If link is relative
case "$JENA_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
JENA_HOME=$(dirname "$JENA_HOME")
;;
esac
export JENA_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
# Expand JENA_HOME but literal *
JENA_CP="$JENA_HOME"'/lib/*'
SOCKS=
LOGGING="${LOGGING:--Dlog4j.configuration=file:$JENA_HOME/jena-log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
CYGWIN*) JENA_CP="$(cygpath -wp "$JENA_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
# important for tdbloader spill
if [ -n "$TMPDIR" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMPDIR\""
elif [ -n "$TMP" ]
then
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
java $JVM_ARGS $LOGGING -cp "$JENA_CP" org.topbraid.shacl.tools.Validate "$@"
<MSG> Fixed Linux line endings, switched from JENAROOT to SHACLROOT
<DFF> @@ -24,8 +24,8 @@ resolveLink() {
echo "$NAME"
}
-# If JENA_HOME is empty
-if [ -z "$JENA_HOME" ]; then
+# If SHACL_HOME is empty
+if [ -z "$SHACL_HOME" ]; then
SCRIPT="$0"
# Catch common issue: script has been symlinked
if [ -L "$SCRIPT" ]; then
@@ -43,37 +43,37 @@ if [ -z "$JENA_HOME" ]; then
fi
# Work out root from script location
- JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
- export JENA_HOME
+ SHACL_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
+ export SHACL_HOME
fi
-# If JENA_HOME is a symbolic link need to resolve
-if [ -L "${JENA_HOME}" ]; then
- JENA_HOME=$(resolveLink "$JENA_HOME")
+# If SHACL_HOME is a symbolic link need to resolve
+if [ -L "${SHACL_HOME}" ]; then
+ SHACL_HOME=$(resolveLink "$SHACL_HOME")
# If link is relative
- case "$JENA_HOME" in
+ case "$SHACL_HOME" in
/*)
# Already absolute
;;
*)
# Relative, make absolute
- JENA_HOME=$(dirname "$JENA_HOME")
+ SHACL_HOME=$(dirname "$SHACL_HOME")
;;
esac
- export JENA_HOME
+ export SHACL_HOME
fi
# ---- Setup
# JVM_ARGS : don't set here but it can be set in the environment.
-# Expand JENA_HOME but literal *
-JENA_CP="$JENA_HOME"'/lib/*'
+# Expand SHACL_HOME but literal *
+SHACL_CP="$SHACL_HOME"'/lib/*'
SOCKS=
-LOGGING="${LOGGING:--Dlog4j.configuration=file:$JENA_HOME/jena-log4j.properties}"
+LOGGING="${LOGGING:--Dlog4j.configuration=file:$SHACL_HOME/log4j.properties}"
# Platform specific fixup
# On CYGWIN convert path and end with a ';'
case "$(uname)" in
- CYGWIN*) JENA_CP="$(cygpath -wp "$JENA_CP");";;
+ CYGWIN*) SHACL_CP="$(cygpath -wp "$SHACL_CP");";;
esac
# Respect TMPDIR or TMP (windows?) if present
@@ -86,4 +86,4 @@ elif [ -n "$TMP" ]
JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
fi
-java $JVM_ARGS $LOGGING -cp "$JENA_CP" org.topbraid.shacl.tools.Validate "$@"
+java $JVM_ARGS $LOGGING -cp "$SHACL_CP" org.topbraid.shacl.tools.Validate "$@"
| 15 | Fixed Linux line endings, switched from JENAROOT to SHACLROOT | 15 | .sh | sh | apache-2.0 | TopQuadrant/shacl |
284 | <NME> severity-002.test.ttl
<BEF> ADDFILE
<MSG> Fixed lack of support for sh:deactivated and added tests for it
<DFF> @@ -0,0 +1,55 @@
+# baseURI: http://datashapes.org/sh/tests/core/misc/severity-002.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/core/misc/severity-002.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/misc/severity-002.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of sh:severity 002" ;
+ owl:imports <http://datashapes.org/dash> ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultPath ex:property ;
+ sh:resultSeverity sh:Info ;
+ sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
+ sh:sourceShape ex:TestShape2 ;
+ sh:value "true"^^xsd:boolean ;
+ ] ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultSeverity ex:MySeverity ;
+ sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
+ sh:sourceShape ex:TestShape1 ;
+ sh:value ex:InvalidResource1 ;
+ ] ;
+ ] ;
+.
+ex:InvalidResource1
+ ex:property "true"^^xsd:boolean ;
+.
+ex:TestShape1
+ sh:nodeKind sh:BlankNode ;
+ sh:property ex:TestShape2 ;
+ sh:severity ex:MySeverity ;
+ sh:targetNode ex:InvalidResource1 ;
+.
+ex:TestShape2
+ sh:path ex:property ;
+ sh:datatype xsd:integer ;
+ sh:severity sh:Info ;
+.
| 55 | Fixed lack of support for sh:deactivated and added tests for it | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
285 | <NME> severity-002.test.ttl
<BEF> ADDFILE
<MSG> Fixed lack of support for sh:deactivated and added tests for it
<DFF> @@ -0,0 +1,55 @@
+# baseURI: http://datashapes.org/sh/tests/core/misc/severity-002.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/core/misc/severity-002.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/misc/severity-002.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of sh:severity 002" ;
+ owl:imports <http://datashapes.org/dash> ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultPath ex:property ;
+ sh:resultSeverity sh:Info ;
+ sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
+ sh:sourceShape ex:TestShape2 ;
+ sh:value "true"^^xsd:boolean ;
+ ] ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultSeverity ex:MySeverity ;
+ sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
+ sh:sourceShape ex:TestShape1 ;
+ sh:value ex:InvalidResource1 ;
+ ] ;
+ ] ;
+.
+ex:InvalidResource1
+ ex:property "true"^^xsd:boolean ;
+.
+ex:TestShape1
+ sh:nodeKind sh:BlankNode ;
+ sh:property ex:TestShape2 ;
+ sh:severity ex:MySeverity ;
+ sh:targetNode ex:InvalidResource1 ;
+.
+ex:TestShape2
+ sh:path ex:property ;
+ sh:datatype xsd:integer ;
+ sh:severity sh:Info ;
+.
| 55 | Fixed lack of support for sh:deactivated and added tests for it | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
286 | <NME> SH.java
<BEF> package org.topbraid.shacl.vocabulary;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property constraint = ResourceFactory.createProperty(NS + "constraint");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property defaultValueType = ResourceFactory.createProperty(NS + "defaultValueType");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Switched to Apache Jena 3
<DFF> @@ -1,9 +1,9 @@
package org.topbraid.shacl.vocabulary;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.ResourceFactory;
-import com.hp.hpl.jena.sparql.core.Var;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl
@@ -104,10 +104,14 @@ public class SH {
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
+ public final static Property classIn = ResourceFactory.createProperty(NS + "classIn");
+
public final static Property constraint = ResourceFactory.createProperty(NS + "constraint");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
+ public final static Property datatypeIn = ResourceFactory.createProperty(NS + "datatypeIn");
+
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property defaultValueType = ResourceFactory.createProperty(NS + "defaultValueType");
| 8 | Switched to Apache Jena 3 | 4 | .java | java | apache-2.0 | TopQuadrant/shacl |
287 | <NME> SH.java
<BEF> package org.topbraid.shacl.vocabulary;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.topbraid.shacl.vocabulary;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl#
*
* @author Holger Knublauch
*/
public class SH {
public final static String BASE_URI = "http://www.w3.org/ns/shacl#";
public final static String NAME = "SHACL";
public final static String NS = BASE_URI;
public final static String PREFIX = "sh";
public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult");
public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent");
public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode");
public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI");
public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral");
public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent");
public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent");
public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint");
public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent");
public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent");
public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent");
public final static Resource EqualsConstraintComponent = ResourceFactory.createResource(NS + "EqualsConstraintComponent");
public final static Resource HasValueConstraintComponent = ResourceFactory.createResource(NS + "HasValueConstraintComponent");
public final static Resource InConstraintComponent = ResourceFactory.createResource(NS + "InConstraintComponent");
public final static Resource Info = ResourceFactory.createResource(NS + "Info");
public final static Resource IRI = ResourceFactory.createResource(NS + "IRI");
public final static Resource IRIOrLiteral = ResourceFactory.createResource(NS + "IRIOrLiteral");
public final static Resource LanguageInConstraintComponent = ResourceFactory.createResource(NS + "LanguageInConstraintComponent");
public final static Resource LessThanConstraintComponent = ResourceFactory.createResource(NS + "LessThanConstraintComponent");
public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent");
public final static Resource Literal = ResourceFactory.createResource(NS + "Literal");
public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent");
public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent");
public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent");
public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent");
public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent");
public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent");
public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent");
public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent");
public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent");
public final static Resource NodeKindConstraintComponent = ResourceFactory.createResource(NS + "NodeKindConstraintComponent");
public final static Resource NodeShape = ResourceFactory.createResource(NS + "NodeShape");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property constraint = ResourceFactory.createProperty(NS + "constraint");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property defaultValueType = ResourceFactory.createProperty(NS + "defaultValueType");
public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape");
public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent");
public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent");
public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent");
public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation");
public final static Resource Shape = ResourceFactory.createResource(NS + "Shape");
public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator");
public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint");
public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent");
public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule");
public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable");
public final static Resource SPARQLFunction = ResourceFactory.createResource(NS + "SPARQLFunction");
public final static Resource SPARQLSelectValidator = ResourceFactory.createResource(NS + "SPARQLSelectValidator");
public final static Resource SPARQLTarget = ResourceFactory.createResource(NS + "SPARQLTarget");
public final static Resource SPARQLValuesDeriver = ResourceFactory.createResource(NS + "SPARQLValuesDeriver");
public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent");
public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport");
public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult");
public final static Resource Validator = ResourceFactory.createResource(NS + "Validator");
public final static Resource Violation = ResourceFactory.createResource(NS + "Violation");
public final static Resource Warning = ResourceFactory.createResource(NS + "Warning");
public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent");
public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath");
public final static Property and = ResourceFactory.createProperty(NS + "and");
public final static Property ask = ResourceFactory.createProperty(NS + "ask");
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
public final static Property closed = ResourceFactory.createProperty(NS + "closed");
public final static Property condition = ResourceFactory.createProperty(NS + "condition");
public final static Property conforms = ResourceFactory.createProperty(NS + "conforms");
public final static Property construct = ResourceFactory.createProperty(NS + "construct");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated");
public final static Property declare = ResourceFactory.createProperty(NS + "declare");
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property detail = ResourceFactory.createProperty(NS + "detail");
public final static Property description = ResourceFactory.createProperty(NS + "description");
public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint");
public final static Property entailment = ResourceFactory.createProperty(NS + "entailment");
public final static Property equals = ResourceFactory.createProperty(NS + "equals");
public final static Property flags = ResourceFactory.createProperty(NS + "flags");
public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode");
public final static Property group = ResourceFactory.createProperty(NS + "group");
public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue");
public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties");
public final static Property in = ResourceFactory.createProperty(NS + "in");
public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath");
public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate");
public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn");
public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan");
public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals");
public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount");
public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive");
public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive");
public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength");
public final static Property message = ResourceFactory.createProperty(NS + "message");
public final static Property minCount = ResourceFactory.createProperty(NS + "minCount");
public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive");
public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive");
public final static Property minLength = ResourceFactory.createProperty(NS + "minLength");
public final static Property name = ResourceFactory.createProperty(NS + "name");
public final static Property namespace = ResourceFactory.createProperty(NS + "namespace");
public final static Property node = ResourceFactory.createProperty(NS + "node");
public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind");
public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator");
public final static Property not = ResourceFactory.createProperty(NS + "not");
public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath");
public final static Property optional = ResourceFactory.createProperty(NS + "optional");
public final static Property or = ResourceFactory.createProperty(NS + "or");
public final static Property order = ResourceFactory.createProperty(NS + "order");
public final static Property parameter = ResourceFactory.createProperty(NS + "parameter");
public final static Property path = ResourceFactory.createProperty(NS + "path");
public final static Property pattern = ResourceFactory.createProperty(NS + "pattern");
public final static Property prefix = ResourceFactory.createProperty(NS + "prefix");
public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes");
public final static Property property = ResourceFactory.createProperty(NS + "property");
public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator");
public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount");
public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount");
public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape");
public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint");
public final static Property result = ResourceFactory.createProperty(NS + "result");
public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage");
public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath");
public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity");
public final static Property select = ResourceFactory.createProperty(NS + "select");
public final static Property severity = ResourceFactory.createProperty(NS + "severity");
public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph");
public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint");
public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent");
public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape");
public final static Property sparql = ResourceFactory.createProperty(NS + "sparql");
public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass");
public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode");
public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf");
public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf");
public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang");
public final static Property update = ResourceFactory.createProperty(NS + "update");
public final static Property validator = ResourceFactory.createProperty(NS + "validator");
public final static Property value = ResourceFactory.createProperty(NS + "value");
public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath");
public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath");
// Advanced features
public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent");
public final static Resource Function = ResourceFactory.createResource(NS + "Function");
public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint");
public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent");
public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable");
public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction");
public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary");
public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule");
public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget");
public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType");
public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator");
public final static Resource Rule = ResourceFactory.createResource(NS + "Rule");
public final static Resource Rules = ResourceFactory.createResource(NS + "Rules");
public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule");
public final static Resource Target = ResourceFactory.createResource(NS + "Target");
public final static Resource this_ = ResourceFactory.createResource(NS + "this");
public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule");
public final static Property expression = ResourceFactory.createProperty(NS + "expression");
public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape");
public final static Property intersection = ResourceFactory.createProperty(NS + "intersection");
public final static Property js = ResourceFactory.createProperty(NS + "js");
public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName");
public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary");
public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL");
public final static Property member = ResourceFactory.createProperty(NS + "member");
public final static Property nodes = ResourceFactory.createProperty(NS + "nodes");
public final static Property object = ResourceFactory.createProperty(NS + "object");
public final static Property predicate = ResourceFactory.createProperty(NS + "predicate");
public final static Property returnType = ResourceFactory.createProperty(NS + "returnType");
public final static Property rule = ResourceFactory.createProperty(NS + "rule");
public final static Property subject = ResourceFactory.createProperty(NS + "subject");
public final static Property target = ResourceFactory.createProperty(NS + "target");
public final static Property union = ResourceFactory.createProperty(NS + "union");
// Features not in SHACL 1.0 but candidates for next release
public final static Property count = ResourceFactory.createProperty(NS + "count");
public final static Property desc = ResourceFactory.createProperty(NS + "desc");
public final static Property distinct = ResourceFactory.createProperty(NS + "distinct");
public final static Property else_ = ResourceFactory.createProperty(NS + "else");
public final static Property exists = ResourceFactory.createProperty(NS + "exists");
public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat");
public final static Property if_ = ResourceFactory.createProperty(NS + "if");
public final static Property limit = ResourceFactory.createProperty(NS + "limit");
public final static Property max = ResourceFactory.createProperty(NS + "max");
public final static Property min = ResourceFactory.createProperty(NS + "min");
public final static Property minus = ResourceFactory.createProperty(NS + "minus");
public final static Property offset = ResourceFactory.createProperty(NS + "offset");
public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy");
public final static Property separator = ResourceFactory.createProperty(NS + "separator");
public final static Property sum = ResourceFactory.createProperty(NS + "sum");
public final static Property then = ResourceFactory.createProperty(NS + "then");
public final static Property values = ResourceFactory.createProperty(NS + "values");
public static final Var currentShapeVar = Var.alloc("currentShape");
public static final Var failureVar = Var.alloc("failure");
public static final Var PATHVar = Var.alloc("PATH");
public static final Var pathVar = Var.alloc(path.getLocalName());
public static final Var shapesGraphVar = Var.alloc("shapesGraph");
public static final Var thisVar = Var.alloc("this");
public static final Var valueVar = Var.alloc("value");
public final static String JS_DATA_VAR = "$data";
public final static String JS_SHAPES_VAR = "$shapes";
public static String getURI() {
return NS;
}
}
<MSG> Switched to Apache Jena 3
<DFF> @@ -1,9 +1,9 @@
package org.topbraid.shacl.vocabulary;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.ResourceFactory;
-import com.hp.hpl.jena.sparql.core.Var;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.sparql.core.Var;
/**
* Vocabulary for http://www.w3.org/ns/shacl
@@ -104,10 +104,14 @@ public class SH {
public final static Property class_ = ResourceFactory.createProperty(NS + "class");
+ public final static Property classIn = ResourceFactory.createProperty(NS + "classIn");
+
public final static Property constraint = ResourceFactory.createProperty(NS + "constraint");
public final static Property datatype = ResourceFactory.createProperty(NS + "datatype");
+ public final static Property datatypeIn = ResourceFactory.createProperty(NS + "datatypeIn");
+
public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue");
public final static Property defaultValueType = ResourceFactory.createProperty(NS + "defaultValueType");
| 8 | Switched to Apache Jena 3 | 4 | .java | java | apache-2.0 | TopQuadrant/shacl |
288 | <NME> prefixes-001.test.ttl
<BEF> ADDFILE
<MSG> Minor bug fixes, latest test cases
<DFF> @@ -0,0 +1,64 @@
+# baseURI: http://datashapes.org/sh/tests/sparql/node/prefixes-001.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/node/prefixes-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/sparql/node/prefixes-001.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of sh:prefixes 001" ;
+ owl:imports <http://datashapes.org/dash> ;
+ owl:versionInfo "Created with TopBraid Composer" ;
+ sh:declare [
+ rdf:type sh:PrefixDeclaration ;
+ sh:namespace "http://datashapes.org/sh/tests/sparql/node/prefixes-001.test#"^^xsd:anyURI ;
+ sh:prefix "ex" ;
+ ] ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestSPARQL ;
+ sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
+ sh:value <http://test.com/ns#Value> ;
+ ] ;
+ ] ;
+.
+ex:InvalidResource1
+ ex:property <http://test.com/ns#Value> ;
+.
+ex:TestPrefixes
+ owl:imports <http://datashapes.org/sh/tests/sparql/node/prefixes-001.test> ;
+ sh:declare [
+ sh:namespace "http://test.com/ns#"^^xsd:anyURI ;
+ sh:prefix "test" ;
+ ] ;
+.
+ex:TestSPARQL
+ sh:prefixes ex:TestPrefixes ;
+ sh:select """
+ SELECT $this ?value
+ WHERE {
+ $this ex:property ?value .
+ FILTER (?value = test:Value) .
+ } """ ;
+.
+ex:TestShape
+ rdf:type sh:NodeShape ;
+ sh:sparql ex:TestSPARQL ;
+ sh:targetNode ex:InvalidResource1 ;
+ sh:targetNode ex:ValidResource1 ;
+.
| 64 | Minor bug fixes, latest test cases | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
289 | <NME> prefixes-001.test.ttl
<BEF> ADDFILE
<MSG> Minor bug fixes, latest test cases
<DFF> @@ -0,0 +1,64 @@
+# baseURI: http://datashapes.org/sh/tests/sparql/node/prefixes-001.test
+# imports: http://datashapes.org/dash
+# prefix: ex
+
+@prefix dash: <http://datashapes.org/dash#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/node/prefixes-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/sparql/node/prefixes-001.test>
+ rdf:type owl:Ontology ;
+ rdfs:label "Test of sh:prefixes 001" ;
+ owl:imports <http://datashapes.org/dash> ;
+ owl:versionInfo "Created with TopBraid Composer" ;
+ sh:declare [
+ rdf:type sh:PrefixDeclaration ;
+ sh:namespace "http://datashapes.org/sh/tests/sparql/node/prefixes-001.test#"^^xsd:anyURI ;
+ sh:prefix "ex" ;
+ ] ;
+.
+ex:GraphValidationTestCase
+ rdf:type dash:GraphValidationTestCase ;
+ dash:expectedResult [
+ rdf:type sh:ValidationReport ;
+ sh:conforms "false"^^xsd:boolean ;
+ sh:result [
+ rdf:type sh:ValidationResult ;
+ sh:focusNode ex:InvalidResource1 ;
+ sh:resultSeverity sh:Violation ;
+ sh:sourceConstraint ex:TestSPARQL ;
+ sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
+ sh:sourceShape ex:TestShape ;
+ sh:value <http://test.com/ns#Value> ;
+ ] ;
+ ] ;
+.
+ex:InvalidResource1
+ ex:property <http://test.com/ns#Value> ;
+.
+ex:TestPrefixes
+ owl:imports <http://datashapes.org/sh/tests/sparql/node/prefixes-001.test> ;
+ sh:declare [
+ sh:namespace "http://test.com/ns#"^^xsd:anyURI ;
+ sh:prefix "test" ;
+ ] ;
+.
+ex:TestSPARQL
+ sh:prefixes ex:TestPrefixes ;
+ sh:select """
+ SELECT $this ?value
+ WHERE {
+ $this ex:property ?value .
+ FILTER (?value = test:Value) .
+ } """ ;
+.
+ex:TestShape
+ rdf:type sh:NodeShape ;
+ sh:sparql ex:TestSPARQL ;
+ sh:targetNode ex:InvalidResource1 ;
+ sh:targetNode ex:ValidResource1 ;
+.
| 64 | Minor bug fixes, latest test cases | 0 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
290 | <NME> process.md
<BEF> # Processes for the Project
This page describes processes for the SHACL API Project.
----
## Local Build
To build the latest snapshot code for your local system:
Clone the github repo, run maven in the local directory:
```
git clone https://github.com/TopQuadrant/shacl
cd shacl
mvn clean install
```
The latest SNAPSHOT code is now available in you local maven
repository. Check the pom.xml for the correct version string.
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>VERSION</version>
</dependency>
```
----
## Release
### Prerequisites
One time setup:
1. A PGP key for signing the release. This needs to be registered on one
of the public servers e.g. [http://pgpkeys.mit.edu/](http://pgpkeys.mit.edu/).
1. Write access to the GitHub repo - the release process updates the
versions and creates a tag.
1. Write access to the Sonatype OpenSource Hosting Nexus server for `org.topbraid`.
Put your user name and password for accessing the Sonatype open source
repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`).
```
<server>
<id>ossrh.snapshots</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
<server>
<id>ossrh.releases</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
```
### Setup Release Process
#### Versions
Choose the release version, next version and the tag, otherwise maven
will ask for these interactively:
```
export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"
```
The maven release plugin will move the version from the current SNAPSHOT
to the release version, and tag the github repository. It will also move
to the next SNAPSHOT version after building the release.
#### Signing
If you have multiple PGP keys, choose the right one:
`export KEY="-Darguments=-Dgpg.keyname=KEY_SIGNATURE"`
(Note the slightly odd value here; the release plugin calls maven
recursively and `-Darguments=` is maven recursively passing
down arguments to the subprocess.)
If you have only one key, set this to the empty string:
```
export KEY=""
```
or omit `$KEY` in the examples below.
### Dry run
It is advisable to dry run the release:
```
mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY
```
### Check
Look in `target/`.
You should see various files built including the binary ".bin.zip", the
javadoc (which is only done in the release cycle), `sources`, `tests`
and `test-sources`. The files should have been signed and `.asc` files
created.
If there is no javadoc jar or no `.asc` files, check you gave the
`-Prelease` argument.
It still says "SNAPSHOT" because the dry run does not change the version in POM.
### Do the release
This has two steps:
`mvn release:clean release:prepare -Prelease $KEY $VER`
`mvn release:perform -Prelease $KEY $VER`
### If it goes wrong:
`mvn release:rollback`
`mvn release:clean`
You may also need to delete the tag.
`git tag -d shacl-x.y.z`
`git push --delete origin shacl-x.y.z`
### Release to central
The steps so far pushed the built artifacts to the staging repository.
To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
### Clearup
Check where any intermediate files are left over.
Do a Github release using the tag `shacl-x.y.z` above.
### Clearup
Check where any intermediate files are left over.
You may wish to build the new SNAPSHOT development version for your
local system with:
`mvn clean install`
and clean your local maven repository of old snapshots.
<MSG> Reflect maven central release process
<DFF> @@ -140,6 +140,8 @@ To push them up to central.maven, go to https://oss.sonatype.org/
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
+Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
+
### Clearup
Check where any intermediate files are left over.
| 2 | Reflect maven central release process | 0 | .md | md | apache-2.0 | TopQuadrant/shacl |
291 | <NME> process.md
<BEF> # Processes for the Project
This page describes processes for the SHACL API Project.
----
## Local Build
To build the latest snapshot code for your local system:
Clone the github repo, run maven in the local directory:
```
git clone https://github.com/TopQuadrant/shacl
cd shacl
mvn clean install
```
The latest SNAPSHOT code is now available in you local maven
repository. Check the pom.xml for the correct version string.
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>VERSION</version>
</dependency>
```
----
## Release
### Prerequisites
One time setup:
1. A PGP key for signing the release. This needs to be registered on one
of the public servers e.g. [http://pgpkeys.mit.edu/](http://pgpkeys.mit.edu/).
1. Write access to the GitHub repo - the release process updates the
versions and creates a tag.
1. Write access to the Sonatype OpenSource Hosting Nexus server for `org.topbraid`.
Put your user name and password for accessing the Sonatype open source
repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`).
```
<server>
<id>ossrh.snapshots</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
<server>
<id>ossrh.releases</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
```
### Setup Release Process
#### Versions
Choose the release version, next version and the tag, otherwise maven
will ask for these interactively:
```
export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"
```
The maven release plugin will move the version from the current SNAPSHOT
to the release version, and tag the github repository. It will also move
to the next SNAPSHOT version after building the release.
#### Signing
If you have multiple PGP keys, choose the right one:
`export KEY="-Darguments=-Dgpg.keyname=KEY_SIGNATURE"`
(Note the slightly odd value here; the release plugin calls maven
recursively and `-Darguments=` is maven recursively passing
down arguments to the subprocess.)
If you have only one key, set this to the empty string:
```
export KEY=""
```
or omit `$KEY` in the examples below.
### Dry run
It is advisable to dry run the release:
```
mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY
```
### Check
Look in `target/`.
You should see various files built including the binary ".bin.zip", the
javadoc (which is only done in the release cycle), `sources`, `tests`
and `test-sources`. The files should have been signed and `.asc` files
created.
If there is no javadoc jar or no `.asc` files, check you gave the
`-Prelease` argument.
It still says "SNAPSHOT" because the dry run does not change the version in POM.
### Do the release
This has two steps:
`mvn release:clean release:prepare -Prelease $KEY $VER`
`mvn release:perform -Prelease $KEY $VER`
### If it goes wrong:
`mvn release:rollback`
`mvn release:clean`
You may also need to delete the tag.
`git tag -d shacl-x.y.z`
`git push --delete origin shacl-x.y.z`
### Release to central
The steps so far pushed the built artifacts to the staging repository.
To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
### Clearup
Check where any intermediate files are left over.
Do a Github release using the tag `shacl-x.y.z` above.
### Clearup
Check where any intermediate files are left over.
You may wish to build the new SNAPSHOT development version for your
local system with:
`mvn clean install`
and clean your local maven repository of old snapshots.
<MSG> Reflect maven central release process
<DFF> @@ -140,6 +140,8 @@ To push them up to central.maven, go to https://oss.sonatype.org/
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
+Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
+
### Clearup
Check where any intermediate files are left over.
| 2 | Reflect maven central release process | 0 | .md | md | apache-2.0 | TopQuadrant/shacl |
292 | <NME> process.md
<BEF> # Processes for the Project
This page describes processes for the SHACL API Project.
----
## Local Build
To build the latest snapshot code for your local system:
Clone the github repo, run maven in the local directory:
```
git clone https://github.com/TopQuadrant/shacl
cd shacl
mvn clean install
```
The latest SNAPSHOT code is now available in you local maven
repository. Check the pom.xml for the correct version string.
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>VERSION</version>
</dependency>
```
----
## Release
### Prerequisites
One time setup:
1. A PGP key for signing the release. This needs to be registered on one
of the public servers e.g. [http://pgpkeys.mit.edu/](http://pgpkeys.mit.edu/).
1. Write access to the GitHub repo - the release process updates the
versions and creates a tag.
1. Write access to the Sonatype OpenSource Hosting Nexus server for `org.topbraid`.
Put your user name and password for accessing the Sonatype open source
repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`).
```
<server>
<id>ossrh.snapshots</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
<server>
<id>ossrh.releases</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
```
### Setup Release Process
#### Versions
Choose the release version, next version and the tag, otherwise maven
will ask for these interactively:
```
export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"
```
The maven release plugin will move the version from the current SNAPSHOT
to the release version, and tag the github repository. It will also move
to the next SNAPSHOT version after building the release.
#### Signing
If you have multiple PGP keys, choose the right one:
`export KEY="-Darguments=-Dgpg.keyname=KEY_SIGNATURE"`
(Note the slightly odd value here; the release plugin calls maven
recursively and `-Darguments=` is maven recursively passing
down arguments to the subprocess.)
If you have only one key, set this to the empty string:
```
export KEY=""
```
or omit `$KEY` in the examples below.
### Dry run
It is advisable to dry run the release:
```
mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY
```
### Check
Look in `target/`.
You should see various files built including the binary ".bin.zip", the
javadoc (which is only done in the release cycle), `sources`, `tests`
and `test-sources`. The files should have been signed and `.asc` files
created.
If there is no javadoc jar or no `.asc` files, check you gave the
`-Prelease` argument.
It still says "SNAPSHOT" because the dry run does not change the version in POM.
### Do the release
This has two steps:
`mvn release:clean release:prepare -Prelease $KEY $VER`
`mvn release:perform -Prelease $KEY $VER`
### If it goes wrong:
`mvn release:rollback`
`mvn release:clean`
You may also need to delete the tag.
`git tag -d shacl-x.y.z`
`git push --delete origin shacl-x.y.z`
### Release to central
The steps so far pushed the built artifacts to the staging repository.
To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Close it, at which point the checking rules run.
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
The release artifacts end up in "Repositories -> Releases -> org.topbraid".
### Github
Do a Github release using the tag `shacl-x.y.z` above.
### Clearup
Check where any intermediate files are left over.
You may wish to build the new SNAPSHOT development version for your
local system with:
`mvn clean install`
and clean your local maven repository of old snapshots.
<MSG> Merge branch 'master' of https://github.com/TopQuadrant/shacl
<DFF> @@ -138,11 +138,9 @@ To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Close it, at which point the checking rules run.
-* Refresh the webpage until rule checkign completes.
+* Refresh the webpage until rule checking completes.
* If all is good, click "release" at the top.
-Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
-
The release artifacts end up in "Repositories -> Releases -> org.topbraid".
### Github
| 1 | Merge branch 'master' of https://github.com/TopQuadrant/shacl | 3 | .md | md | apache-2.0 | TopQuadrant/shacl |
293 | <NME> process.md
<BEF> # Processes for the Project
This page describes processes for the SHACL API Project.
----
## Local Build
To build the latest snapshot code for your local system:
Clone the github repo, run maven in the local directory:
```
git clone https://github.com/TopQuadrant/shacl
cd shacl
mvn clean install
```
The latest SNAPSHOT code is now available in you local maven
repository. Check the pom.xml for the correct version string.
```
<dependency>
<groupId>org.topbraid</groupId>
<artifactId>shacl</artifactId>
<version>VERSION</version>
</dependency>
```
----
## Release
### Prerequisites
One time setup:
1. A PGP key for signing the release. This needs to be registered on one
of the public servers e.g. [http://pgpkeys.mit.edu/](http://pgpkeys.mit.edu/).
1. Write access to the GitHub repo - the release process updates the
versions and creates a tag.
1. Write access to the Sonatype OpenSource Hosting Nexus server for `org.topbraid`.
Put your user name and password for accessing the Sonatype open source
repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`).
```
<server>
<id>ossrh.snapshots</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
<server>
<id>ossrh.releases</id>
<username>SONATYPE_USERNAME</username>
<password>SONATYPE_PASSWORD</password>
</server>
```
### Setup Release Process
#### Versions
Choose the release version, next version and the tag, otherwise maven
will ask for these interactively:
```
export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"
```
The maven release plugin will move the version from the current SNAPSHOT
to the release version, and tag the github repository. It will also move
to the next SNAPSHOT version after building the release.
#### Signing
If you have multiple PGP keys, choose the right one:
`export KEY="-Darguments=-Dgpg.keyname=KEY_SIGNATURE"`
(Note the slightly odd value here; the release plugin calls maven
recursively and `-Darguments=` is maven recursively passing
down arguments to the subprocess.)
If you have only one key, set this to the empty string:
```
export KEY=""
```
or omit `$KEY` in the examples below.
### Dry run
It is advisable to dry run the release:
```
mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY
```
### Check
Look in `target/`.
You should see various files built including the binary ".bin.zip", the
javadoc (which is only done in the release cycle), `sources`, `tests`
and `test-sources`. The files should have been signed and `.asc` files
created.
If there is no javadoc jar or no `.asc` files, check you gave the
`-Prelease` argument.
It still says "SNAPSHOT" because the dry run does not change the version in POM.
### Do the release
This has two steps:
`mvn release:clean release:prepare -Prelease $KEY $VER`
`mvn release:perform -Prelease $KEY $VER`
### If it goes wrong:
`mvn release:rollback`
`mvn release:clean`
You may also need to delete the tag.
`git tag -d shacl-x.y.z`
`git push --delete origin shacl-x.y.z`
### Release to central
The steps so far pushed the built artifacts to the staging repository.
To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Close it, at which point the checking rules run.
* Refresh the webpage until rule checkign completes.
* If all is good, click "release" at the top.
Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
The release artifacts end up in "Repositories -> Releases -> org.topbraid".
### Github
Do a Github release using the tag `shacl-x.y.z` above.
### Clearup
Check where any intermediate files are left over.
You may wish to build the new SNAPSHOT development version for your
local system with:
`mvn clean install`
and clean your local maven repository of old snapshots.
<MSG> Merge branch 'master' of https://github.com/TopQuadrant/shacl
<DFF> @@ -138,11 +138,9 @@ To push them up to central.maven, go to https://oss.sonatype.org/
* Find repo (it's open) `orgtopbraid....`
* Check it ("content" tab)
* Close it, at which point the checking rules run.
-* Refresh the webpage until rule checkign completes.
+* Refresh the webpage until rule checking completes.
* If all is good, click "release" at the top.
-Note from 1.0.1: this happened automatically. The rules ran as part of `release:perform`.
-
The release artifacts end up in "Repositories -> Releases -> org.topbraid".
### Github
| 1 | Merge branch 'master' of https://github.com/TopQuadrant/shacl | 3 | .md | md | apache-2.0 | TopQuadrant/shacl |
294 | <NME> test.js
<BEF> ADDFILE
<MSG> Adding web test cases
<DFF> @@ -0,0 +1,181 @@
+// expected result
+var $rdf = require("rdflib");
+var rdflibgraph = require("../../src/rdflib-graph");
+var RDFLibGraph = rdflibgraph.RDFLibGraph;
+
+
+var ExpectedValidationResult = function(solution) {
+ this._id = solution["report"].value;
+
+ this._focusNode = solution["focusNode"].termType === "BlankNode" ? "_:" + solution["focusNode"].id : solution["focusNode"].value;
+ this._severity = solution["severity"].value;
+ this._constraint = solution["constraint"].value;
+ this._shape = solution["shape"].value;
+};
+
+ExpectedValidationResult.prototype.id = function() {
+ return this._id;
+}
+
+ExpectedValidationResult.prototype.focusNode = function() {
+ return this._focusNode;
+};
+
+ExpectedValidationResult.prototype.severity = function() {
+ if (this._severity != null) {
+ return this._severity.split("#")[1];
+ }
+};
+
+ExpectedValidationResult.prototype.sourceConstraintComponent = function() {
+ return this._constraint;
+};
+
+ExpectedValidationResult.prototype.sourceShape = function() {
+ return this._shape
+};
+
+
+var ExpectedValidationReport = function(graph) {
+ this.graph = graph;
+};
+
+ExpectedValidationReport.prototype.conforms = function() {
+ var conforms = this.graph.query()
+ .match("?report", "rdf:type", "sh:ValidationReport")
+ .match("?report", "sh:conforms", "?conforms")
+ .getNode("?conforms");
+ return conforms != null && conforms.value === "true"
+};
+
+ExpectedValidationReport.prototype.results = function() {
+ var acc = [];
+ var query = this.graph.query()
+ .match("?report", "sh:result", "?result")
+ .match("?result", "sh:focusNode", "?focusNode")
+ .match("?result", "sh:resultSeverity", "?severity")
+ .match("?result", "sh:sourceConstraintComponent", "?constraint")
+ .match("?result", "sh:sourceShape", "?shape");
+ var solution = query.nextSolution();
+ while (solution != null) {
+ acc.push(new ExpectedValidationResult(solution));
+ solution = query.nextSolution();
+ }
+ return acc;
+};
+
+var expectedResult = function(data, mediaType, cb) {
+ var store = $rdf.graph();
+ rdflibgraph.loadGraph(data, store, "http://test.com/example", mediaType, function() {
+ var graph = new RDFLibGraph(store);
+ var expectedValidationReport = new ExpectedValidationReport(graph);
+ expectedValidationReport.results();
+ cb(expectedValidationReport, null);
+ }, function(e) {
+ cb(null, e);
+ });
+};
+
+var isBlank = function(s) {
+ return s != null && (s.indexOf("_:") === 0 || s.indexOf("_g_") > -1);
+}
+
+var validateReports = function(test, done, data) {
+
+ expectedResult(data, "text/turtle", function(expectedReport, e) {
+ if (e != null) {
+ test.ok(e != null);
+ done();
+ } else {
+ new SHACLValidator().validate(data, "text/turtle", data, "text/turtle", function (e, report) {
+ if (e != null) {
+ test.ok(e != null);
+ done();
+ } else {
+ test.ok(report.conforms() === expectedReport.conforms());
+ test.ok(report.results().length === expectedReport.results().length);
+ var results = report.results() || [];
+ var expectedResults = expectedReport.results();
+ for (var i=0; i <results.length; i++) {
+ found = false;
+ for (var j=0; j<expectedResults.length; j++) {
+ if (//(results[i].focusNode() === expectedResults[j].focusNode() ) &&
+ results[i].severity() === expectedResults[j].severity() &&
+ ( (isBlank(results[i].sourceShape()) && isBlank(expectedResults[j].sourceShape())) ||
+ results[i].sourceShape() === expectedResults[j].sourceShape()) &&
+ results[i].sourceConstraintComponent() === expectedResults[j].sourceConstraintComponent()) {
+ found = true;
+ }
+
+ }
+ test.ok(found === true);
+ }
+ done();
+ }
+ });
+ }
+ });
+};
+
+var loadTestCases = function(k) {
+ var oReq = new XMLHttpRequest();
+ oReq.addEventListener("load", function() {
+ var cases = JSON.parse(this.responseText);
+ k(cases);
+ });
+ oReq.open("GET", "test_cases.json");
+ oReq.send();
+};
+
+var loadTestCase = function(testCase, k) {
+ var oReq = new XMLHttpRequest();
+ oReq.addEventListener("load", function() {
+ k(this.responseText);
+ });
+ oReq.open("GET", testCase);
+ oReq.send();
+};
+
+loadTestCases(function(testCases) {
+ for (var i=0; i<testCases.length; i++) {
+ (function(file) {
+ QUnit.test("Test case " + file, function(assert) {
+ var done = assert.async();
+ loadTestCase(file, function(data) {
+ validateReports(assert, done, data);
+ });
+ });
+ })(testCases[i])
+ }
+});
+
+
+/*
+
+
+QUnit.test("Integration test 2", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example2.data,
+ examples.example2.dataFormat,
+ examples.example2.shapes,
+ examples.example2.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "More than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#title");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MaxCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title");
+ done();
+ });
+});
+
+*/
\ No newline at end of file
| 181 | Adding web test cases | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
295 | <NME> test.js
<BEF> ADDFILE
<MSG> Adding web test cases
<DFF> @@ -0,0 +1,181 @@
+// expected result
+var $rdf = require("rdflib");
+var rdflibgraph = require("../../src/rdflib-graph");
+var RDFLibGraph = rdflibgraph.RDFLibGraph;
+
+
+var ExpectedValidationResult = function(solution) {
+ this._id = solution["report"].value;
+
+ this._focusNode = solution["focusNode"].termType === "BlankNode" ? "_:" + solution["focusNode"].id : solution["focusNode"].value;
+ this._severity = solution["severity"].value;
+ this._constraint = solution["constraint"].value;
+ this._shape = solution["shape"].value;
+};
+
+ExpectedValidationResult.prototype.id = function() {
+ return this._id;
+}
+
+ExpectedValidationResult.prototype.focusNode = function() {
+ return this._focusNode;
+};
+
+ExpectedValidationResult.prototype.severity = function() {
+ if (this._severity != null) {
+ return this._severity.split("#")[1];
+ }
+};
+
+ExpectedValidationResult.prototype.sourceConstraintComponent = function() {
+ return this._constraint;
+};
+
+ExpectedValidationResult.prototype.sourceShape = function() {
+ return this._shape
+};
+
+
+var ExpectedValidationReport = function(graph) {
+ this.graph = graph;
+};
+
+ExpectedValidationReport.prototype.conforms = function() {
+ var conforms = this.graph.query()
+ .match("?report", "rdf:type", "sh:ValidationReport")
+ .match("?report", "sh:conforms", "?conforms")
+ .getNode("?conforms");
+ return conforms != null && conforms.value === "true"
+};
+
+ExpectedValidationReport.prototype.results = function() {
+ var acc = [];
+ var query = this.graph.query()
+ .match("?report", "sh:result", "?result")
+ .match("?result", "sh:focusNode", "?focusNode")
+ .match("?result", "sh:resultSeverity", "?severity")
+ .match("?result", "sh:sourceConstraintComponent", "?constraint")
+ .match("?result", "sh:sourceShape", "?shape");
+ var solution = query.nextSolution();
+ while (solution != null) {
+ acc.push(new ExpectedValidationResult(solution));
+ solution = query.nextSolution();
+ }
+ return acc;
+};
+
+var expectedResult = function(data, mediaType, cb) {
+ var store = $rdf.graph();
+ rdflibgraph.loadGraph(data, store, "http://test.com/example", mediaType, function() {
+ var graph = new RDFLibGraph(store);
+ var expectedValidationReport = new ExpectedValidationReport(graph);
+ expectedValidationReport.results();
+ cb(expectedValidationReport, null);
+ }, function(e) {
+ cb(null, e);
+ });
+};
+
+var isBlank = function(s) {
+ return s != null && (s.indexOf("_:") === 0 || s.indexOf("_g_") > -1);
+}
+
+var validateReports = function(test, done, data) {
+
+ expectedResult(data, "text/turtle", function(expectedReport, e) {
+ if (e != null) {
+ test.ok(e != null);
+ done();
+ } else {
+ new SHACLValidator().validate(data, "text/turtle", data, "text/turtle", function (e, report) {
+ if (e != null) {
+ test.ok(e != null);
+ done();
+ } else {
+ test.ok(report.conforms() === expectedReport.conforms());
+ test.ok(report.results().length === expectedReport.results().length);
+ var results = report.results() || [];
+ var expectedResults = expectedReport.results();
+ for (var i=0; i <results.length; i++) {
+ found = false;
+ for (var j=0; j<expectedResults.length; j++) {
+ if (//(results[i].focusNode() === expectedResults[j].focusNode() ) &&
+ results[i].severity() === expectedResults[j].severity() &&
+ ( (isBlank(results[i].sourceShape()) && isBlank(expectedResults[j].sourceShape())) ||
+ results[i].sourceShape() === expectedResults[j].sourceShape()) &&
+ results[i].sourceConstraintComponent() === expectedResults[j].sourceConstraintComponent()) {
+ found = true;
+ }
+
+ }
+ test.ok(found === true);
+ }
+ done();
+ }
+ });
+ }
+ });
+};
+
+var loadTestCases = function(k) {
+ var oReq = new XMLHttpRequest();
+ oReq.addEventListener("load", function() {
+ var cases = JSON.parse(this.responseText);
+ k(cases);
+ });
+ oReq.open("GET", "test_cases.json");
+ oReq.send();
+};
+
+var loadTestCase = function(testCase, k) {
+ var oReq = new XMLHttpRequest();
+ oReq.addEventListener("load", function() {
+ k(this.responseText);
+ });
+ oReq.open("GET", testCase);
+ oReq.send();
+};
+
+loadTestCases(function(testCases) {
+ for (var i=0; i<testCases.length; i++) {
+ (function(file) {
+ QUnit.test("Test case " + file, function(assert) {
+ var done = assert.async();
+ loadTestCase(file, function(data) {
+ validateReports(assert, done, data);
+ });
+ });
+ })(testCases[i])
+ }
+});
+
+
+/*
+
+
+QUnit.test("Integration test 2", function (assert) {
+ var done = assert.async();
+ new SHACLValidator().validate(
+ examples.example2.data,
+ examples.example2.dataFormat,
+ examples.example2.shapes,
+ examples.example2.shapesFormat,
+ function (e, report) {
+ if (e != null) {
+ console.log(e);
+ }
+ assert.ok(e == null);
+ assert.ok(!report.conforms());
+ var results = report.results();
+ assert.ok(results.length === 1);
+ assert.ok(results[0].message() === "More than 1 values");
+ assert.ok(results[0].path() === "http://raml.org/vocabularies/shapes/anon#title");
+ assert.ok(results[0].focusNode() !== null);
+ assert.ok(results[0].severity() === "Violation");
+ assert.ok(results[0].sourceConstraintComponent() === "http://www.w3.org/ns/shacl#MaxCountConstraintComponent");
+ assert.ok(results[0].sourceShape() === "https://mulesoft-labs.github.io/amf-playground/raml/world-music-api/api.raml#/definitions/Entry/items/0/property/title");
+ done();
+ });
+});
+
+*/
\ No newline at end of file
| 181 | Adding web test cases | 0 | .js | js | apache-2.0 | TopQuadrant/shacl |
296 | <NME> sparql-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.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/sparql/property/LanguageExamplePropertyShape.test>
rdf:type owl:Ontology ;
rdfs:label "Test of LanguageExamplePropertyShape" ;
owl:imports <http://datashapes.org/dash> ;
owl:versionInfo "Created with TopBraid Composer" ;
.
ex:Country
rdf:type rdfs:Class ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidCountry ;
sh:resultPath ex:germanLabel ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraint ex:LanguageExamplePropertyShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape ex:LanguageExamplePropertyShape ;
sh:value "Spain"@en ;
] ;
] ;
.
ex:InvalidCountry
rdf:type ex:Country ;
ex:germanLabel "Spain"@en ;
.
ex:LanguageExamplePropertyShape
rdf:type sh:PropertyShape ;
sh:path ex:germanLabel ;
sh:sparql ex:LanguageExamplePropertyShape-sparql ;
sh:targetClass ex:Country ;
.
ex:LanguageExamplePropertyShape-sparql
rdf:type sh:SPARQLConstraint ;
sh:message "Values are literals with German language tag." ;
sh:prefixes ex: ;
sh:select """
SELECT $this ?value
WHERE {
$this $PATH ?value .
FILTER (!isLiteral(?value) || !langMatches(lang(?value), \"de\"))
}
""" ;
.
ex:ValidCountry
rdf:type ex:Country ;
ex:germanLabel "Spanien"@de ;
.
<MSG> Fixed () error with sh:path syntax in SPARQL, latest test cases
<DFF> @@ -1,20 +1,19 @@
-# baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
+# baseURI: http://datashapes.org/sh/tests/sparql/property/sparql-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
-@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/property/sparql-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/sparql/property/LanguageExamplePropertyShape.test>
+<http://datashapes.org/sh/tests/sparql/property/sparql-001.test>
rdf:type owl:Ontology ;
- rdfs:label "Test of LanguageExamplePropertyShape" ;
+ rdfs:label "Test of sh:sparql at property shape 001" ;
owl:imports <http://datashapes.org/dash> ;
- owl:versionInfo "Created with TopBraid Composer" ;
.
ex:Country
rdf:type rdfs:Class ;
| 4 | Fixed () error with sh:path syntax in SPARQL, latest test cases | 5 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
297 | <NME> sparql-001.test.ttl
<BEF> # baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.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/sparql/property/LanguageExamplePropertyShape.test>
rdf:type owl:Ontology ;
rdfs:label "Test of LanguageExamplePropertyShape" ;
owl:imports <http://datashapes.org/dash> ;
owl:versionInfo "Created with TopBraid Composer" ;
.
ex:Country
rdf:type rdfs:Class ;
.
ex:GraphValidationTestCase
rdf:type dash:GraphValidationTestCase ;
dash:expectedResult [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidCountry ;
sh:resultPath ex:germanLabel ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraint ex:LanguageExamplePropertyShape-sparql ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape ex:LanguageExamplePropertyShape ;
sh:value "Spain"@en ;
] ;
] ;
.
ex:InvalidCountry
rdf:type ex:Country ;
ex:germanLabel "Spain"@en ;
.
ex:LanguageExamplePropertyShape
rdf:type sh:PropertyShape ;
sh:path ex:germanLabel ;
sh:sparql ex:LanguageExamplePropertyShape-sparql ;
sh:targetClass ex:Country ;
.
ex:LanguageExamplePropertyShape-sparql
rdf:type sh:SPARQLConstraint ;
sh:message "Values are literals with German language tag." ;
sh:prefixes ex: ;
sh:select """
SELECT $this ?value
WHERE {
$this $PATH ?value .
FILTER (!isLiteral(?value) || !langMatches(lang(?value), \"de\"))
}
""" ;
.
ex:ValidCountry
rdf:type ex:Country ;
ex:germanLabel "Spanien"@de ;
.
<MSG> Fixed () error with sh:path syntax in SPARQL, latest test cases
<DFF> @@ -1,20 +1,19 @@
-# baseURI: http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test
+# baseURI: http://datashapes.org/sh/tests/sparql/property/sparql-001.test
# imports: http://datashapes.org/dash
# prefix: ex
@prefix dash: <http://datashapes.org/dash#> .
-@prefix ex: <http://datashapes.org/sh/tests/sparql/property/LanguageExamplePropertyShape.test#> .
+@prefix ex: <http://datashapes.org/sh/tests/sparql/property/sparql-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/sparql/property/LanguageExamplePropertyShape.test>
+<http://datashapes.org/sh/tests/sparql/property/sparql-001.test>
rdf:type owl:Ontology ;
- rdfs:label "Test of LanguageExamplePropertyShape" ;
+ rdfs:label "Test of sh:sparql at property shape 001" ;
owl:imports <http://datashapes.org/dash> ;
- owl:versionInfo "Created with TopBraid Composer" ;
.
ex:Country
rdf:type rdfs:Class ;
| 4 | Fixed () error with sh:path syntax in SPARQL, latest test cases | 5 | .ttl | test | apache-2.0 | TopQuadrant/shacl |
298 | <NME> SPARQLSubstitutions.java
<BEF> ADDFILE
<MSG> (Corrected Git glitch from previous commit)
<DFF> @@ -0,0 +1,212 @@
+package org.topbraid.shacl.constraints.sparql;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.topbraid.shacl.arq.functions.ScopeContainsPFunction;
+import org.topbraid.shacl.constraints.ModelConstraintValidator;
+import org.topbraid.shacl.constraints.SHACLException;
+import org.topbraid.shacl.vocabulary.SH;
+import org.topbraid.spin.arq.ARQFactory;
+import org.topbraid.spin.system.SPINLabels;
+import org.topbraid.spin.util.JenaUtil;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryParseException;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.vocabulary.RDFS;
+
+/**
+ * Collects various dodgy helper algorithms currently used by the SPARQL execution language.
+ *
+ * TODO: These should likely operate on clones of the Query syntax tree instead of query strings.
+ *
+ * @author Holger Knublauch
+ */
+class SPARQLSubstitutions {
+
+ public static void addMessageVarNames(String labelTemplate, Set<String> results) {
+ for(int i = 0; i < labelTemplate.length(); i++) {
+ if(i < labelTemplate.length() - 3 && labelTemplate.charAt(i) == '{' && labelTemplate.charAt(i + 1) == '?') {
+ int varEnd = i + 2;
+ while(varEnd < labelTemplate.length()) {
+ if(labelTemplate.charAt(varEnd) == '}') {
+ String varName = labelTemplate.substring(i + 2, varEnd);
+ results.add(varName);
+ break;
+ }
+ else {
+ varEnd++;
+ }
+ }
+ i = varEnd;
+ }
+ }
+ }
+
+
+ // TODO: Algorithm incorrect, e.g. if { is included as a comment
+ static Query insertFilterClause(Query query, int scopeCount) {
+ String str = query.toString();
+ Pattern pattern = Pattern.compile("(?i)WHERE\\s*\\{");
+ Matcher matcher = pattern.matcher(str);
+ if(matcher.find()) {
+ int index = matcher.end();
+ StringBuilder sb = new StringBuilder(str);
+
+ StringBuffer s = new StringBuffer();
+ for(int i = 0; i < scopeCount; i++) {
+ s.append("{ FILTER <");
+ s.append(SH.hasShape.getURI());
+ s.append(">(?this, ?");
+ s.append(ModelConstraintValidator.FILTER_VAR_NAME + i);
+ s.append(", ?" + SH.shapesGraphVar.getVarName() + ") }");
+ }
+
+ sb.insert(index, s.toString());
+ return ARQFactory.get().createQuery(sb.toString());
+ }
+ else {
+ throw new IllegalArgumentException("Cannot find first '{' in query string: " + str);
+ }
+ }
+
+
+ // TODO: Algorithm incorrect, e.g. if { is included as a comment
+ static Query insertScopeAndFilterClauses(Query query, int filterCount, Resource shape, Dataset dataset, QuerySolution binding) {
+ String str = query.toString();
+ Pattern pattern = Pattern.compile("(?i)WHERE\\s*\\{");
+ Matcher matcher = pattern.matcher(str);
+ if(matcher.find()) {
+ int index = matcher.end();
+ StringBuilder sb = new StringBuilder(str);
+
+ StringBuffer s = new StringBuffer();
+ s.append(" {\n SELECT DISTINCT ?" + SH.thisVar.getName() + " ?" + SH.shapesGraphVar.getName() + " ?" + SH.currentShapeVar.getName());
+
+ // We need to enumerate template call arguments here because Jena would otherwise drop the pre-bound variables
+ Iterator<String> varNames = binding.varNames();
+ while(varNames.hasNext()) {
+ String varName = varNames.next();
+ s.append(" ?" + varName);
+ }
+
+ s.append("\nWHERE {\n");
+ appendScopes(s, shape, dataset);
+ s.append(" } }\n");
+ for(int i = 0; i < filterCount; i++) {
+ s.append(" FILTER <");
+ s.append(SH.hasShape.getURI());
+ s.append(">(?this, ?");
+ s.append(ModelConstraintValidator.FILTER_VAR_NAME + i);
+ s.append(", ?" + SH.shapesGraphVar.getVarName() + ") .");
+ }
+
+ sb.insert(index, s.toString());
+ try {
+ return ARQFactory.get().createQuery(sb.toString());
+ }
+ catch(QueryParseException ex) {
+ System.err.println("Failed to parse query:\n" + sb);
+ throw ex;
+ }
+ }
+ else {
+ throw new IllegalArgumentException("Cannot find first '{' in query string: " + str);
+ }
+ }
+
+
+ static Literal withSubstitutions(Literal template, QuerySolution bindings) {
+ StringBuffer buffer = new StringBuffer();
+ String labelTemplate = template.getLexicalForm();
+ for(int i = 0; i < labelTemplate.length(); i++) {
+ if(i < labelTemplate.length() - 3 && labelTemplate.charAt(i) == '{' && (labelTemplate.charAt(i + 1) == '?' || labelTemplate.charAt(i + 1) == '$')) {
+ int varEnd = i + 2;
+ while(varEnd < labelTemplate.length()) {
+ if(labelTemplate.charAt(varEnd) == '}') {
+ String varName = labelTemplate.substring(i + 2, varEnd);
+ RDFNode varValue = bindings.get(varName);
+ if(varValue instanceof Resource) {
+ buffer.append(SPINLabels.get().getLabel((Resource)varValue));
+ }
+ else if(varValue instanceof Literal) {
+ buffer.append(varValue.asNode().getLiteralLexicalForm());
+ }
+ break;
+ }
+ else {
+ varEnd++;
+ }
+ }
+ i = varEnd;
+ }
+ else {
+ buffer.append(labelTemplate.charAt(i));
+ }
+ }
+ if(template.getLanguage().isEmpty()) {
+ return ResourceFactory.createTypedLiteral(buffer.toString());
+ }
+ else {
+ return ResourceFactory.createLangLiteral(buffer.toString(), template.getLanguage());
+ }
+ }
+
+
+ private static void appendScopes(StringBuffer sb, Resource shape, Dataset dataset) {
+
+ List<String> scopes = new LinkedList<String>();
+
+ if(shape.getModel().contains(shape, SH.scopeNode, (RDFNode)null)) {
+ scopes.add(" GRAPH $shapesGraph { $" + SH.currentShapeVar.getName() + " <" + SH.scopeNode + "> ?this } .\n");
+ }
+
+ if(JenaUtil.hasIndirectType(shape, RDFS.Class)) {
+ String varName = "?CLASS_VAR";
+ scopes.add(" " + varName + " <" + RDFS.subClassOf + ">* $" + SH.currentShapeVar.getName() + " .\n ?this a " + varName + " .\n");
+ }
+
+ for(Resource cls : JenaUtil.getResourceProperties(shape, SH.scopeClass)) {
+ String varName = "?SHAPE_CLASS_VAR";
+ scopes.add(" " + varName + " <" + RDFS.subClassOf + ">* <" + cls + "> .\n ?this a " + varName + " .\n");
+ }
+
+ if(shape.hasProperty(SH.scope)) {
+ scopes.add(createScopes(shape));
+ }
+
+ if(scopes.isEmpty()) {
+ throw new SHACLException("Unscoped shape " + shape);
+ }
+ else if(scopes.size() == 1) {
+ sb.append(scopes.get(0));
+ }
+ else {
+ for(int i = 0; i < scopes.size(); i++) {
+ sb.append(" {");
+ sb.append(scopes.get(i));
+ sb.append(" }");
+ if(i < scopes.size() - 1) {
+ sb.append(" UNION\n");
+ }
+ }
+ }
+ }
+
+
+ private static String createScopes(Resource shape) {
+ String scopeVar = "?scpe_" + (int)(Math.random() * 10000);
+ return " GRAPH $" + SH.shapesGraphVar.getName() + " { $" + SH.currentShapeVar.getName() + " <" + SH.scope + "> " + scopeVar + "} .\n" +
+ " (" + scopeVar + " $" + SH.shapesGraphVar.getName() + ") <" + ScopeContainsPFunction.URI + "> ?this .\n";
+ }
+ }
| 212 | (Corrected Git glitch from previous commit) | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |
299 | <NME> SPARQLSubstitutions.java
<BEF> ADDFILE
<MSG> (Corrected Git glitch from previous commit)
<DFF> @@ -0,0 +1,212 @@
+package org.topbraid.shacl.constraints.sparql;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.topbraid.shacl.arq.functions.ScopeContainsPFunction;
+import org.topbraid.shacl.constraints.ModelConstraintValidator;
+import org.topbraid.shacl.constraints.SHACLException;
+import org.topbraid.shacl.vocabulary.SH;
+import org.topbraid.spin.arq.ARQFactory;
+import org.topbraid.spin.system.SPINLabels;
+import org.topbraid.spin.util.JenaUtil;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryParseException;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.vocabulary.RDFS;
+
+/**
+ * Collects various dodgy helper algorithms currently used by the SPARQL execution language.
+ *
+ * TODO: These should likely operate on clones of the Query syntax tree instead of query strings.
+ *
+ * @author Holger Knublauch
+ */
+class SPARQLSubstitutions {
+
+ public static void addMessageVarNames(String labelTemplate, Set<String> results) {
+ for(int i = 0; i < labelTemplate.length(); i++) {
+ if(i < labelTemplate.length() - 3 && labelTemplate.charAt(i) == '{' && labelTemplate.charAt(i + 1) == '?') {
+ int varEnd = i + 2;
+ while(varEnd < labelTemplate.length()) {
+ if(labelTemplate.charAt(varEnd) == '}') {
+ String varName = labelTemplate.substring(i + 2, varEnd);
+ results.add(varName);
+ break;
+ }
+ else {
+ varEnd++;
+ }
+ }
+ i = varEnd;
+ }
+ }
+ }
+
+
+ // TODO: Algorithm incorrect, e.g. if { is included as a comment
+ static Query insertFilterClause(Query query, int scopeCount) {
+ String str = query.toString();
+ Pattern pattern = Pattern.compile("(?i)WHERE\\s*\\{");
+ Matcher matcher = pattern.matcher(str);
+ if(matcher.find()) {
+ int index = matcher.end();
+ StringBuilder sb = new StringBuilder(str);
+
+ StringBuffer s = new StringBuffer();
+ for(int i = 0; i < scopeCount; i++) {
+ s.append("{ FILTER <");
+ s.append(SH.hasShape.getURI());
+ s.append(">(?this, ?");
+ s.append(ModelConstraintValidator.FILTER_VAR_NAME + i);
+ s.append(", ?" + SH.shapesGraphVar.getVarName() + ") }");
+ }
+
+ sb.insert(index, s.toString());
+ return ARQFactory.get().createQuery(sb.toString());
+ }
+ else {
+ throw new IllegalArgumentException("Cannot find first '{' in query string: " + str);
+ }
+ }
+
+
+ // TODO: Algorithm incorrect, e.g. if { is included as a comment
+ static Query insertScopeAndFilterClauses(Query query, int filterCount, Resource shape, Dataset dataset, QuerySolution binding) {
+ String str = query.toString();
+ Pattern pattern = Pattern.compile("(?i)WHERE\\s*\\{");
+ Matcher matcher = pattern.matcher(str);
+ if(matcher.find()) {
+ int index = matcher.end();
+ StringBuilder sb = new StringBuilder(str);
+
+ StringBuffer s = new StringBuffer();
+ s.append(" {\n SELECT DISTINCT ?" + SH.thisVar.getName() + " ?" + SH.shapesGraphVar.getName() + " ?" + SH.currentShapeVar.getName());
+
+ // We need to enumerate template call arguments here because Jena would otherwise drop the pre-bound variables
+ Iterator<String> varNames = binding.varNames();
+ while(varNames.hasNext()) {
+ String varName = varNames.next();
+ s.append(" ?" + varName);
+ }
+
+ s.append("\nWHERE {\n");
+ appendScopes(s, shape, dataset);
+ s.append(" } }\n");
+ for(int i = 0; i < filterCount; i++) {
+ s.append(" FILTER <");
+ s.append(SH.hasShape.getURI());
+ s.append(">(?this, ?");
+ s.append(ModelConstraintValidator.FILTER_VAR_NAME + i);
+ s.append(", ?" + SH.shapesGraphVar.getVarName() + ") .");
+ }
+
+ sb.insert(index, s.toString());
+ try {
+ return ARQFactory.get().createQuery(sb.toString());
+ }
+ catch(QueryParseException ex) {
+ System.err.println("Failed to parse query:\n" + sb);
+ throw ex;
+ }
+ }
+ else {
+ throw new IllegalArgumentException("Cannot find first '{' in query string: " + str);
+ }
+ }
+
+
+ static Literal withSubstitutions(Literal template, QuerySolution bindings) {
+ StringBuffer buffer = new StringBuffer();
+ String labelTemplate = template.getLexicalForm();
+ for(int i = 0; i < labelTemplate.length(); i++) {
+ if(i < labelTemplate.length() - 3 && labelTemplate.charAt(i) == '{' && (labelTemplate.charAt(i + 1) == '?' || labelTemplate.charAt(i + 1) == '$')) {
+ int varEnd = i + 2;
+ while(varEnd < labelTemplate.length()) {
+ if(labelTemplate.charAt(varEnd) == '}') {
+ String varName = labelTemplate.substring(i + 2, varEnd);
+ RDFNode varValue = bindings.get(varName);
+ if(varValue instanceof Resource) {
+ buffer.append(SPINLabels.get().getLabel((Resource)varValue));
+ }
+ else if(varValue instanceof Literal) {
+ buffer.append(varValue.asNode().getLiteralLexicalForm());
+ }
+ break;
+ }
+ else {
+ varEnd++;
+ }
+ }
+ i = varEnd;
+ }
+ else {
+ buffer.append(labelTemplate.charAt(i));
+ }
+ }
+ if(template.getLanguage().isEmpty()) {
+ return ResourceFactory.createTypedLiteral(buffer.toString());
+ }
+ else {
+ return ResourceFactory.createLangLiteral(buffer.toString(), template.getLanguage());
+ }
+ }
+
+
+ private static void appendScopes(StringBuffer sb, Resource shape, Dataset dataset) {
+
+ List<String> scopes = new LinkedList<String>();
+
+ if(shape.getModel().contains(shape, SH.scopeNode, (RDFNode)null)) {
+ scopes.add(" GRAPH $shapesGraph { $" + SH.currentShapeVar.getName() + " <" + SH.scopeNode + "> ?this } .\n");
+ }
+
+ if(JenaUtil.hasIndirectType(shape, RDFS.Class)) {
+ String varName = "?CLASS_VAR";
+ scopes.add(" " + varName + " <" + RDFS.subClassOf + ">* $" + SH.currentShapeVar.getName() + " .\n ?this a " + varName + " .\n");
+ }
+
+ for(Resource cls : JenaUtil.getResourceProperties(shape, SH.scopeClass)) {
+ String varName = "?SHAPE_CLASS_VAR";
+ scopes.add(" " + varName + " <" + RDFS.subClassOf + ">* <" + cls + "> .\n ?this a " + varName + " .\n");
+ }
+
+ if(shape.hasProperty(SH.scope)) {
+ scopes.add(createScopes(shape));
+ }
+
+ if(scopes.isEmpty()) {
+ throw new SHACLException("Unscoped shape " + shape);
+ }
+ else if(scopes.size() == 1) {
+ sb.append(scopes.get(0));
+ }
+ else {
+ for(int i = 0; i < scopes.size(); i++) {
+ sb.append(" {");
+ sb.append(scopes.get(i));
+ sb.append(" }");
+ if(i < scopes.size() - 1) {
+ sb.append(" UNION\n");
+ }
+ }
+ }
+ }
+
+
+ private static String createScopes(Resource shape) {
+ String scopeVar = "?scpe_" + (int)(Math.random() * 10000);
+ return " GRAPH $" + SH.shapesGraphVar.getName() + " { $" + SH.currentShapeVar.getName() + " <" + SH.scope + "> " + scopeVar + "} .\n" +
+ " (" + scopeVar + " $" + SH.shapesGraphVar.getName() + ") <" + ScopeContainsPFunction.URI + "> ?this .\n";
+ }
+ }
| 212 | (Corrected Git glitch from previous commit) | 0 | .java | java | apache-2.0 | TopQuadrant/shacl |