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
0
<NME> rdfquery.js <BEF> ADDFILE <MSG> SHACL-JS progress <DFF> @@ -0,0 +1,313 @@ +// rdfquery.js +// A simple RDF query library for JavaScript +// Contact: holger@topquadrant.com +// +// The basic idea is that the function RDFQuery produces an initial +// Query object, which starts with a single "empty" solution. +// Each query object has a function nextSolution() producing an iteration +// of variable bindings ("volcano style"). +// Each query object can be refined with subsequent calls to other +// functions, producing new queries. +// Invoking nextSolution on a query will pull solutions from its +// predecessors in a chain of query objects. +// Finally, functions such as .first() and .toArray() can be used +// to produce individual values. +// The solution objects are plain JavaScript objects providing a +// mapping from variable names to RDF Term objects. +// Unless a query has been walked to exhaustion, .close() must be called. +// +// RDF Term objects are expected to follow the contracts from the +// RDF Representation Task Force's interface specification: +// https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md +// +// In order to bootstrap all this, graph objects need to implement a +// function .find(s, p, o) where each parameter is either an RDF term or null +// producing an iterator object with a .next() function that produces RDF triples +// (with attributes subject, predicate, object) or null when done. +// +// (Note I am not particularly a JavaScript guru so the modularization of this +// script may be improved to hide private members from public API etc). + +/* Example: + var result = RDFQuery($dataGraph). + find(OWL.Class, RDFS.label, "label"). + find("otherClass", RDFS.label, "label"). + filter(function(solution) { return !OWL.Class.equals(solution.otherClass) }). + first().otherClass; + +Equivalent SPARQL: + SELECT ?otherClass + WHERE { + owl:Class rdfs:label ?label . + ?otherClass rdfs:label ?label . + FILTER (owl:Class != ?otherClass) . + } LIMIT 1 +*/ + + +function _Namespace (nsuri) { + return function (localName) { + return TermFactory.namedNode(nsuri + localName); + } +} + +// Suggested container object for all frequently needed namespaces +// Usage to get rdf:type: NS.rdf("type") +var NS = { + rdf : _Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'), + rdfs : _Namespace('http://www.w3.org/2000/01/rdf-schema#'), + sh : _Namespace('http://www.w3.org/ns/shacl#'), + owl : _Namespace('http://www.w3.org/2002/07/owl#'), + xsd : _Namespace('http://www.w3.org/2001/XMLSchema#') +} + +var OWL = { + Class : NS.owl("Class"), + DatatypeProperty : NS.owl("DatatypeProperty"), + ObjectProperty : NS.owl("ObjectProperty") +} + +var RDF = { + HTML : NS.rdf("HTML"), + List : NS.rdf("List"), + Property : NS.rdf("Property"), + Statement : NS.rdf("Statement"), + first : NS.rdf("first"), + langString : NS.rdf("langString"), + nil : NS.rdf("nil"), + object : NS.rdf("object"), + predicate : NS.rdf("predicate"), + rest : NS.rdf("rest"), + subject : NS.rdf("subject"), + type : NS.rdf("type"), + value : NS.rdf("value") +} + +var RDFS = { + Class : NS.rdfs("Class"), + Datatype : NS.rdfs("Datatype"), + Literal : NS.rdfs("Literal"), + Resource : NS.rdfs("Resource"), + comment : NS.rdfs("comment"), + domain : NS.rdfs("domain"), + label : NS.rdfs("label"), + range : NS.rdfs("range"), + seeAlso : NS.rdfs("seeAlso"), + subClassOf : NS.rdfs("subClassOf"), + subPropertyOf : NS.rdfs("subPropertyOf") +} + +var XSD = { + boolean : NS.xsd("boolean"), + date : NS.xsd("date"), + dateTime : NS.xsd("dateTime"), + decimal : NS.xsd("decimal"), + float : NS.xsd("float"), + integer : NS.xsd("integer"), + string : NS.xsd("string") +}; + + +/** + * Creates a query object for a given graph and optional initial solution. + * The resulting object can be further refined using the functions on + * AbstractQuery such as <code>find()</code> and <code>filter()</code>. + * Functions such as <code>nextSolution()</code> can be used to get the actual results. + * @param graph the graph to query + * @param initialSolution the initial solutions or null for none + * @returns a query object + */ +function RDFQuery(graph, initialSolution) { + return new StartQuery(graph, initialSolution ? initialSolution : []); +} + + +// class AbstractQuery + +function AbstractQuery() { +} + +/** + * Creates a new query that filters the solutions produced by this. + * @param filterFunction a function that takes a solution object + * and returns true iff that solution is valid + */ +AbstractQuery.prototype.filter = function(filterFunction) { + return new FilterQuery(this, filterFunction); +} + +// TODO: add other SPARQL-like query types +// - .distinct() +// - .bind(varName, function(solution)) +// - . +// - .limit() +// - .path(s, path, o) (this is complex) +// - .sort(varName, [comparatorFunction]) +// - .union(otherQuery) + +/** + * Creates a new query doing a triple match. + * @param s the match subject or null (any) or a variable name (string) + * @param p the match predicate or null (any) or a variable name (string) + * @param o the match object or null (any) or a variable name (string) + */ +AbstractQuery.prototype.find = function(s, p, o) { + return new RDFTripleQuery(this, s, p, o); +} + +/** + * Gets the next solution and closes the query. + * @return a solution object + */ +AbstractQuery.prototype.first = function() { + var n = this.nextSolution(); + this.close(); + return n; +} + +/** + * Turns all results into an array. + * @return a array consisting of solution objects + */ +AbstractQuery.prototype.toArray = function() { + var results = []; + for(var n = this.nextSolution(); n != null; n = this.nextSolution()) { + results.push(n); + } + return results; +} + + +// class FilterQuery +// Filters the incoming solutions, only letting through those where +// filterFunction(solution) returns true + +function FilterQuery(input, filterFunction) { + this.source = input.source; + this.input = input; + this.filterFunction = filterFunction; +} + +FilterQuery.prototype = Object.create(AbstractQuery.prototype); + +FilterQuery.prototype.close = function() { + this.input.close(); +} + +// Pulls the next result from the input Query and passes it into +// the given filter function +FilterQuery.prototype.nextSolution = function() { + for(;;) { + var result = this.input.nextSolution(); + if(result == null) { + return null; + } + else if(this.filterFunction(result) === true) { + return result; + } + } +} + + +// class RDFTripleQuery +// Joins the solutions from the input Query with triple matches against +// the current input graph. + +function RDFTripleQuery(input, s, p, o) { + this.source = input.source; + this.input = input; + this.s = s; + this.p = p; + this.o = o; +} + +RDFTripleQuery.prototype = Object.create(AbstractQuery.prototype); + +RDFTripleQuery.prototype.close = function() { + this.input.close(); + if(this.ownIterator) { + this.ownIterator.close(); + } +} + +// This pulls the first solution from the input Query and uses it to +// create an "ownIterator" which applies the input solution to those +// specified by s, p, o. +// Once this "ownIterator" has been exhausted, it moves to the next +// solution from the input Query, and so on. +// At each step, it produces the union of the input solutions plus the +// own solutions. +RDFTripleQuery.prototype.nextSolution = function() { + + var oit = this.ownIterator; + if(oit) { + var n = oit.next(); + if(n != null) { + var result = createSolution(this.inputSolution); + if(typeof this.s === 'string') { + result[this.s] = n.subject; + } + if(typeof this.p === 'string') { + result[this.p] = n.predicate; + } + if(typeof this.o === 'string') { + result[this.o] = n.object; + } + return result; + } + else { + delete this.ownIterator; // Mark as exhausted + } + } + + // Pull from input + this.inputSolution = this.input.nextSolution(); + if(this.inputSolution) { + var sm = (typeof this.s === 'string') ? this.inputSolution[this.s] : this.s; + var pm = (typeof this.p === 'string') ? this.inputSolution[this.p] : this.p; + var om = (typeof this.o === 'string') ? this.inputSolution[this.o] : this.o; + this.ownIterator = this.source.find(sm, pm, om) + return this.nextSolution(); + } + else { + return null; + } +} + + +// class StartQuery +// This simply produces a single result: the initial solution + +function StartQuery(source, initialSolution) { + this.source = source; + this.solution = initialSolution; +} + +StartQuery.prototype = Object.create(AbstractQuery.prototype); + +StartQuery.prototype.close = function() { +} + +StartQuery.prototype.nextSolution = function() { + if(this.solution) { + var b = this.solution; + delete this.solution; + return b; + } + else { + return null; + } +} + + +// Helper functions + +function createSolution(base) { + var result = {}; + for(var attr in base) { + if(base.hasOwnProperty(attr)) { + result[attr] = base[attr]; + } + } + return result; +}
313
SHACL-JS progress
0
.js
js
apache-2.0
TopQuadrant/shacl
1
<NME> rdfquery.js <BEF> ADDFILE <MSG> SHACL-JS progress <DFF> @@ -0,0 +1,313 @@ +// rdfquery.js +// A simple RDF query library for JavaScript +// Contact: holger@topquadrant.com +// +// The basic idea is that the function RDFQuery produces an initial +// Query object, which starts with a single "empty" solution. +// Each query object has a function nextSolution() producing an iteration +// of variable bindings ("volcano style"). +// Each query object can be refined with subsequent calls to other +// functions, producing new queries. +// Invoking nextSolution on a query will pull solutions from its +// predecessors in a chain of query objects. +// Finally, functions such as .first() and .toArray() can be used +// to produce individual values. +// The solution objects are plain JavaScript objects providing a +// mapping from variable names to RDF Term objects. +// Unless a query has been walked to exhaustion, .close() must be called. +// +// RDF Term objects are expected to follow the contracts from the +// RDF Representation Task Force's interface specification: +// https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md +// +// In order to bootstrap all this, graph objects need to implement a +// function .find(s, p, o) where each parameter is either an RDF term or null +// producing an iterator object with a .next() function that produces RDF triples +// (with attributes subject, predicate, object) or null when done. +// +// (Note I am not particularly a JavaScript guru so the modularization of this +// script may be improved to hide private members from public API etc). + +/* Example: + var result = RDFQuery($dataGraph). + find(OWL.Class, RDFS.label, "label"). + find("otherClass", RDFS.label, "label"). + filter(function(solution) { return !OWL.Class.equals(solution.otherClass) }). + first().otherClass; + +Equivalent SPARQL: + SELECT ?otherClass + WHERE { + owl:Class rdfs:label ?label . + ?otherClass rdfs:label ?label . + FILTER (owl:Class != ?otherClass) . + } LIMIT 1 +*/ + + +function _Namespace (nsuri) { + return function (localName) { + return TermFactory.namedNode(nsuri + localName); + } +} + +// Suggested container object for all frequently needed namespaces +// Usage to get rdf:type: NS.rdf("type") +var NS = { + rdf : _Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'), + rdfs : _Namespace('http://www.w3.org/2000/01/rdf-schema#'), + sh : _Namespace('http://www.w3.org/ns/shacl#'), + owl : _Namespace('http://www.w3.org/2002/07/owl#'), + xsd : _Namespace('http://www.w3.org/2001/XMLSchema#') +} + +var OWL = { + Class : NS.owl("Class"), + DatatypeProperty : NS.owl("DatatypeProperty"), + ObjectProperty : NS.owl("ObjectProperty") +} + +var RDF = { + HTML : NS.rdf("HTML"), + List : NS.rdf("List"), + Property : NS.rdf("Property"), + Statement : NS.rdf("Statement"), + first : NS.rdf("first"), + langString : NS.rdf("langString"), + nil : NS.rdf("nil"), + object : NS.rdf("object"), + predicate : NS.rdf("predicate"), + rest : NS.rdf("rest"), + subject : NS.rdf("subject"), + type : NS.rdf("type"), + value : NS.rdf("value") +} + +var RDFS = { + Class : NS.rdfs("Class"), + Datatype : NS.rdfs("Datatype"), + Literal : NS.rdfs("Literal"), + Resource : NS.rdfs("Resource"), + comment : NS.rdfs("comment"), + domain : NS.rdfs("domain"), + label : NS.rdfs("label"), + range : NS.rdfs("range"), + seeAlso : NS.rdfs("seeAlso"), + subClassOf : NS.rdfs("subClassOf"), + subPropertyOf : NS.rdfs("subPropertyOf") +} + +var XSD = { + boolean : NS.xsd("boolean"), + date : NS.xsd("date"), + dateTime : NS.xsd("dateTime"), + decimal : NS.xsd("decimal"), + float : NS.xsd("float"), + integer : NS.xsd("integer"), + string : NS.xsd("string") +}; + + +/** + * Creates a query object for a given graph and optional initial solution. + * The resulting object can be further refined using the functions on + * AbstractQuery such as <code>find()</code> and <code>filter()</code>. + * Functions such as <code>nextSolution()</code> can be used to get the actual results. + * @param graph the graph to query + * @param initialSolution the initial solutions or null for none + * @returns a query object + */ +function RDFQuery(graph, initialSolution) { + return new StartQuery(graph, initialSolution ? initialSolution : []); +} + + +// class AbstractQuery + +function AbstractQuery() { +} + +/** + * Creates a new query that filters the solutions produced by this. + * @param filterFunction a function that takes a solution object + * and returns true iff that solution is valid + */ +AbstractQuery.prototype.filter = function(filterFunction) { + return new FilterQuery(this, filterFunction); +} + +// TODO: add other SPARQL-like query types +// - .distinct() +// - .bind(varName, function(solution)) +// - . +// - .limit() +// - .path(s, path, o) (this is complex) +// - .sort(varName, [comparatorFunction]) +// - .union(otherQuery) + +/** + * Creates a new query doing a triple match. + * @param s the match subject or null (any) or a variable name (string) + * @param p the match predicate or null (any) or a variable name (string) + * @param o the match object or null (any) or a variable name (string) + */ +AbstractQuery.prototype.find = function(s, p, o) { + return new RDFTripleQuery(this, s, p, o); +} + +/** + * Gets the next solution and closes the query. + * @return a solution object + */ +AbstractQuery.prototype.first = function() { + var n = this.nextSolution(); + this.close(); + return n; +} + +/** + * Turns all results into an array. + * @return a array consisting of solution objects + */ +AbstractQuery.prototype.toArray = function() { + var results = []; + for(var n = this.nextSolution(); n != null; n = this.nextSolution()) { + results.push(n); + } + return results; +} + + +// class FilterQuery +// Filters the incoming solutions, only letting through those where +// filterFunction(solution) returns true + +function FilterQuery(input, filterFunction) { + this.source = input.source; + this.input = input; + this.filterFunction = filterFunction; +} + +FilterQuery.prototype = Object.create(AbstractQuery.prototype); + +FilterQuery.prototype.close = function() { + this.input.close(); +} + +// Pulls the next result from the input Query and passes it into +// the given filter function +FilterQuery.prototype.nextSolution = function() { + for(;;) { + var result = this.input.nextSolution(); + if(result == null) { + return null; + } + else if(this.filterFunction(result) === true) { + return result; + } + } +} + + +// class RDFTripleQuery +// Joins the solutions from the input Query with triple matches against +// the current input graph. + +function RDFTripleQuery(input, s, p, o) { + this.source = input.source; + this.input = input; + this.s = s; + this.p = p; + this.o = o; +} + +RDFTripleQuery.prototype = Object.create(AbstractQuery.prototype); + +RDFTripleQuery.prototype.close = function() { + this.input.close(); + if(this.ownIterator) { + this.ownIterator.close(); + } +} + +// This pulls the first solution from the input Query and uses it to +// create an "ownIterator" which applies the input solution to those +// specified by s, p, o. +// Once this "ownIterator" has been exhausted, it moves to the next +// solution from the input Query, and so on. +// At each step, it produces the union of the input solutions plus the +// own solutions. +RDFTripleQuery.prototype.nextSolution = function() { + + var oit = this.ownIterator; + if(oit) { + var n = oit.next(); + if(n != null) { + var result = createSolution(this.inputSolution); + if(typeof this.s === 'string') { + result[this.s] = n.subject; + } + if(typeof this.p === 'string') { + result[this.p] = n.predicate; + } + if(typeof this.o === 'string') { + result[this.o] = n.object; + } + return result; + } + else { + delete this.ownIterator; // Mark as exhausted + } + } + + // Pull from input + this.inputSolution = this.input.nextSolution(); + if(this.inputSolution) { + var sm = (typeof this.s === 'string') ? this.inputSolution[this.s] : this.s; + var pm = (typeof this.p === 'string') ? this.inputSolution[this.p] : this.p; + var om = (typeof this.o === 'string') ? this.inputSolution[this.o] : this.o; + this.ownIterator = this.source.find(sm, pm, om) + return this.nextSolution(); + } + else { + return null; + } +} + + +// class StartQuery +// This simply produces a single result: the initial solution + +function StartQuery(source, initialSolution) { + this.source = source; + this.solution = initialSolution; +} + +StartQuery.prototype = Object.create(AbstractQuery.prototype); + +StartQuery.prototype.close = function() { +} + +StartQuery.prototype.nextSolution = function() { + if(this.solution) { + var b = this.solution; + delete this.solution; + return b; + } + else { + return null; + } +} + + +// Helper functions + +function createSolution(base) { + var result = {}; + for(var attr in base) { + if(base.hasOwnProperty(attr)) { + result[attr] = base[attr]; + } + } + return result; +}
313
SHACL-JS progress
0
.js
js
apache-2.0
TopQuadrant/shacl
2
<NME> DASH.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; /** * Vocabulary for http://datashapes.org/dash */ public class DASH { public final static String BASE_URI = "http://datashapes.org/dash"; public final static String NAME = "DASH Data Shapes Vocabulary"; public final static String NS = BASE_URI + "#"; public final static String PREFIX = "dash"; public final static Resource Action = ResourceFactory.createResource(NS + "Action"); public final static Resource ActionGroup = ResourceFactory.createResource(NS + "ActionGroup"); public final static Resource ActionTestCase = ResourceFactory.createResource(NS + "ActionTestCase"); public final static Resource addedGraph = ResourceFactory.createResource(NS + "addedGraph"); public final static Resource all = ResourceFactory.createResource(NS + "all"); public final static Resource ChangeScript = ResourceFactory.createResource(NS + "ChangeScript"); public final static Resource CommitScript = ResourceFactory.createResource(NS + "CommitScript"); public final static Resource Constructor = ResourceFactory.createResource(NS + "Constructor"); public final static Resource deletedGraph = ResourceFactory.createResource(NS + "deletedGraph"); public final static Resource DepictionRole = ResourceFactory.createResource(NS + "DepictionRole"); public final static Resource Deprecated = ResourceFactory.createResource(NS + "Deprecated"); public final static Resource DescriptionRole = ResourceFactory.createResource(NS + "DescriptionRole"); public final static Resource Editor = ResourceFactory.createResource(NS + "Editor"); public final static Resource ExecutionPlatform = ResourceFactory.createResource(NS + "ExecutionPlatform"); public final static Resource Experimental = ResourceFactory.createResource(NS + "Experimental"); public final static Resource ExploreAction = ResourceFactory.createResource(NS + "ExploreAction"); public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult"); public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase"); public final static Resource IconRole = ResourceFactory.createResource(NS + "IconRole"); public final static Resource IDRole = ResourceFactory.createResource(NS + "IDRole"); public final static Resource IncludedScript = ResourceFactory.createResource(NS + "IncludedScript"); public final static Resource IndexedConstraintComponent = ResourceFactory.createResource(NS + "IndexedConstraintComponent"); public final static Resource InferencingTestCase = ResourceFactory.createResource(NS + "InferencingTestCase"); public final static Resource isDeactivated = ResourceFactory.createResource(NS + "isDeactivated"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Resource ModifyAction = ResourceFactory.createResource(NS + "ModifyAction"); public final static Resource MultiFunction = ResourceFactory.createResource(NS + "MultiFunction"); public final static Resource None = ResourceFactory.createResource(NS + "None"); public final static Resource NonRecursiveConstraintComponent = ResourceFactory.createResource(NS + "NonRecursiveConstraintComponent"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Resource ResourceAction = ResourceFactory.createResource(NS + "ResourceAction"); public final static Resource ResourceService = ResourceFactory.createResource(NS + "ResourceService"); public final static Resource Script = ResourceFactory.createResource(NS + "Script"); public final static Resource ScriptConstraint = ResourceFactory.createResource(NS + "ScriptConstraint"); public final static Resource ScriptConstraintComponent = ResourceFactory.createResource(NS + "ScriptConstraintComponent"); public final static Resource ScriptFunction = ResourceFactory.createResource(NS + "ScriptFunction"); public final static Resource ScriptSuggestionGenerator = ResourceFactory.createResource(NS + "ScriptSuggestionGenerator"); public final static Resource ScriptTestCase = ResourceFactory.createResource(NS + "ScriptTestCase"); public final static Resource ScriptValidator = ResourceFactory.createResource(NS + "ScriptValidator"); public final static Resource Service = ResourceFactory.createResource(NS + "Service"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource ShapeScript = ResourceFactory.createResource(NS + "ShapeScript"); public final static Resource SPARQLConstructTemplate = ResourceFactory.createResource(NS + "SPARQLConstructTemplate"); public final static Resource SPARQLMultiFunction = ResourceFactory.createResource(NS + "SPARQLMultiFunction"); public final static Resource SPARQLSelectTemplate = ResourceFactory.createResource(NS + "SPARQLSelectTemplate"); public final static Resource SPARQLUpdateSuggestionGenerator = ResourceFactory.createResource(NS + "SPARQLUpdateSuggestionGenerator"); public final static Resource SingleLineConstraintComponent = ResourceFactory.createResource(NS + "SingleLineConstraintComponent"); public final static Resource Stable = ResourceFactory.createResource(NS + "Stable"); public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase"); public final static Resource ValueTableViewer = ResourceFactory.createResource(NS + "ValueTableViewer"); public final static Resource Viewer = ResourceFactory.createResource(NS + "Viewer"); public final static Resource Widget = ResourceFactory.createResource(NS + "Widget"); public final static Property abstract_ = ResourceFactory.createProperty(NS + "abstract"); public final static Property action = ResourceFactory.createProperty(NS + "action"); public final static Property actualResult = ResourceFactory.createProperty(NS + "actualResult"); public final static Property actionGroup = ResourceFactory.createProperty(NS + "actionGroup"); public final static Property addedTriple = ResourceFactory.createProperty(NS + "addedTriple"); public final static Property apiStatus = ResourceFactory.createProperty(NS + "apiStatus"); public final static Property applicableToClass = ResourceFactory.createProperty(NS + "applicableToClass"); public final static Property cachable = ResourceFactory.createProperty(NS + "cachable"); public final static Property canWrite = ResourceFactory.createProperty(NS + "canWrite"); public final static Property composite = ResourceFactory.createProperty(NS + "composite"); public final static Property constructor = ResourceFactory.createProperty(NS + "constructor"); public final static Property contextFree = ResourceFactory.createProperty(NS + "contextFree"); public final static Property defaultViewForRole = ResourceFactory.createProperty(NS + "defaultViewForRole"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property dependencyPredicate = ResourceFactory.createProperty(NS + "dependencyPredicate"); public final static Property detailsEndpoint = ResourceFactory.createProperty(NS + "detailsEndpoint"); public final static Property detailsGraph = ResourceFactory.createProperty(NS + "detailsGraph"); public final static Property editor = ResourceFactory.createProperty(NS + "editor"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expectedResultIsJSON = ResourceFactory.createProperty(NS + "expectedResultIsJSON"); public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property exports = ResourceFactory.createProperty(NS + "exports"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property generateClass = ResourceFactory.createProperty(NS + "generateClass"); public final static Property generatePrefixClasses = ResourceFactory.createProperty(NS + "generatePrefixClasses"); public final static Property generatePrefixConstants = ResourceFactory.createProperty(NS + "generatePrefixConstants"); public final static Property hidden = ResourceFactory.createProperty(NS + "hidden"); public final static Property includedExecutionPlatform = ResourceFactory.createProperty(NS + "includedExecutionPlatform"); public final static Property includeSuggestions = ResourceFactory.createProperty(NS + "includeSuggestions"); public final static Property index = ResourceFactory.createProperty(NS + "index"); public final static Property indexed = ResourceFactory.createProperty(NS + "indexed"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsCondition = ResourceFactory.createProperty(NS + "jsCondition"); public final static Property mimeTypes = ResourceFactory.createProperty(NS + "mimeTypes"); public final static Property neverMaterialize = ResourceFactory.createProperty(NS + "neverMaterialize"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property onAllValues = ResourceFactory.createProperty(NS + "onAllValues"); public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property propertyRole = ResourceFactory.createProperty(NS + "propertyRole"); public final static Property propertySuggestionGenerator = ResourceFactory.createProperty(NS + "propertySuggestionGenerator"); public final static Property requiredExecutionPlatform = ResourceFactory.createProperty(NS + "requiredExecutionPlatform"); public final static Property resultVariable = ResourceFactory.createProperty(NS + "resultVariable"); public final static Property rootClass = ResourceFactory.createProperty(NS + "rootClass"); public final static Property readOnly = ResourceFactory.createProperty(NS + "readOnly"); public final static Property reifiableBy = ResourceFactory.createProperty(NS + "reifiableBy"); public final static Property resourceAction = ResourceFactory.createProperty(NS + "resourceAction"); public final static Property resourceService = ResourceFactory.createProperty(NS + "resourceService"); public final static Property responseContentType = ResourceFactory.createProperty(NS + "responseContentType"); public final static Property scriptConstraint = ResourceFactory.createProperty(NS + "scriptConstraint"); public final static Property shape = ResourceFactory.createProperty(NS + "shape"); public final static Property shapeScript = ResourceFactory.createProperty(NS + "shapeScript"); public final static Property singleLine = ResourceFactory.createProperty(NS + "singleLine"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Property testCase = ResourceFactory.createProperty(NS + "testCase"); public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph"); public final static Property uri = ResourceFactory.createProperty(NS + "uri"); public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart"); public final static Property validateShapes = ResourceFactory.createProperty(NS + "validateShapes"); public final static Property variables = ResourceFactory.createProperty(NS + "variables"); public final static Property viewer = ResourceFactory.createProperty(NS + "viewer"); public final static Property x = ResourceFactory.createProperty(NS + "x"); public final static Property y = ResourceFactory.createProperty(NS + "y"); public static String getURI() { return NS; } /** * Checks whether a given feature shall be included into the generated APIs. * @param feature the feature to check * @return true currently if the feature has any value for dash:apiStatus but this may change in case we introduce * additional stati in the future. */ public static boolean isAPI(Resource feature) { return feature.hasProperty(DASH.apiStatus); } } <MSG> Moved to Jena 3.5.0, misc minor adjustments and fixes <DFF> @@ -72,6 +72,8 @@ public class DASH { public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); + public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); + public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); @@ -92,6 +94,8 @@ public class DASH { public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); + + public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); @@ -107,6 +111,8 @@ public class DASH { public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); + public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); + public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup");
6
Moved to Jena 3.5.0, misc minor adjustments and fixes
0
.java
java
apache-2.0
TopQuadrant/shacl
3
<NME> DASH.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; /** * Vocabulary for http://datashapes.org/dash */ public class DASH { public final static String BASE_URI = "http://datashapes.org/dash"; public final static String NAME = "DASH Data Shapes Vocabulary"; public final static String NS = BASE_URI + "#"; public final static String PREFIX = "dash"; public final static Resource Action = ResourceFactory.createResource(NS + "Action"); public final static Resource ActionGroup = ResourceFactory.createResource(NS + "ActionGroup"); public final static Resource ActionTestCase = ResourceFactory.createResource(NS + "ActionTestCase"); public final static Resource addedGraph = ResourceFactory.createResource(NS + "addedGraph"); public final static Resource all = ResourceFactory.createResource(NS + "all"); public final static Resource ChangeScript = ResourceFactory.createResource(NS + "ChangeScript"); public final static Resource CommitScript = ResourceFactory.createResource(NS + "CommitScript"); public final static Resource Constructor = ResourceFactory.createResource(NS + "Constructor"); public final static Resource deletedGraph = ResourceFactory.createResource(NS + "deletedGraph"); public final static Resource DepictionRole = ResourceFactory.createResource(NS + "DepictionRole"); public final static Resource Deprecated = ResourceFactory.createResource(NS + "Deprecated"); public final static Resource DescriptionRole = ResourceFactory.createResource(NS + "DescriptionRole"); public final static Resource Editor = ResourceFactory.createResource(NS + "Editor"); public final static Resource ExecutionPlatform = ResourceFactory.createResource(NS + "ExecutionPlatform"); public final static Resource Experimental = ResourceFactory.createResource(NS + "Experimental"); public final static Resource ExploreAction = ResourceFactory.createResource(NS + "ExploreAction"); public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult"); public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase"); public final static Resource IconRole = ResourceFactory.createResource(NS + "IconRole"); public final static Resource IDRole = ResourceFactory.createResource(NS + "IDRole"); public final static Resource IncludedScript = ResourceFactory.createResource(NS + "IncludedScript"); public final static Resource IndexedConstraintComponent = ResourceFactory.createResource(NS + "IndexedConstraintComponent"); public final static Resource InferencingTestCase = ResourceFactory.createResource(NS + "InferencingTestCase"); public final static Resource isDeactivated = ResourceFactory.createResource(NS + "isDeactivated"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Resource ModifyAction = ResourceFactory.createResource(NS + "ModifyAction"); public final static Resource MultiFunction = ResourceFactory.createResource(NS + "MultiFunction"); public final static Resource None = ResourceFactory.createResource(NS + "None"); public final static Resource NonRecursiveConstraintComponent = ResourceFactory.createResource(NS + "NonRecursiveConstraintComponent"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Resource ResourceAction = ResourceFactory.createResource(NS + "ResourceAction"); public final static Resource ResourceService = ResourceFactory.createResource(NS + "ResourceService"); public final static Resource Script = ResourceFactory.createResource(NS + "Script"); public final static Resource ScriptConstraint = ResourceFactory.createResource(NS + "ScriptConstraint"); public final static Resource ScriptConstraintComponent = ResourceFactory.createResource(NS + "ScriptConstraintComponent"); public final static Resource ScriptFunction = ResourceFactory.createResource(NS + "ScriptFunction"); public final static Resource ScriptSuggestionGenerator = ResourceFactory.createResource(NS + "ScriptSuggestionGenerator"); public final static Resource ScriptTestCase = ResourceFactory.createResource(NS + "ScriptTestCase"); public final static Resource ScriptValidator = ResourceFactory.createResource(NS + "ScriptValidator"); public final static Resource Service = ResourceFactory.createResource(NS + "Service"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource ShapeScript = ResourceFactory.createResource(NS + "ShapeScript"); public final static Resource SPARQLConstructTemplate = ResourceFactory.createResource(NS + "SPARQLConstructTemplate"); public final static Resource SPARQLMultiFunction = ResourceFactory.createResource(NS + "SPARQLMultiFunction"); public final static Resource SPARQLSelectTemplate = ResourceFactory.createResource(NS + "SPARQLSelectTemplate"); public final static Resource SPARQLUpdateSuggestionGenerator = ResourceFactory.createResource(NS + "SPARQLUpdateSuggestionGenerator"); public final static Resource SingleLineConstraintComponent = ResourceFactory.createResource(NS + "SingleLineConstraintComponent"); public final static Resource Stable = ResourceFactory.createResource(NS + "Stable"); public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase"); public final static Resource ValueTableViewer = ResourceFactory.createResource(NS + "ValueTableViewer"); public final static Resource Viewer = ResourceFactory.createResource(NS + "Viewer"); public final static Resource Widget = ResourceFactory.createResource(NS + "Widget"); public final static Property abstract_ = ResourceFactory.createProperty(NS + "abstract"); public final static Property action = ResourceFactory.createProperty(NS + "action"); public final static Property actualResult = ResourceFactory.createProperty(NS + "actualResult"); public final static Property actionGroup = ResourceFactory.createProperty(NS + "actionGroup"); public final static Property addedTriple = ResourceFactory.createProperty(NS + "addedTriple"); public final static Property apiStatus = ResourceFactory.createProperty(NS + "apiStatus"); public final static Property applicableToClass = ResourceFactory.createProperty(NS + "applicableToClass"); public final static Property cachable = ResourceFactory.createProperty(NS + "cachable"); public final static Property canWrite = ResourceFactory.createProperty(NS + "canWrite"); public final static Property composite = ResourceFactory.createProperty(NS + "composite"); public final static Property constructor = ResourceFactory.createProperty(NS + "constructor"); public final static Property contextFree = ResourceFactory.createProperty(NS + "contextFree"); public final static Property defaultViewForRole = ResourceFactory.createProperty(NS + "defaultViewForRole"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property dependencyPredicate = ResourceFactory.createProperty(NS + "dependencyPredicate"); public final static Property detailsEndpoint = ResourceFactory.createProperty(NS + "detailsEndpoint"); public final static Property detailsGraph = ResourceFactory.createProperty(NS + "detailsGraph"); public final static Property editor = ResourceFactory.createProperty(NS + "editor"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expectedResultIsJSON = ResourceFactory.createProperty(NS + "expectedResultIsJSON"); public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property exports = ResourceFactory.createProperty(NS + "exports"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property generateClass = ResourceFactory.createProperty(NS + "generateClass"); public final static Property generatePrefixClasses = ResourceFactory.createProperty(NS + "generatePrefixClasses"); public final static Property generatePrefixConstants = ResourceFactory.createProperty(NS + "generatePrefixConstants"); public final static Property hidden = ResourceFactory.createProperty(NS + "hidden"); public final static Property includedExecutionPlatform = ResourceFactory.createProperty(NS + "includedExecutionPlatform"); public final static Property includeSuggestions = ResourceFactory.createProperty(NS + "includeSuggestions"); public final static Property index = ResourceFactory.createProperty(NS + "index"); public final static Property indexed = ResourceFactory.createProperty(NS + "indexed"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsCondition = ResourceFactory.createProperty(NS + "jsCondition"); public final static Property mimeTypes = ResourceFactory.createProperty(NS + "mimeTypes"); public final static Property neverMaterialize = ResourceFactory.createProperty(NS + "neverMaterialize"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property onAllValues = ResourceFactory.createProperty(NS + "onAllValues"); public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property propertyRole = ResourceFactory.createProperty(NS + "propertyRole"); public final static Property propertySuggestionGenerator = ResourceFactory.createProperty(NS + "propertySuggestionGenerator"); public final static Property requiredExecutionPlatform = ResourceFactory.createProperty(NS + "requiredExecutionPlatform"); public final static Property resultVariable = ResourceFactory.createProperty(NS + "resultVariable"); public final static Property rootClass = ResourceFactory.createProperty(NS + "rootClass"); public final static Property readOnly = ResourceFactory.createProperty(NS + "readOnly"); public final static Property reifiableBy = ResourceFactory.createProperty(NS + "reifiableBy"); public final static Property resourceAction = ResourceFactory.createProperty(NS + "resourceAction"); public final static Property resourceService = ResourceFactory.createProperty(NS + "resourceService"); public final static Property responseContentType = ResourceFactory.createProperty(NS + "responseContentType"); public final static Property scriptConstraint = ResourceFactory.createProperty(NS + "scriptConstraint"); public final static Property shape = ResourceFactory.createProperty(NS + "shape"); public final static Property shapeScript = ResourceFactory.createProperty(NS + "shapeScript"); public final static Property singleLine = ResourceFactory.createProperty(NS + "singleLine"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Property testCase = ResourceFactory.createProperty(NS + "testCase"); public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph"); public final static Property uri = ResourceFactory.createProperty(NS + "uri"); public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart"); public final static Property validateShapes = ResourceFactory.createProperty(NS + "validateShapes"); public final static Property variables = ResourceFactory.createProperty(NS + "variables"); public final static Property viewer = ResourceFactory.createProperty(NS + "viewer"); public final static Property x = ResourceFactory.createProperty(NS + "x"); public final static Property y = ResourceFactory.createProperty(NS + "y"); public static String getURI() { return NS; } /** * Checks whether a given feature shall be included into the generated APIs. * @param feature the feature to check * @return true currently if the feature has any value for dash:apiStatus but this may change in case we introduce * additional stati in the future. */ public static boolean isAPI(Resource feature) { return feature.hasProperty(DASH.apiStatus); } } <MSG> Moved to Jena 3.5.0, misc minor adjustments and fixes <DFF> @@ -72,6 +72,8 @@ public class DASH { public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); + public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); + public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); @@ -92,6 +94,8 @@ public class DASH { public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); + + public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); @@ -107,6 +111,8 @@ public class DASH { public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); + public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); + public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup");
6
Moved to Jena 3.5.0, misc minor adjustments and fixes
0
.java
java
apache-2.0
TopQuadrant/shacl
4
<NME> Validate.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.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; 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.JenaDatatypes; import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.shacl.vocabulary.SH; /** * Stand-alone utility to perform constraint validation of a given file. * * Example arguments: * * -datafile my.ttl * * @author Holger Knublauch */ public class Validate extends AbstractTool { public static void main(String[] args) throws IOException { // Temporarily redirect system.err to avoid SLF4J warning PrintStream oldPS = System.err; System.setErr(new PrintStream(new ByteArrayOutputStream())); Validate validate = new Validate(); System.setErr(oldPS); validate.run(args); } private void run(String[] args) throws IOException { Model dataModel = getDataModel(args); Model shapesModel = getShapesModel(args); if(shapesModel == null) { shapesModel = dataModel; } Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) { // See https://github.com/TopQuadrant/shacl/issues/56 System.exit(1); } } } <MSG> #135: validate command line tool now has -validateShapes flag which is off by default <DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.Arrays; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; @@ -54,7 +55,8 @@ public class Validate extends AbstractTool { if(shapesModel == null) { shapesModel = dataModel; } - Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); + boolean validateShapes = Arrays.asList(args).contains("-validateShapes"); + Resource report = ValidationUtil.validateModel(dataModel, shapesModel, validateShapes); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) {
3
#135: validate command line tool now has -validateShapes flag which is off by default
1
.java
java
apache-2.0
TopQuadrant/shacl
5
<NME> Validate.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.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; 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.JenaDatatypes; import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.shacl.vocabulary.SH; /** * Stand-alone utility to perform constraint validation of a given file. * * Example arguments: * * -datafile my.ttl * * @author Holger Knublauch */ public class Validate extends AbstractTool { public static void main(String[] args) throws IOException { // Temporarily redirect system.err to avoid SLF4J warning PrintStream oldPS = System.err; System.setErr(new PrintStream(new ByteArrayOutputStream())); Validate validate = new Validate(); System.setErr(oldPS); validate.run(args); } private void run(String[] args) throws IOException { Model dataModel = getDataModel(args); Model shapesModel = getShapesModel(args); if(shapesModel == null) { shapesModel = dataModel; } Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) { // See https://github.com/TopQuadrant/shacl/issues/56 System.exit(1); } } } <MSG> #135: validate command line tool now has -validateShapes flag which is off by default <DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.Arrays; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; @@ -54,7 +55,8 @@ public class Validate extends AbstractTool { if(shapesModel == null) { shapesModel = dataModel; } - Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); + boolean validateShapes = Arrays.asList(args).contains("-validateShapes"); + Resource report = ValidationUtil.validateModel(dataModel, shapesModel, validateShapes); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) {
3
#135: validate command line tool now has -validateShapes flag which is off by default
1
.java
java
apache-2.0
TopQuadrant/shacl
6
<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); } 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(thisValue != null) { Resource resultType = SH.ValidationResult; RDFNode selectMessage = sol.get(SH.message.getLocalName()); if(JenaDatatypes.TRUE.equals(sol.get(SH.failureVar.getName()))) { resultType = DASH.FailureResult; String message = getLabel(constraint); message += " has produced ?" + SH.failureVar.getName(); if(focusNode != null) { message += " for focus node "; if(focusNode.isLiteral()) { message += focusNode; } 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> Support for cancelling validation, other clean up <DFF> @@ -111,6 +111,7 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { 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();
1
Support for cancelling validation, other clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
7
<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); } 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(thisValue != null) { Resource resultType = SH.ValidationResult; RDFNode selectMessage = sol.get(SH.message.getLocalName()); if(JenaDatatypes.TRUE.equals(sol.get(SH.failureVar.getName()))) { resultType = DASH.FailureResult; String message = getLabel(constraint); message += " has produced ?" + SH.failureVar.getName(); if(focusNode != null) { message += " for focus node "; if(focusNode.isLiteral()) { message += focusNode; } 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> Support for cancelling validation, other clean up <DFF> @@ -111,6 +111,7 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { 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();
1
Support for cancelling validation, other clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
8
<NME> ValidationSuggestionGenerator.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.util.function.Function; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; /** * An interface for objects that can produce suggestions for a given results graph. * * @author Holger Knublauch */ public interface ValidationSuggestionGenerator { /** * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); /** * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction); /** * Checks if this is (in principle) capable of adding suggestions for a given result. * @param result the validation result * @return true if this can */ boolean canHandle(Resource result); } <MSG> JavaDoc clean up <DFF> @@ -33,6 +33,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); @@ -42,6 +43,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction);
2
JavaDoc clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
9
<NME> ValidationSuggestionGenerator.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.util.function.Function; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; /** * An interface for objects that can produce suggestions for a given results graph. * * @author Holger Knublauch */ public interface ValidationSuggestionGenerator { /** * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); /** * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction); /** * Checks if this is (in principle) capable of adding suggestions for a given result. * @param result the validation result * @return true if this can */ boolean canHandle(Resource result); } <MSG> JavaDoc clean up <DFF> @@ -33,6 +33,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); @@ -42,6 +43,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction);
2
JavaDoc clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
10
<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 PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); 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 Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); 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 Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property property = ResourceFactory.createProperty(NS + "property"); 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> Improved support for scopes <DFF> @@ -61,6 +61,8 @@ public class SH { public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); + public final static Resource Scope = ResourceFactory.createResource(NS + "Scope"); + public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); @@ -68,6 +70,8 @@ public class SH { public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); + + public final static Resource TemplateScope = ResourceFactory.createResource(NS + "TemplateScope"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); @@ -95,6 +99,8 @@ public class SH { public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); + + public final static Property final_ = ResourceFactory.createProperty(NS + "final"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); @@ -133,6 +139,8 @@ public class SH { public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); + + public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property property = ResourceFactory.createProperty(NS + "property");
8
Improved support for scopes
0
.java
java
apache-2.0
TopQuadrant/shacl
11
<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 PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); 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 Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); 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 Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property property = ResourceFactory.createProperty(NS + "property"); 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> Improved support for scopes <DFF> @@ -61,6 +61,8 @@ public class SH { public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); + public final static Resource Scope = ResourceFactory.createResource(NS + "Scope"); + public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); @@ -68,6 +70,8 @@ public class SH { public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); + + public final static Resource TemplateScope = ResourceFactory.createResource(NS + "TemplateScope"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); @@ -95,6 +99,8 @@ public class SH { public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); + + public final static Property final_ = ResourceFactory.createProperty(NS + "final"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); @@ -133,6 +139,8 @@ public class SH { public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); + + public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property property = ResourceFactory.createProperty(NS + "property");
8
Improved support for scopes
0
.java
java
apache-2.0
TopQuadrant/shacl
12
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-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/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 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:InvalidNode1 ; sh:resultPath ex:property ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -28,6 +28,7 @@ ex:GraphValidationTestCase sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; + dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ;
1
Tracking latest SHACL spec
0
.ttl
test
apache-2.0
TopQuadrant/shacl
13
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-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/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 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:InvalidNode1 ; sh:resultPath ex:property ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -28,6 +28,7 @@ ex:GraphValidationTestCase sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; + dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ;
1
Tracking latest SHACL spec
0
.ttl
test
apache-2.0
TopQuadrant/shacl
14
<NME> sparqlscope-001.test.ttl <BEF> ADDFILE <MSG> Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid <DFF> @@ -0,0 +1,53 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/scope/sparqlscope-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/scope/sparqlscope-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparqlscope-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer"^^xsd:string ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidInstance1 ; + sh:predicate rdfs:label ; + sh:severity sh:Violation ; + sh:subject ex:InvalidInstance1 ; + ] ; +. +ex:InvalidInstance1 + rdf:type owl:Thing ; + rdfs:label "Invalid instance1"^^xsd:string ; +. +ex:TestShape + rdf:type sh:Shape ; + rdfs:label "Test shape"^^xsd:string ; + sh:property [ + rdfs:comment "Must not have any rdfs:label"^^xsd:string ; + rdfs:label "label"^^xsd:string ; + sh:datatype xsd:string ; + sh:maxCount 0 ; + sh:predicate rdfs:label ; + ] ; + sh:scope [ + rdf:type sh:SPARQLScope ; + sh:sparql """SELECT ?this +WHERE { + ?this a owl:Thing . +}""" ; + ] ; +. +ex:ValidInstance1 + rdf:type owl:Thing ; +.
53
Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid
0
.ttl
test
apache-2.0
TopQuadrant/shacl
15
<NME> sparqlscope-001.test.ttl <BEF> ADDFILE <MSG> Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid <DFF> @@ -0,0 +1,53 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/scope/sparqlscope-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/scope/sparqlscope-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparqlscope-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer"^^xsd:string ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidInstance1 ; + sh:predicate rdfs:label ; + sh:severity sh:Violation ; + sh:subject ex:InvalidInstance1 ; + ] ; +. +ex:InvalidInstance1 + rdf:type owl:Thing ; + rdfs:label "Invalid instance1"^^xsd:string ; +. +ex:TestShape + rdf:type sh:Shape ; + rdfs:label "Test shape"^^xsd:string ; + sh:property [ + rdfs:comment "Must not have any rdfs:label"^^xsd:string ; + rdfs:label "label"^^xsd:string ; + sh:datatype xsd:string ; + sh:maxCount 0 ; + sh:predicate rdfs:label ; + ] ; + sh:scope [ + rdf:type sh:SPARQLScope ; + sh:sparql """SELECT ?this +WHERE { + ?this a owl:Thing . +}""" ; + ] ; +. +ex:ValidInstance1 + rdf:type owl:Thing ; +.
53
Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid
0
.ttl
test
apache-2.0
TopQuadrant/shacl
16
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). 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. * [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 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> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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.
1
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
17
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). 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. * [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 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> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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.
1
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
18
<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 ; sh:property [ sh:path dash:nonRecursive ; sh:group tosh:RelationshipPropertyGroup ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart tosh:editWidget swa:PlainTextFieldEditor ; . 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 }""" ; ] ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . . 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 ; . dash:Widget sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; tosh:PropertyShapeShape a sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ a sh:PropertyShape ; sh:path sh:values ; 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 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:order "10"^^xsd:decimal ; . tosh:ActionTestCase-focusNode a sh:PropertyShape ; sh:path dash:focusNode ; sh:name "on property" ; sh:order 0 ; ] ; sh:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup sh:order "2"^^xsd:decimal ; . rdfs:label "Relationship" ; sh:order 8 ; . 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: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)." ; sh:group tosh:ScriptsPropertyGroup ; sh:name "resource services" ; sh:order "10"^^xsd:decimal ; . tosh:Class-subClassOf a sh:PropertyShape ; 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 ; . rdfs:label "Type of Values" ; sh:order 3 ; . 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: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 ; . tosh:DatatypesViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Datatypes viewer" ; . tosh:DefinitionPropertyGroup a sh:PropertyGroup ; rdfs:label "Definition" ; sh:order "0"^^xsd:decimal ; . tosh:DeleteTripleSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion that would delete the offending value in the validation result from the focus node." ; rdfs:label "Delete triple suggestion generator" ; sh:message "Delete the invalid statement" ; sh:order 100.0 ; 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:returnType xsd:boolean ; . tosh:open a rdf:Property ; rdfs:comment "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:domain sh:PropertyGroup ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable a rdf:Property ; rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; rdfs:domain sh:PropertyGroup ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . 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 a sh:PropertyShape ; sh:path dash:hidden ; dash:editor dash:BooleanSelectEditor ; sh:datatype xsd:boolean ; sh:description "True to mark this property as hidden in user interface, yet still used in data tasks." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:order "30"^^xsd:decimal ; . tosh:PropertyShape-indexed a sh:PropertyShape ; sh:path dash:indexed ; 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 a sh:PropertyShape ; sh:path sh:path ; sh:group tosh:DefinitionPropertyGroup ; rdfs:isDefinedBy sh: ; rdfs:label "distinct"@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: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: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 ; rdfs:isDefinedBy sh: ; rdfs:label "sum"@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: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 "Use declared datatype constraint component" ; sh:parameter [ a sh:Parameter ; sh:path tosh:useDeclaredDatatype ; sh:datatype xsd:boolean ; sh:description "True to state that the datatype of literal values must be the same as the declared sh:datatype." ; sh:name "use declared datatype" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Datatype must match the declared datatype " ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?datatype WHERE { { FILTER ($useDeclaredDatatype) } $this sh:datatype ?datatype . $this $PATH ?value . FILTER (isLiteral(?value) && datatype(?value) != ?datatype) . }""" ; ] ; sh:targetClass sh:PropertyShape ; . tosh:ValidationPropertyGroup a sh:PropertyGroup ; rdfs:label "Validation" ; sh:order "30"^^xsd:decimal ; . tosh:ValidationTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected validation report, either as instance of sh:ValidationReport or a Turtle string with one instance of sh:ValidationReport in it when parsed." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:name "expected result" ; sh:or ( [ sh:datatype xsd:string ; ] [ sh:class sh:ValidationReport ; ] ) ; sh:order "10"^^xsd:decimal ; . tosh:ValidationTestCase-includeSuggestions a sh:PropertyShape ; sh:path dash:includeSuggestions ; sh:datatype xsd:boolean ; sh:description "True to also generate and verify suggestions." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "include suggestions" ; sh:order "0"^^xsd:decimal ; . tosh:ValidationTestCase-validateShapes a sh:PropertyShape ; sh:path dash:validateShapes ; sh:datatype xsd:boolean ; sh:description "True to also validate shapes themselves." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "validate shapes" ; sh:order "5"^^xsd:decimal ; . tosh:ValueConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "Value Constraints" ; sh:order "60"^^xsd:decimal ; . tosh:ValueRangePropertyGroup a sh:PropertyGroup ; rdfs:label "Value Range" ; sh:order "60"^^xsd:decimal ; . 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." ; rdfs:label "count shapes with match result" ; sh:parameter [ a sh:Parameter ; sh:path sh:expectedValue ; sh:datatype xsd:boolean ; sh:description "The expected value of tosh:hasShape to count." ; sh:order 3.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:focusNode ; sh:class rdfs:Resource ; sh:description "The focus node." ; sh:order 0.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:shapes ; sh:class rdf:List ; sh:description "The list of shapes to walk through." ; sh:order 1.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:shapesGraph ; sh:class rdfs:Resource ; sh:description "The shapes graph." ; sh:order 2.0 ; ] ; sh:prefixes <http://topbraid.org/tosh> ; sh:returnType xsd:integer ; sh:select """ # The SUM will fail with an error if one of the operands is not a number # (this mechanism is used to propagate errors from tosh:hasShape calls) SELECT (SUM(?s) AS ?result) WHERE { GRAPH $shapesGraph { $shapes rdf:rest*/rdf:first ?shape . } BIND (tosh:hasShape($focusNode, ?shape, true) AS ?hasShape) . BIND (IF(bound(?hasShape), IF(?hasShape = $expectedValue, 1, 0), 'error') AS ?s) . } """ ; . tosh:editGroupDescription a rdf:Property ; rdfs:comment "A description of the property group when in \"edit\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "edit group description" ; rdfs:range xsd:string ; . tosh:graph a rdf:Property ; rdfs:comment "The graph that the shape is validated in." ; rdfs:label "graph" ; . tosh:hasDatatype a sh:SPARQLAskValidator ; rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; rdfs:label "has datatype" ; sh:ask """ ASK { FILTER (datatype($value) = $datatype && spif:isValidForDatatype($value, $datatype)) . } """ ; sh:prefixes <http://topbraid.org/tosh> ; . tosh:hasShape a sh:Function ; dash:apiStatus dash:Experimental ; rdfs:comment """A built-in function of the TopBraid SHACL implementation. Can be used to validate a given (focus) node against a given shape, returning <code>true</code> if the node is valid. If executed within a SHACL validation engine, this uses the shapes graph that was provided when the engine started. If executed in other contexts, e.g. in a stand-alone SPARQL query, the function attempts to use the URI of the current default graph as the shapes graph. This may not always be supported. If called from within an SWP engine, the shapes graph is the current query graph."""^^rdf:HTML ; rdfs:label "has shape" ; sh:parameter [ a sh:Parameter ; sh:path tosh:node ; sh:description "The node to validate." ; ] ; sh:parameter [ a sh:Parameter ; sh:path tosh:shape ; sh:description "The shape that the node is supposed to have." ; ] ; sh:returnType xsd:boolean ; . tosh:isHiddenClass a sh:SPARQLFunction ; dash:apiStatus dash:Experimental ; rdfs:comment "Checks if a given resource is supposed to
91
Corrected SHACL TTL files
8
.ttl
ttl
apache-2.0
TopQuadrant/shacl
19
<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 ; sh:property [ sh:path dash:nonRecursive ; sh:group tosh:RelationshipPropertyGroup ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart tosh:editWidget swa:PlainTextFieldEditor ; . 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 }""" ; ] ; . <http://spinrdf.org/sp#> tosh:systemNamespace true ; . . 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 ; . dash:Widget sh:property tosh:Resource-comment ; sh:property tosh:Resource-label ; tosh:PropertyShapeShape a sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ a sh:PropertyShape ; sh:path sh:values ; 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 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:order "10"^^xsd:decimal ; . tosh:ActionTestCase-focusNode a sh:PropertyShape ; sh:path dash:focusNode ; sh:name "on property" ; sh:order 0 ; ] ; sh:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup sh:order "2"^^xsd:decimal ; . rdfs:label "Relationship" ; sh:order 8 ; . 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: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)." ; sh:group tosh:ScriptsPropertyGroup ; sh:name "resource services" ; sh:order "10"^^xsd:decimal ; . tosh:Class-subClassOf a sh:PropertyShape ; 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 ; . rdfs:label "Type of Values" ; sh:order 3 ; . 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: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 ; . tosh:DatatypesViewer a dash:MultiViewer ; dash:hidden true ; rdfs:label "Datatypes viewer" ; . tosh:DefinitionPropertyGroup a sh:PropertyGroup ; rdfs:label "Definition" ; sh:order "0"^^xsd:decimal ; . tosh:DeleteTripleSuggestionGenerator a dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion that would delete the offending value in the validation result from the focus node." ; rdfs:label "Delete triple suggestion generator" ; sh:message "Delete the invalid statement" ; sh:order 100.0 ; 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:returnType xsd:boolean ; . tosh:open a rdf:Property ; rdfs:comment "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:domain sh:PropertyGroup ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable a rdf:Property ; rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; rdfs:domain sh:PropertyGroup ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . 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 a sh:PropertyShape ; sh:path dash:hidden ; dash:editor dash:BooleanSelectEditor ; sh:datatype xsd:boolean ; sh:description "True to mark this property as hidden in user interface, yet still used in data tasks." ; sh:group tosh:DisplayPropertyGroup ; sh:maxCount 1 ; sh:order "30"^^xsd:decimal ; . tosh:PropertyShape-indexed a sh:PropertyShape ; sh:path dash:indexed ; 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 a sh:PropertyShape ; sh:path sh:path ; sh:group tosh:DefinitionPropertyGroup ; rdfs:isDefinedBy sh: ; rdfs:label "distinct"@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: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: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 ; rdfs:isDefinedBy sh: ; rdfs:label "sum"@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: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 "Use declared datatype constraint component" ; sh:parameter [ a sh:Parameter ; sh:path tosh:useDeclaredDatatype ; sh:datatype xsd:boolean ; sh:description "True to state that the datatype of literal values must be the same as the declared sh:datatype." ; sh:name "use declared datatype" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Datatype must match the declared datatype " ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?datatype WHERE { { FILTER ($useDeclaredDatatype) } $this sh:datatype ?datatype . $this $PATH ?value . FILTER (isLiteral(?value) && datatype(?value) != ?datatype) . }""" ; ] ; sh:targetClass sh:PropertyShape ; . tosh:ValidationPropertyGroup a sh:PropertyGroup ; rdfs:label "Validation" ; sh:order "30"^^xsd:decimal ; . tosh:ValidationTestCase-expectedResult a sh:PropertyShape ; sh:path dash:expectedResult ; sh:description "The expected validation report, either as instance of sh:ValidationReport or a Turtle string with one instance of sh:ValidationReport in it when parsed." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:name "expected result" ; sh:or ( [ sh:datatype xsd:string ; ] [ sh:class sh:ValidationReport ; ] ) ; sh:order "10"^^xsd:decimal ; . tosh:ValidationTestCase-includeSuggestions a sh:PropertyShape ; sh:path dash:includeSuggestions ; sh:datatype xsd:boolean ; sh:description "True to also generate and verify suggestions." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "include suggestions" ; sh:order "0"^^xsd:decimal ; . tosh:ValidationTestCase-validateShapes a sh:PropertyShape ; sh:path dash:validateShapes ; sh:datatype xsd:boolean ; sh:description "True to also validate shapes themselves." ; sh:group tosh:TestPropertiesPropertyGroup ; sh:maxCount 1 ; sh:name "validate shapes" ; sh:order "5"^^xsd:decimal ; . tosh:ValueConstraintsPropertyGroup a sh:PropertyGroup ; rdfs:label "Value Constraints" ; sh:order "60"^^xsd:decimal ; . tosh:ValueRangePropertyGroup a sh:PropertyGroup ; rdfs:label "Value Range" ; sh:order "60"^^xsd:decimal ; . 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." ; rdfs:label "count shapes with match result" ; sh:parameter [ a sh:Parameter ; sh:path sh:expectedValue ; sh:datatype xsd:boolean ; sh:description "The expected value of tosh:hasShape to count." ; sh:order 3.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:focusNode ; sh:class rdfs:Resource ; sh:description "The focus node." ; sh:order 0.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:shapes ; sh:class rdf:List ; sh:description "The list of shapes to walk through." ; sh:order 1.0 ; ] ; sh:parameter [ a sh:Parameter ; sh:path sh:shapesGraph ; sh:class rdfs:Resource ; sh:description "The shapes graph." ; sh:order 2.0 ; ] ; sh:prefixes <http://topbraid.org/tosh> ; sh:returnType xsd:integer ; sh:select """ # The SUM will fail with an error if one of the operands is not a number # (this mechanism is used to propagate errors from tosh:hasShape calls) SELECT (SUM(?s) AS ?result) WHERE { GRAPH $shapesGraph { $shapes rdf:rest*/rdf:first ?shape . } BIND (tosh:hasShape($focusNode, ?shape, true) AS ?hasShape) . BIND (IF(bound(?hasShape), IF(?hasShape = $expectedValue, 1, 0), 'error') AS ?s) . } """ ; . tosh:editGroupDescription a rdf:Property ; rdfs:comment "A description of the property group when in \"edit\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "edit group description" ; rdfs:range xsd:string ; . tosh:graph a rdf:Property ; rdfs:comment "The graph that the shape is validated in." ; rdfs:label "graph" ; . tosh:hasDatatype a sh:SPARQLAskValidator ; rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; rdfs:label "has datatype" ; sh:ask """ ASK { FILTER (datatype($value) = $datatype && spif:isValidForDatatype($value, $datatype)) . } """ ; sh:prefixes <http://topbraid.org/tosh> ; . tosh:hasShape a sh:Function ; dash:apiStatus dash:Experimental ; rdfs:comment """A built-in function of the TopBraid SHACL implementation. Can be used to validate a given (focus) node against a given shape, returning <code>true</code> if the node is valid. If executed within a SHACL validation engine, this uses the shapes graph that was provided when the engine started. If executed in other contexts, e.g. in a stand-alone SPARQL query, the function attempts to use the URI of the current default graph as the shapes graph. This may not always be supported. If called from within an SWP engine, the shapes graph is the current query graph."""^^rdf:HTML ; rdfs:label "has shape" ; sh:parameter [ a sh:Parameter ; sh:path tosh:node ; sh:description "The node to validate." ; ] ; sh:parameter [ a sh:Parameter ; sh:path tosh:shape ; sh:description "The shape that the node is supposed to have." ; ] ; sh:returnType xsd:boolean ; . tosh:isHiddenClass a sh:SPARQLFunction ; dash:apiStatus dash:Experimental ; rdfs:comment "Checks if a given resource is supposed to
91
Corrected SHACL TTL files
8
.ttl
ttl
apache-2.0
TopQuadrant/shacl
20
<NME> common.js <BEF> ADDFILE <MSG> Removing global variables <DFF> @@ -0,0 +1,19 @@ + +var $shapes = null; +var $data = null; + + +module.exports.$shapes = function() { + if (arguments.length === 0) { + return $shapes + } else { + $shapes = arguments[0]; + } +}; +module.exports.$data = function() { + if (arguments.length === 0) { + return $data + } else { + $data = arguments[0]; + } +};
19
Removing global variables
0
.js
js
apache-2.0
TopQuadrant/shacl
21
<NME> common.js <BEF> ADDFILE <MSG> Removing global variables <DFF> @@ -0,0 +1,19 @@ + +var $shapes = null; +var $data = null; + + +module.exports.$shapes = function() { + if (arguments.length === 0) { + return $shapes + } else { + $shapes = arguments[0]; + } +}; +module.exports.$data = function() { + if (arguments.length === 0) { + return $data + } else { + $data = arguments[0]; + } +};
19
Removing global variables
0
.js
js
apache-2.0
TopQuadrant/shacl
22
<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 java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.query.Dataset; import org.apache.jena.query.QuerySolution; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; 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.rdf.model.StmtIterator; import org.apache.jena.sparql.path.P_Inverse; import org.apache.jena.sparql.path.P_Link; import org.apache.jena.sparql.path.Path; import org.apache.jena.sparql.path.eval.PathEval; import org.apache.jena.sparql.util.Context; 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.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; /** * A ValidationEngine uses a given shapes graph (represented via an instance of ShapesGraph) * and performs SHACL validation on a given Dataset. * * Instances of this class should be created via the ValidatorFactory. * * @author Holger Knublauch */ 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> Merge branch 'jena-4.3.2' <DFF> @@ -386,7 +386,7 @@ public class ValidationEngine extends AbstractEngine { return results; } Set<RDFNode> results = new HashSet<>(); - Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), jenaPath, Context.emptyContext); + 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));
1
Merge branch 'jena-4.3.2'
1
.java
java
apache-2.0
TopQuadrant/shacl
23
<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 java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.query.Dataset; import org.apache.jena.query.QuerySolution; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; 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.rdf.model.StmtIterator; import org.apache.jena.sparql.path.P_Inverse; import org.apache.jena.sparql.path.P_Link; import org.apache.jena.sparql.path.Path; import org.apache.jena.sparql.path.eval.PathEval; import org.apache.jena.sparql.util.Context; 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.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; /** * A ValidationEngine uses a given shapes graph (represented via an instance of ShapesGraph) * and performs SHACL validation on a given Dataset. * * Instances of this class should be created via the ValidatorFactory. * * @author Holger Knublauch */ 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> Merge branch 'jena-4.3.2' <DFF> @@ -386,7 +386,7 @@ public class ValidationEngine extends AbstractEngine { return results; } Set<RDFNode> results = new HashSet<>(); - Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), jenaPath, Context.emptyContext); + 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));
1
Merge branch 'jena-4.3.2'
1
.java
java
apache-2.0
TopQuadrant/shacl
24
<NME> SHACLSystemModel.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.util; import java.io.InputStream; import org.apache.jena.rdf.model.Model; import org.apache.jena.util.FileUtils; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.jenax.util.SystemTriples; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.vocabulary.SH; /** * Provides API access to the system graphs needed by SHACL. * * This is used by the stand-alone API only, which bundles these files in an etc folder. * * @author Holger Knublauch */ public class SHACLSystemModel { private static Model shaclModel; public static Model getSHACLModel() { if(shaclModel == null) { shaclModel = JenaUtil.createDefaultModel(); InputStream shaclTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/shacl.ttl"); shaclModel.read(shaclTTL, SH.BASE_URI, FileUtils.langTurtle); InputStream dashTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/dash.ttl"); shaclModel.read(dashTTL, SH.BASE_URI, FileUtils.langTurtle); InputStream toshTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/tosh.ttl"); shaclModel.read(toshTTL, SH.BASE_URI, FileUtils.langTurtle); shaclModel.add(SystemTriples.getVocabularyModel()); SHACLFunctions.registerFunctions(shaclModel); } return shaclModel; } } <MSG> #46: Made a function synchronized <DFF> @@ -37,7 +37,7 @@ public class SHACLSystemModel { private static Model shaclModel; - public static Model getSHACLModel() { + public static synchronized Model getSHACLModel() { if(shaclModel == null) { shaclModel = JenaUtil.createDefaultModel();
1
#46: Made a function synchronized
1
.java
java
apache-2.0
TopQuadrant/shacl
25
<NME> SHACLSystemModel.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.util; import java.io.InputStream; import org.apache.jena.rdf.model.Model; import org.apache.jena.util.FileUtils; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.jenax.util.SystemTriples; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.vocabulary.SH; /** * Provides API access to the system graphs needed by SHACL. * * This is used by the stand-alone API only, which bundles these files in an etc folder. * * @author Holger Knublauch */ public class SHACLSystemModel { private static Model shaclModel; public static Model getSHACLModel() { if(shaclModel == null) { shaclModel = JenaUtil.createDefaultModel(); InputStream shaclTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/shacl.ttl"); shaclModel.read(shaclTTL, SH.BASE_URI, FileUtils.langTurtle); InputStream dashTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/dash.ttl"); shaclModel.read(dashTTL, SH.BASE_URI, FileUtils.langTurtle); InputStream toshTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/tosh.ttl"); shaclModel.read(toshTTL, SH.BASE_URI, FileUtils.langTurtle); shaclModel.add(SystemTriples.getVocabularyModel()); SHACLFunctions.registerFunctions(shaclModel); } return shaclModel; } } <MSG> #46: Made a function synchronized <DFF> @@ -37,7 +37,7 @@ public class SHACLSystemModel { private static Model shaclModel; - public static Model getSHACLModel() { + public static synchronized Model getSHACLModel() { if(shaclModel == null) { shaclModel = JenaUtil.createDefaultModel();
1
#46: Made a function synchronized
1
.java
java
apache-2.0
TopQuadrant/shacl
26
<NME> JenaUtil.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.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; import org.apache.jena.enhanced.EnhGraph; import org.apache.jena.graph.Factory; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; import org.apache.jena.query.ARQ; import org.apache.jena.query.Dataset; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.NodeIterator; import org.apache.jena.rdf.model.Property; 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.apache.jena.rdf.model.StmtIterator; import org.apache.jena.rdf.model.impl.PropertyImpl; import org.apache.jena.rdf.model.impl.StmtIteratorImpl; import org.apache.jena.shared.PrefixMapping; import org.apache.jena.sparql.ARQConstants; import org.apache.jena.sparql.core.DatasetGraph; import org.apache.jena.sparql.core.Var; import org.apache.jena.sparql.engine.ExecutionContext; import org.apache.jena.sparql.engine.binding.Binding; import org.apache.jena.sparql.engine.binding.BindingBuilder; import org.apache.jena.sparql.engine.binding.BindingRoot; import org.apache.jena.sparql.expr.E_Function; import org.apache.jena.sparql.expr.Expr; import org.apache.jena.sparql.expr.ExprEvalException; import org.apache.jena.sparql.expr.ExprList; import org.apache.jena.sparql.expr.ExprTransform; import org.apache.jena.sparql.expr.ExprTransformer; import org.apache.jena.sparql.expr.ExprVar; import org.apache.jena.sparql.expr.NodeValue; import org.apache.jena.sparql.expr.nodevalue.NodeFunctions; import org.apache.jena.sparql.function.FunctionEnv; import org.apache.jena.sparql.graph.NodeTransform; import org.apache.jena.sparql.syntax.syntaxtransform.ElementTransform; import org.apache.jena.sparql.syntax.syntaxtransform.ElementTransformSubst; import org.apache.jena.sparql.syntax.syntaxtransform.ExprTransformNodeElement; import org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps; import org.apache.jena.sparql.util.Context; import org.apache.jena.sparql.util.NodeFactoryExtra; import org.apache.jena.sparql.util.NodeUtils; import org.apache.jena.util.iterator.ExtendedIterator; import org.apache.jena.vocabulary.OWL; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.RDFS; import org.apache.jena.vocabulary.XSD; import org.topbraid.jenax.progress.ProgressMonitor; /** * Some convenience methods to operate on Jena Models. * * These methods are not as stable as the rest of the API, but * they may be of general use. * * @author Holger Knublauch */ public class JenaUtil { // Unstable private static JenaUtilHelper helper = new JenaUtilHelper(); // Leave this line under the helper line above! private static Model dummyModel = JenaUtil.createDefaultModel(); public static final String WITH_IMPORTS_PREFIX = "http://rdfex.org/withImports?uri="; /** * Sets the helper which allows the behavior of some JenaUtil * methods to be modified by the system using the SPIN library. * Note: Should not be used outside of TopBraid - not stable. * @param h the JenaUtilHelper * @return the old helper */ public static JenaUtilHelper setHelper(JenaUtilHelper h) { JenaUtilHelper old = helper; helper = h; return old; } /** * Gets the current helper object. * Note: Should not be used outside of TopBraid - not stable. * @return the helper */ public final static JenaUtilHelper getHelper() { return helper; } /** * Populates a result set of resources reachable from a subject via zero or more steps with a given predicate. * Implementation note: the results set need only implement {@link Collection#add(Object)}. * @param results The transitive objects reached from subject via triples with the given predicate * @param subject the subject to start traversal at * @param predicate the predicate to walk */ public static void addTransitiveObjects(Set<Resource> results, Resource subject, Property predicate) { helper.setGraphReadOptimization(true); try { addTransitiveObjects(results, new HashSet<Resource>(), subject, predicate); } finally { helper.setGraphReadOptimization(false); } } private static void addTransitiveObjects(Set<Resource> resources, Set<Resource> reached, Resource subject, Property predicate) { resources.add(subject); reached.add(subject); StmtIterator it = subject.listProperties(predicate); try { while (it.hasNext()) { RDFNode object = it.next().getObject(); if (object instanceof Resource) { if (!reached.contains(object)) { addTransitiveObjects(resources, reached, (Resource)object, predicate); } } } } finally { it.close(); } } private static void addTransitiveSubjects(Set<Resource> reached, Resource object, Property predicate, ProgressMonitor monitor) { if (object != null) { reached.add(object); StmtIterator it = object.getModel().listStatements(null, predicate, object); try { while (it.hasNext()) { if (monitor != null && monitor.isCanceled()) { it.close(); return; } Resource subject = it.next().getSubject(); if (!reached.contains(subject)) { addTransitiveSubjects(reached, subject, predicate, monitor); } } } finally { it.close(); } } } /** * Turns a QuerySolution into a Binding. * @param map the input QuerySolution * @return a Binding or null if the input is null */ public static Binding asBinding(final QuerySolution map) { if(map != null) { BindingBuilder builder = BindingBuilder.create(); Iterator<String> varNames = map.varNames(); while(varNames.hasNext()) { String varName = varNames.next(); RDFNode node = map.get(varName); if(node != null) { builder.add(Var.alloc(varName), node.asNode()); } } return builder.build(); } else { return null; } } /** * Turns a Binding into a QuerySolutionMap. * @param binding the Binding to convert * @return a QuerySolutionMap */ public static QuerySolutionMap asQuerySolutionMap(Binding binding) { QuerySolutionMap map = new QuerySolutionMap(); Iterator<Var> vars = binding.vars(); while(vars.hasNext()) { Var var = vars.next(); Node node = binding.get(var); if(node != null) { map.add(var.getName(), dummyModel.asRDFNode(node)); } } return map; } /** * Returns a set of resources reachable from an object via one or more reversed steps with a given predicate. * @param object the object to start traversal at * @param predicate the predicate to walk * @param monitor an optional progress monitor to allow cancelation * @return the reached resources */ public static Set<Resource> getAllTransitiveSubjects(Resource object, Property predicate, ProgressMonitor monitor) { Set<Resource> set = new HashSet<>(); helper.setGraphReadOptimization(true); try { addTransitiveSubjects(set, object, predicate, monitor); } finally { helper.setGraphReadOptimization(false); } set.remove(object); return set; } /** * Casts a Resource into a Property. * @param resource the Resource to cast * @return resource as an instance of Property */ public static Property asProperty(Resource resource) { if(resource instanceof Property) { return (Property) resource; } else { return new PropertyImpl(resource.asNode(), (EnhGraph)resource.getModel()); } } public static void collectBaseGraphs(Graph graph, Set<Graph> baseGraphs) { if(graph instanceof MultiUnion) { MultiUnion union = (MultiUnion)graph; collectBaseGraphs(union.getBaseGraph(), baseGraphs); for(Object subGraph : union.getSubGraphs()) { collectBaseGraphs((Graph)subGraph, baseGraphs); } } else if(graph != null) { baseGraphs.add(graph); } } /** * Creates a new Graph. By default this will deliver a plain in-memory graph, * but other implementations may deliver graphs with concurrency support and * other features. * @return a default graph * @see #createDefaultModel() */ public static Graph createDefaultGraph() { return helper.createDefaultGraph(); } /** * Wraps the result of {@link #createDefaultGraph()} into a Model and initializes namespaces. * @return a default Model * @see #createDefaultGraph() */ public static Model createDefaultModel() { Model m = ModelFactory.createModelForGraph(createDefaultGraph()); initNamespaces(m); return m; } /** * Creates a memory Graph with no reification. * @return a new memory graph */ public static Graph createMemoryGraph() { return Factory.createDefaultGraph(); } /** * Creates a memory Model with no reification. * @return a new memory Model */ public static Model createMemoryModel() { return ModelFactory.createModelForGraph(createMemoryGraph()); } public static MultiUnion createMultiUnion() { return helper.createMultiUnion(); } public static MultiUnion createMultiUnion(Graph[] graphs) { return helper.createMultiUnion(graphs); } public static MultiUnion createMultiUnion(Iterator<Graph> graphs) { return helper.createMultiUnion(graphs); } /** * Gets all instances of a given class and its subclasses. * @param cls the class to get the instances of * @return the instances */ public static Set<Resource> getAllInstances(Resource cls) { JenaUtil.setGraphReadOptimization(true); try { Model model = cls.getModel(); Set<Resource> classes = getAllSubClasses(cls); classes.add(cls); Set<Resource> results = new HashSet<>(); for(Resource subClass : classes) { StmtIterator it = model.listStatements(null, RDF.type, subClass); while (it.hasNext()) { results.add(it.next().getSubject()); } } return results; } finally { JenaUtil.setGraphReadOptimization(false); } } public static Set<Resource> getAllSubClasses(Resource cls) { return getAllTransitiveSubjects(cls, RDFS.subClassOf); } /** * Returns a set consisting of a given class and all its subclasses. * Similar to rdfs:subClassOf*. * @param cls the class to return with its subclasses * @return the Set of class resources */ public static Set<Resource> getAllSubClassesStar(Resource cls) { Set<Resource> results = getAllTransitiveSubjects(cls, RDFS.subClassOf); results.add(cls); return results; } public static Set<Resource> getAllSubProperties(Property superProperty) { return getAllTransitiveSubjects(superProperty, RDFS.subPropertyOf); } public static Set<Resource> getAllSuperClasses(Resource cls) { return getAllTransitiveObjects(cls, RDFS.subClassOf); } /** * Returns a set consisting of a given class and all its superclasses. * Similar to rdfs:subClassOf*. * @param cls the class to return with its superclasses * @return the Set of class resources */ public static Set<Resource> getAllSuperClassesStar(Resource cls) { Set<Resource> results = getAllTransitiveObjects(cls, RDFS.subClassOf); results.add(cls); return results; } public static Set<Resource> getAllSuperProperties(Property subProperty) { return getAllTransitiveObjects(subProperty, RDFS.subPropertyOf); } /** * Returns a set of resources reachable from a subject via one or more steps with a given predicate. * @param subject the subject to start at * @param predicate the predicate to traverse * @return the reached resources */ public static Set<Resource> getAllTransitiveObjects(Resource subject, Property predicate) { Set<Resource> set = new HashSet<>(); addTransitiveObjects(set, subject, predicate); set.remove(subject); return set; } private static Set<Resource> getAllTransitiveSubjects(Resource object, Property predicate) { return getAllTransitiveSubjects(object, predicate, null); } public static Set<Resource> getAllTypes(Resource instance) { Set<Resource> types = new HashSet<>(); StmtIterator it = instance.listProperties(RDF.type); try { while (it.hasNext()) { Resource type = it.next().getResource(); types.add(type); types.addAll(getAllSuperClasses(type)); } } finally { it.close(); } return types; } /** * Gets the "base graph" of a Model, walking into MultiUnions if needed. * @param model the Model to get the base graph of * @return the base graph or null if the model contains a MultiUnion that doesn't declare one */ public static Graph getBaseGraph(final Model model) { return getBaseGraph(model.getGraph()); } public static Graph getBaseGraph(Graph graph) { Graph baseGraph = graph; while(baseGraph instanceof MultiUnion) { baseGraph = ((MultiUnion)baseGraph).getBaseGraph(); } return baseGraph; } public static Model getBaseModel(Model model) { Graph baseGraph = getBaseGraph(model); if(baseGraph == model.getGraph()) { return model; } else { return ModelFactory.createModelForGraph(baseGraph); } } /** * For a given subject resource and a given collection of (label/comment) properties this finds the most * suitable value of either property for a given list of languages (usually from the current user's preferences). * For example, if the user's languages are [ "en-AU" ] then the function will prefer "mate"@en-AU over * "friend"@en and never return "freund"@de. The function falls back to literals that have no language * if no better literal has been found. * @param resource the subject resource * @param langs the allowed languages * @param properties the properties to check * @return the best suitable value or null */ public static Literal getBestStringLiteral(Resource resource, List<String> langs, Iterable<Property> properties) { return getBestStringLiteral(resource, langs, properties, (r,p) -> r.listProperties(p)); } public static Literal getBestStringLiteral(Resource resource, List<String> langs, Iterable<Property> properties, BiFunction<Resource,Property,ExtendedIterator<Statement>> getter) { String prefLang = langs.isEmpty() ? null : langs.get(0); Literal label = null; int bestLang = -1; for(Property predicate : properties) { ExtendedIterator<Statement> it = getter.apply(resource, predicate); while(it.hasNext()) { RDFNode object = it.next().getObject(); if(object.isLiteral()) { Literal literal = (Literal)object; String lang = literal.getLanguage(); if(lang.length() == 0 && label == null) { label = literal; } else if(prefLang != null && prefLang.equalsIgnoreCase(lang)) { it.close(); return literal; } else { // 1) Never use a less suitable language // 2) Never replace an already existing label (esp: skos:prefLabel) unless new lang is better // 3) Fall back to more special languages if no other was found (e.g. use en-GB if only "en" is accepted) int startLang = bestLang < 0 ? langs.size() - 1 : (label != null ? bestLang - 1 : bestLang); for(int i = startLang; i > 0; i--) { String langi = langs.get(i); if(langi.equalsIgnoreCase(lang)) { label = literal; bestLang = i; } else if(label == null && lang.contains("-") && NodeFunctions.langMatches(lang, langi)) { label = literal; } } } } } } return label; } /** * Gets the "first" declared rdfs:range of a given property. * If multiple ranges exist, the behavior is undefined. * Note that this method does not consider ranges defined on * super-properties. * @param property the property to get the range of * @return the "first" range Resource or null */ public static Resource getFirstDirectRange(Resource property) { return property.getPropertyResourceValue(RDFS.range); } private static Resource getFirstRange(Resource property, Set<Resource> reached) { Resource directRange = getFirstDirectRange(property); if(directRange != null) { return directRange; } StmtIterator it = property.listProperties(RDFS.subPropertyOf); while (it.hasNext()) { Statement ss = it.next(); if (ss.getObject().isURIResource()) { Resource superProperty = ss.getResource(); if (!reached.contains(superProperty)) { reached.add(superProperty); Resource r = getFirstRange(superProperty, reached); if (r != null) { it.close(); return r; } } } } return null; } /** * Gets the "first" declared rdfs:range of a given property. * If multiple ranges exist, the behavior is undefined. * This method walks up to super-properties if no direct match exists. * @param property the property to get the range of * @return the "first" range Resource or null */ public static Resource getFirstRange(Resource property) { return getFirstRange(property, new HashSet<>()); } public static Set<Resource> getImports(Resource graph) { Set<Resource> results = new HashSet<>(); for(Property importProperty : ImportProperties.get().getImportProperties()) { results.addAll(JenaUtil.getResourceProperties(graph, importProperty)); } return results; } public static Integer getIntegerProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getInt(); } else { return null; } } public static RDFList getListProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().canAs(RDFList.class)) { return s.getResource().as(RDFList.class); } else { return null; } } public static List<Literal> getLiteralProperties(Resource subject, Property predicate) { List<Literal> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isLiteral()) { results.add(s.getLiteral()); } } * returns a value for a given Function. * @param cls the class to start at * @param function the Function to execute on each class * @param T the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) { * @param cls the class to start at * @param function the Function to execute on each class * @param <T> the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) { T result = function.apply(cls); if(result != null) { return result; } return getNearest(cls, function, new HashSet<>()); } private static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function, Set<Resource> reached) { reached.add(cls); StmtIterator it = cls.listProperties(RDFS.subClassOf); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && !reached.contains(s.getResource())) { T result = function.apply(s.getResource()); if(result == null) { result = getNearest(s.getResource(), function, reached); } if(result != null) { it.close(); return result; } } } return null; } /** * Overcomes a design mismatch with Jena: if the base model does not declare a default namespace then the * default namespace of an import is returned - this is not desirable for TopBraid-like scenarios. * @param model the Model to operate on * @param prefix the prefix to get the URI of * @return the URI of prefix */ public static String getNsPrefixURI(Model model, String prefix) { if ("".equals(prefix) && model.getGraph() instanceof MultiUnion) { Graph baseGraph = ((MultiUnion)model.getGraph()).getBaseGraph(); if(baseGraph != null) { return baseGraph.getPrefixMapping().getNsPrefixURI(prefix); } else { return model.getNsPrefixURI(prefix); } } else { return model.getNsPrefixURI(prefix); } } public static RDFNode getProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null) { return s.getObject(); } else { return null; } } public static Resource getResourcePropertyWithType(Resource subject, Property predicate, Resource type) { StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), type)) { it.close(); return s.getResource(); } } return null; } public static List<Resource> getResourceProperties(Resource subject, Property predicate) { List<Resource> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource()) { results.add(s.getResource()); } } return results; } public static Resource getURIResourceProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isURIResource()) { return s.getResource(); } else { return null; } } public static List<Resource> getURIResourceProperties(Resource subject, Property predicate) { List<Resource> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isURIResource()) { results.add(s.getResource()); } } return results; } public static String getStringProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getString(); } else { return null; } } public static boolean getBooleanProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getBoolean(); } else { return false; } } public static Double getDoubleProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getDouble(); } else { return null; } } public static double getDoubleProperty(Resource subject, Property predicate, double defaultValue) { Double d = getDoubleProperty(subject, predicate); if(d != null) { return d; } else { return defaultValue; } } public static List<Graph> getSubGraphs(MultiUnion union) { List<Graph> results = new LinkedList<>(); Graph baseGraph = union.getBaseGraph(); if(baseGraph != null) { results.add(baseGraph); } results.addAll(union.getSubGraphs()); return results; } /** * Gets a Set of all superclasses (rdfs:subClassOf) of a given Resource. * @param subClass the subClass Resource * @return a Collection of class resources */ public static Collection<Resource> getSuperClasses(Resource subClass) { NodeIterator it = subClass.getModel().listObjectsOfProperty(subClass, RDFS.subClassOf); Set<Resource> results = new HashSet<>(); while (it.hasNext()) { RDFNode node = it.nextNode(); if (node instanceof Resource) { results.add((Resource)node); } } return results; } /** * Gets the "first" type of a given Resource. * @param instance the instance to get the type of * @return the type or null */ public static Resource getType(Resource instance) { return instance.getPropertyResourceValue(RDF.type); } /** * Gets a Set of all rdf:types of a given Resource. * @param instance the instance Resource * @return a Collection of type resources */ public static List<Resource> getTypes(Resource instance) { return JenaUtil.getResourceProperties(instance, RDF.type); } /** * Checks whether a given Resource is an instance of a given type, or * a subclass thereof. Make sure that the expectedType parameter is associated * with the right Model, because the system will try to walk up the superclasses * of expectedType. The expectedType may have no Model, in which case * the method will use the instance's Model. * @param instance the Resource to test * @param expectedType the type that instance is expected to have * @return true if resource has rdf:type expectedType */ public static boolean hasIndirectType(Resource instance, Resource expectedType) { if(expectedType.getModel() == null) { expectedType = expectedType.inModel(instance.getModel()); } StmtIterator it = instance.listProperties(RDF.type); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource()) { Resource actualType = s.getResource(); if(actualType.equals(expectedType) || JenaUtil.hasSuperClass(actualType, expectedType)) { it.close(); return true; } } } return false; } /** * Checks whether a given class has a given (transitive) super class. * @param subClass the sub-class * @param superClass the super-class * @return true if subClass has superClass (somewhere up the tree) */ public static boolean hasSuperClass(Resource subClass, Resource superClass) { return hasSuperClass(subClass, superClass, new HashSet<>()); } private static boolean hasSuperClass(Resource subClass, Resource superClass, Set<Resource> reached) { StmtIterator it = subClass.listProperties(RDFS.subClassOf); while(it.hasNext()) { Statement s = it.next(); if(superClass.equals(s.getObject())) { it.close(); return true; } else if(!reached.contains(s.getResource())) { reached.add(s.getResource()); if(hasSuperClass(s.getResource(), superClass, reached)) { it.close(); return true; } } } return false; } /** * Checks whether a given property has a given (transitive) super property. * @param subProperty the sub-property * @param superProperty the super-property * @return true if subProperty has superProperty (somewhere up the tree) */ public static boolean hasSuperProperty(Property subProperty, Property superProperty) { return getAllSuperProperties(subProperty).contains(superProperty); } /** * Sets the usual default namespaces for rdf, rdfs, owl and xsd. * @param graph the Graph to modify */ public static void initNamespaces(Graph graph) { PrefixMapping prefixMapping = graph.getPrefixMapping(); initNamespaces(prefixMapping); } /** * Sets the usual default namespaces for rdf, rdfs, owl and xsd. * @param prefixMapping the Model to modify */ public static void initNamespaces(PrefixMapping prefixMapping) { ensurePrefix(prefixMapping, "rdf", RDF.getURI()); ensurePrefix(prefixMapping, "rdfs", RDFS.getURI()); ensurePrefix(prefixMapping, "owl", OWL.getURI()); ensurePrefix(prefixMapping, "xsd", XSD.getURI()); } private static void ensurePrefix(PrefixMapping prefixMapping, String prefix, String uristr) { // set if not present, or if different if (!uristr.equals(prefixMapping.getNsPrefixURI(prefix))) { prefixMapping.setNsPrefix(prefix, uristr); } } /** * Checks whether a given graph (possibly a MultiUnion) only contains * GraphMemBase instances. * @param graph the Graph to test * @return true if graph is a memory graph */ public static boolean isMemoryGraph(Graph graph) { if(graph instanceof MultiUnion) { for(Graph subGraph : JenaUtil.getSubGraphs((MultiUnion)graph)) { if(!isMemoryGraph(subGraph)) { return false; } } return true; } else { return helper.isMemoryGraph(graph); } } /** * Gets an Iterator over all Statements of a given property or its sub-properties * at a given subject instance. Note that the predicate and subject should be * both attached to a Model to avoid NPEs. * @param subject the subject (may be null) * @param predicate the predicate * @return a StmtIterator */ public static StmtIterator listAllProperties(Resource subject, Property predicate) { List<Statement> results = new LinkedList<>(); helper.setGraphReadOptimization(true); try { listAllProperties(subject, predicate, new HashSet<>(), results); } finally { helper.setGraphReadOptimization(false); } return new StmtIteratorImpl(results.iterator()); } private static void listAllProperties(Resource subject, Property predicate, Set<Property> reached, List<Statement> results) { reached.add(predicate); StmtIterator sit; Model model; if (subject != null) { sit = subject.listProperties(predicate); model = subject.getModel(); } else { model = predicate.getModel(); sit = model.listStatements(null, predicate, (RDFNode)null); } while (sit.hasNext()) { results.add(sit.next()); } // Iterate into direct subproperties StmtIterator it = model.listStatements(null, RDFS.subPropertyOf, predicate); while (it.hasNext()) { Statement sps = it.next(); if (!reached.contains(sps.getSubject())) { Property subProperty = asProperty(sps.getSubject()); listAllProperties(subject, subProperty, reached, results); } } } /** * This indicates that no further changes to the model are needed. * Some implementations may give runtime exceptions if this is violated. * @param m the Model to get as a read-only variant * @return A read-only model */ public static Model asReadOnlyModel(Model m) { return helper.asReadOnlyModel(m); } /** * This indicates that no further changes to the graph are needed. * Some implementations may give runtime exceptions if this is violated. * @param g the Graph to get as a read-only variant * @return a read-only graph */ public static Graph asReadOnlyGraph(Graph g) { return helper.asReadOnlyGraph(g); } // Internal to TopBraid only public static OntModel createOntologyModel(OntModelSpec spec, Model base) { return helper.createOntologyModel(spec,base); } /** * Allows some environments, e.g. TopBraid, to prioritize * a block of code for reading graphs, with no update occurring. * The top of the block should call this with <code>true</code> * with a matching call with <code>false</code> in a finally * block. * * Note: Unstable - don't use outside of TopBraid. * * @param onOrOff true to switch on */ public static void setGraphReadOptimization(boolean onOrOff) { helper.setGraphReadOptimization(onOrOff); } /** * Ensure that we there is a read-only, thread safe version of the * graph. If the graph is not, then create a deep clone that is * both. * * Note: Unstable - don't use outside of TopBraid. * * @param g The given graph * @return A read-only, thread safe version of the given graph. */ public static Graph deepCloneForReadOnlyThreadSafe(Graph g) { return helper.deepCloneReadOnlyGraph(g); } /** * Calls a SPARQL expression and returns the result, using some initial bindings. * * @param expression the expression to execute (must contain absolute URIs) * @param initialBinding the initial bindings for the unbound variables * @param dataset the query Dataset or null for default * @return the result or null */ public static Node invokeExpression(String expression, QuerySolution initialBinding, Dataset dataset) { if (dataset == null) { dataset = ARQFactory.get().getDataset(ModelFactory.createDefaultModel()); } Query query = ARQFactory.get().createExpressionQuery(expression); try(QueryExecution qexec = ARQFactory.get().createQueryExecution(query, dataset, initialBinding)) { ResultSet rs = qexec.execSelect(); Node result = null; if (rs.hasNext()) { QuerySolution qs = rs.next(); String firstVarName = rs.getResultVars().get(0); RDFNode rdfNode = qs.get(firstVarName); if (rdfNode != null) { result = rdfNode.asNode(); } } return result; } } /** * Calls a given SPARQL function with no arguments. * * @param function the URI resource of the function to call * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction0(Resource function, Dataset dataset) { ExprList args = new ExprList(); return invokeFunction(function, args, dataset); } /** * Calls a given SPARQL function with one argument. * * @param function the URI resource of the function to call * @param argument the first argument * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction1(Resource function, RDFNode argument, Dataset dataset) { ExprList args = new ExprList(); args.add(argument != null ? NodeValue.makeNode(argument.asNode()) : new ExprVar("arg1")); return invokeFunction(function, args, dataset); } public static Node invokeFunction1(Resource function, Node argument, Dataset dataset) { return invokeFunction1(function, toRDFNode(argument), dataset); } /** * Calls a given SPARQL function with two arguments. * * @param function the URI resource of the function to call * @param argument1 the first argument * @param argument2 the second argument * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction2(Resource function, RDFNode argument1, RDFNode argument2, Dataset dataset) { ExprList args = new ExprList(); args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1")); args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2")); return invokeFunction(function, args, dataset); } public static Node invokeFunction2(Resource function, Node argument1, Node argument2, Dataset dataset) { return invokeFunction2(function, toRDFNode(argument1), toRDFNode(argument2), dataset); } public static Node invokeFunction3(Resource function, RDFNode argument1, RDFNode argument2, RDFNode argument3, Dataset dataset) { ExprList args = new ExprList(); args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1")); args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2")); args.add(argument3 != null ? NodeValue.makeNode(argument3.asNode()) : new ExprVar("arg3")); return invokeFunction(function, args, dataset); } private static Node invokeFunction(Resource function, ExprList args, Dataset dataset) { if (dataset == null) { dataset = ARQFactory.get().getDataset(ModelFactory.createDefaultModel()); } E_Function expr = new E_Function(function.getURI(), args); DatasetGraph dsg = dataset.asDatasetGraph(); Context cxt = ARQ.getContext().copy(); cxt.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()); FunctionEnv env = new ExecutionContext(cxt, dsg.getDefaultGraph(), dsg, null); try { NodeValue r = expr.eval(BindingRoot.create(), env); if(r != null) { return r.asNode(); } } catch(ExprEvalException ex) { } return null; } public static Node invokeFunction3(Resource function, Node argument1, Node argument2, Node argument3, Dataset dataset) { return invokeFunction3(function, toRDFNode(argument1), toRDFNode(argument2), toRDFNode(argument3), dataset); } /** * Temp patch for a bug in Jena's syntaxtransform, also applying substitutions on * HAVING clauses. * @param query the Query to transform * @param substitutions the variable bindings * @return a new Query with the bindings applied */ public static Query queryWithSubstitutions(Query query, final Map<Var, Node> substitutions) { Query result = QueryTransformOps.transform(query, substitutions); // TODO: Replace this hack once there is a Jena patch if(result.hasHaving()) { NodeTransform nodeTransform = new NodeTransform() { @Override public Node apply(Node node) { Node n = substitutions.get(node) ; if ( n == null ) { return node ; } return n ; } }; ElementTransform eltrans = new ElementTransformSubst(substitutions) ; ExprTransform exprTrans = new ExprTransformNodeElement(nodeTransform, eltrans) ; List<Expr> havingExprs = result.getHavingExprs(); for(int i = 0; i < havingExprs.size(); i++) { Expr old = havingExprs.get(i); Expr neo = ExprTransformer.transform(exprTrans, old) ; if ( neo != old ) { havingExprs.set(i, neo); } } } return result; } public static void sort(List<Resource> nodes) { Collections.sort(nodes, new Comparator<Resource>() { @Override public int compare(Resource o1, Resource o2) { return NodeUtils.compareRDFTerms(o1.asNode(), o2.asNode()); } }); } public static RDFNode toRDFNode(Node node) { if(node != null) { return dummyModel.asRDFNode(node); } else { return null; } } public static String withImports(String uri) { if(!uri.startsWith(WITH_IMPORTS_PREFIX)) { return WITH_IMPORTS_PREFIX + uri; } else { return uri; } } public static String withoutImports(String uri) { if(uri.startsWith(WITH_IMPORTS_PREFIX)) { return uri.substring(WITH_IMPORTS_PREFIX.length()); } else { return uri; } } } <MSG> More JavaDoc clean up <DFF> @@ -632,7 +632,7 @@ public class JenaUtil { * returns a value for a given Function. * @param cls the class to start at * @param function the Function to execute on each class - * @param T the requested result type + * @param <T> the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) {
1
More JavaDoc clean up
1
.java
java
apache-2.0
TopQuadrant/shacl
27
<NME> JenaUtil.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.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; import org.apache.jena.enhanced.EnhGraph; import org.apache.jena.graph.Factory; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; import org.apache.jena.query.ARQ; import org.apache.jena.query.Dataset; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.NodeIterator; import org.apache.jena.rdf.model.Property; 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.apache.jena.rdf.model.StmtIterator; import org.apache.jena.rdf.model.impl.PropertyImpl; import org.apache.jena.rdf.model.impl.StmtIteratorImpl; import org.apache.jena.shared.PrefixMapping; import org.apache.jena.sparql.ARQConstants; import org.apache.jena.sparql.core.DatasetGraph; import org.apache.jena.sparql.core.Var; import org.apache.jena.sparql.engine.ExecutionContext; import org.apache.jena.sparql.engine.binding.Binding; import org.apache.jena.sparql.engine.binding.BindingBuilder; import org.apache.jena.sparql.engine.binding.BindingRoot; import org.apache.jena.sparql.expr.E_Function; import org.apache.jena.sparql.expr.Expr; import org.apache.jena.sparql.expr.ExprEvalException; import org.apache.jena.sparql.expr.ExprList; import org.apache.jena.sparql.expr.ExprTransform; import org.apache.jena.sparql.expr.ExprTransformer; import org.apache.jena.sparql.expr.ExprVar; import org.apache.jena.sparql.expr.NodeValue; import org.apache.jena.sparql.expr.nodevalue.NodeFunctions; import org.apache.jena.sparql.function.FunctionEnv; import org.apache.jena.sparql.graph.NodeTransform; import org.apache.jena.sparql.syntax.syntaxtransform.ElementTransform; import org.apache.jena.sparql.syntax.syntaxtransform.ElementTransformSubst; import org.apache.jena.sparql.syntax.syntaxtransform.ExprTransformNodeElement; import org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps; import org.apache.jena.sparql.util.Context; import org.apache.jena.sparql.util.NodeFactoryExtra; import org.apache.jena.sparql.util.NodeUtils; import org.apache.jena.util.iterator.ExtendedIterator; import org.apache.jena.vocabulary.OWL; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.RDFS; import org.apache.jena.vocabulary.XSD; import org.topbraid.jenax.progress.ProgressMonitor; /** * Some convenience methods to operate on Jena Models. * * These methods are not as stable as the rest of the API, but * they may be of general use. * * @author Holger Knublauch */ public class JenaUtil { // Unstable private static JenaUtilHelper helper = new JenaUtilHelper(); // Leave this line under the helper line above! private static Model dummyModel = JenaUtil.createDefaultModel(); public static final String WITH_IMPORTS_PREFIX = "http://rdfex.org/withImports?uri="; /** * Sets the helper which allows the behavior of some JenaUtil * methods to be modified by the system using the SPIN library. * Note: Should not be used outside of TopBraid - not stable. * @param h the JenaUtilHelper * @return the old helper */ public static JenaUtilHelper setHelper(JenaUtilHelper h) { JenaUtilHelper old = helper; helper = h; return old; } /** * Gets the current helper object. * Note: Should not be used outside of TopBraid - not stable. * @return the helper */ public final static JenaUtilHelper getHelper() { return helper; } /** * Populates a result set of resources reachable from a subject via zero or more steps with a given predicate. * Implementation note: the results set need only implement {@link Collection#add(Object)}. * @param results The transitive objects reached from subject via triples with the given predicate * @param subject the subject to start traversal at * @param predicate the predicate to walk */ public static void addTransitiveObjects(Set<Resource> results, Resource subject, Property predicate) { helper.setGraphReadOptimization(true); try { addTransitiveObjects(results, new HashSet<Resource>(), subject, predicate); } finally { helper.setGraphReadOptimization(false); } } private static void addTransitiveObjects(Set<Resource> resources, Set<Resource> reached, Resource subject, Property predicate) { resources.add(subject); reached.add(subject); StmtIterator it = subject.listProperties(predicate); try { while (it.hasNext()) { RDFNode object = it.next().getObject(); if (object instanceof Resource) { if (!reached.contains(object)) { addTransitiveObjects(resources, reached, (Resource)object, predicate); } } } } finally { it.close(); } } private static void addTransitiveSubjects(Set<Resource> reached, Resource object, Property predicate, ProgressMonitor monitor) { if (object != null) { reached.add(object); StmtIterator it = object.getModel().listStatements(null, predicate, object); try { while (it.hasNext()) { if (monitor != null && monitor.isCanceled()) { it.close(); return; } Resource subject = it.next().getSubject(); if (!reached.contains(subject)) { addTransitiveSubjects(reached, subject, predicate, monitor); } } } finally { it.close(); } } } /** * Turns a QuerySolution into a Binding. * @param map the input QuerySolution * @return a Binding or null if the input is null */ public static Binding asBinding(final QuerySolution map) { if(map != null) { BindingBuilder builder = BindingBuilder.create(); Iterator<String> varNames = map.varNames(); while(varNames.hasNext()) { String varName = varNames.next(); RDFNode node = map.get(varName); if(node != null) { builder.add(Var.alloc(varName), node.asNode()); } } return builder.build(); } else { return null; } } /** * Turns a Binding into a QuerySolutionMap. * @param binding the Binding to convert * @return a QuerySolutionMap */ public static QuerySolutionMap asQuerySolutionMap(Binding binding) { QuerySolutionMap map = new QuerySolutionMap(); Iterator<Var> vars = binding.vars(); while(vars.hasNext()) { Var var = vars.next(); Node node = binding.get(var); if(node != null) { map.add(var.getName(), dummyModel.asRDFNode(node)); } } return map; } /** * Returns a set of resources reachable from an object via one or more reversed steps with a given predicate. * @param object the object to start traversal at * @param predicate the predicate to walk * @param monitor an optional progress monitor to allow cancelation * @return the reached resources */ public static Set<Resource> getAllTransitiveSubjects(Resource object, Property predicate, ProgressMonitor monitor) { Set<Resource> set = new HashSet<>(); helper.setGraphReadOptimization(true); try { addTransitiveSubjects(set, object, predicate, monitor); } finally { helper.setGraphReadOptimization(false); } set.remove(object); return set; } /** * Casts a Resource into a Property. * @param resource the Resource to cast * @return resource as an instance of Property */ public static Property asProperty(Resource resource) { if(resource instanceof Property) { return (Property) resource; } else { return new PropertyImpl(resource.asNode(), (EnhGraph)resource.getModel()); } } public static void collectBaseGraphs(Graph graph, Set<Graph> baseGraphs) { if(graph instanceof MultiUnion) { MultiUnion union = (MultiUnion)graph; collectBaseGraphs(union.getBaseGraph(), baseGraphs); for(Object subGraph : union.getSubGraphs()) { collectBaseGraphs((Graph)subGraph, baseGraphs); } } else if(graph != null) { baseGraphs.add(graph); } } /** * Creates a new Graph. By default this will deliver a plain in-memory graph, * but other implementations may deliver graphs with concurrency support and * other features. * @return a default graph * @see #createDefaultModel() */ public static Graph createDefaultGraph() { return helper.createDefaultGraph(); } /** * Wraps the result of {@link #createDefaultGraph()} into a Model and initializes namespaces. * @return a default Model * @see #createDefaultGraph() */ public static Model createDefaultModel() { Model m = ModelFactory.createModelForGraph(createDefaultGraph()); initNamespaces(m); return m; } /** * Creates a memory Graph with no reification. * @return a new memory graph */ public static Graph createMemoryGraph() { return Factory.createDefaultGraph(); } /** * Creates a memory Model with no reification. * @return a new memory Model */ public static Model createMemoryModel() { return ModelFactory.createModelForGraph(createMemoryGraph()); } public static MultiUnion createMultiUnion() { return helper.createMultiUnion(); } public static MultiUnion createMultiUnion(Graph[] graphs) { return helper.createMultiUnion(graphs); } public static MultiUnion createMultiUnion(Iterator<Graph> graphs) { return helper.createMultiUnion(graphs); } /** * Gets all instances of a given class and its subclasses. * @param cls the class to get the instances of * @return the instances */ public static Set<Resource> getAllInstances(Resource cls) { JenaUtil.setGraphReadOptimization(true); try { Model model = cls.getModel(); Set<Resource> classes = getAllSubClasses(cls); classes.add(cls); Set<Resource> results = new HashSet<>(); for(Resource subClass : classes) { StmtIterator it = model.listStatements(null, RDF.type, subClass); while (it.hasNext()) { results.add(it.next().getSubject()); } } return results; } finally { JenaUtil.setGraphReadOptimization(false); } } public static Set<Resource> getAllSubClasses(Resource cls) { return getAllTransitiveSubjects(cls, RDFS.subClassOf); } /** * Returns a set consisting of a given class and all its subclasses. * Similar to rdfs:subClassOf*. * @param cls the class to return with its subclasses * @return the Set of class resources */ public static Set<Resource> getAllSubClassesStar(Resource cls) { Set<Resource> results = getAllTransitiveSubjects(cls, RDFS.subClassOf); results.add(cls); return results; } public static Set<Resource> getAllSubProperties(Property superProperty) { return getAllTransitiveSubjects(superProperty, RDFS.subPropertyOf); } public static Set<Resource> getAllSuperClasses(Resource cls) { return getAllTransitiveObjects(cls, RDFS.subClassOf); } /** * Returns a set consisting of a given class and all its superclasses. * Similar to rdfs:subClassOf*. * @param cls the class to return with its superclasses * @return the Set of class resources */ public static Set<Resource> getAllSuperClassesStar(Resource cls) { Set<Resource> results = getAllTransitiveObjects(cls, RDFS.subClassOf); results.add(cls); return results; } public static Set<Resource> getAllSuperProperties(Property subProperty) { return getAllTransitiveObjects(subProperty, RDFS.subPropertyOf); } /** * Returns a set of resources reachable from a subject via one or more steps with a given predicate. * @param subject the subject to start at * @param predicate the predicate to traverse * @return the reached resources */ public static Set<Resource> getAllTransitiveObjects(Resource subject, Property predicate) { Set<Resource> set = new HashSet<>(); addTransitiveObjects(set, subject, predicate); set.remove(subject); return set; } private static Set<Resource> getAllTransitiveSubjects(Resource object, Property predicate) { return getAllTransitiveSubjects(object, predicate, null); } public static Set<Resource> getAllTypes(Resource instance) { Set<Resource> types = new HashSet<>(); StmtIterator it = instance.listProperties(RDF.type); try { while (it.hasNext()) { Resource type = it.next().getResource(); types.add(type); types.addAll(getAllSuperClasses(type)); } } finally { it.close(); } return types; } /** * Gets the "base graph" of a Model, walking into MultiUnions if needed. * @param model the Model to get the base graph of * @return the base graph or null if the model contains a MultiUnion that doesn't declare one */ public static Graph getBaseGraph(final Model model) { return getBaseGraph(model.getGraph()); } public static Graph getBaseGraph(Graph graph) { Graph baseGraph = graph; while(baseGraph instanceof MultiUnion) { baseGraph = ((MultiUnion)baseGraph).getBaseGraph(); } return baseGraph; } public static Model getBaseModel(Model model) { Graph baseGraph = getBaseGraph(model); if(baseGraph == model.getGraph()) { return model; } else { return ModelFactory.createModelForGraph(baseGraph); } } /** * For a given subject resource and a given collection of (label/comment) properties this finds the most * suitable value of either property for a given list of languages (usually from the current user's preferences). * For example, if the user's languages are [ "en-AU" ] then the function will prefer "mate"@en-AU over * "friend"@en and never return "freund"@de. The function falls back to literals that have no language * if no better literal has been found. * @param resource the subject resource * @param langs the allowed languages * @param properties the properties to check * @return the best suitable value or null */ public static Literal getBestStringLiteral(Resource resource, List<String> langs, Iterable<Property> properties) { return getBestStringLiteral(resource, langs, properties, (r,p) -> r.listProperties(p)); } public static Literal getBestStringLiteral(Resource resource, List<String> langs, Iterable<Property> properties, BiFunction<Resource,Property,ExtendedIterator<Statement>> getter) { String prefLang = langs.isEmpty() ? null : langs.get(0); Literal label = null; int bestLang = -1; for(Property predicate : properties) { ExtendedIterator<Statement> it = getter.apply(resource, predicate); while(it.hasNext()) { RDFNode object = it.next().getObject(); if(object.isLiteral()) { Literal literal = (Literal)object; String lang = literal.getLanguage(); if(lang.length() == 0 && label == null) { label = literal; } else if(prefLang != null && prefLang.equalsIgnoreCase(lang)) { it.close(); return literal; } else { // 1) Never use a less suitable language // 2) Never replace an already existing label (esp: skos:prefLabel) unless new lang is better // 3) Fall back to more special languages if no other was found (e.g. use en-GB if only "en" is accepted) int startLang = bestLang < 0 ? langs.size() - 1 : (label != null ? bestLang - 1 : bestLang); for(int i = startLang; i > 0; i--) { String langi = langs.get(i); if(langi.equalsIgnoreCase(lang)) { label = literal; bestLang = i; } else if(label == null && lang.contains("-") && NodeFunctions.langMatches(lang, langi)) { label = literal; } } } } } } return label; } /** * Gets the "first" declared rdfs:range of a given property. * If multiple ranges exist, the behavior is undefined. * Note that this method does not consider ranges defined on * super-properties. * @param property the property to get the range of * @return the "first" range Resource or null */ public static Resource getFirstDirectRange(Resource property) { return property.getPropertyResourceValue(RDFS.range); } private static Resource getFirstRange(Resource property, Set<Resource> reached) { Resource directRange = getFirstDirectRange(property); if(directRange != null) { return directRange; } StmtIterator it = property.listProperties(RDFS.subPropertyOf); while (it.hasNext()) { Statement ss = it.next(); if (ss.getObject().isURIResource()) { Resource superProperty = ss.getResource(); if (!reached.contains(superProperty)) { reached.add(superProperty); Resource r = getFirstRange(superProperty, reached); if (r != null) { it.close(); return r; } } } } return null; } /** * Gets the "first" declared rdfs:range of a given property. * If multiple ranges exist, the behavior is undefined. * This method walks up to super-properties if no direct match exists. * @param property the property to get the range of * @return the "first" range Resource or null */ public static Resource getFirstRange(Resource property) { return getFirstRange(property, new HashSet<>()); } public static Set<Resource> getImports(Resource graph) { Set<Resource> results = new HashSet<>(); for(Property importProperty : ImportProperties.get().getImportProperties()) { results.addAll(JenaUtil.getResourceProperties(graph, importProperty)); } return results; } public static Integer getIntegerProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getInt(); } else { return null; } } public static RDFList getListProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().canAs(RDFList.class)) { return s.getResource().as(RDFList.class); } else { return null; } } public static List<Literal> getLiteralProperties(Resource subject, Property predicate) { List<Literal> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isLiteral()) { results.add(s.getLiteral()); } } * returns a value for a given Function. * @param cls the class to start at * @param function the Function to execute on each class * @param T the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) { * @param cls the class to start at * @param function the Function to execute on each class * @param <T> the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) { T result = function.apply(cls); if(result != null) { return result; } return getNearest(cls, function, new HashSet<>()); } private static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function, Set<Resource> reached) { reached.add(cls); StmtIterator it = cls.listProperties(RDFS.subClassOf); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && !reached.contains(s.getResource())) { T result = function.apply(s.getResource()); if(result == null) { result = getNearest(s.getResource(), function, reached); } if(result != null) { it.close(); return result; } } } return null; } /** * Overcomes a design mismatch with Jena: if the base model does not declare a default namespace then the * default namespace of an import is returned - this is not desirable for TopBraid-like scenarios. * @param model the Model to operate on * @param prefix the prefix to get the URI of * @return the URI of prefix */ public static String getNsPrefixURI(Model model, String prefix) { if ("".equals(prefix) && model.getGraph() instanceof MultiUnion) { Graph baseGraph = ((MultiUnion)model.getGraph()).getBaseGraph(); if(baseGraph != null) { return baseGraph.getPrefixMapping().getNsPrefixURI(prefix); } else { return model.getNsPrefixURI(prefix); } } else { return model.getNsPrefixURI(prefix); } } public static RDFNode getProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null) { return s.getObject(); } else { return null; } } public static Resource getResourcePropertyWithType(Resource subject, Property predicate, Resource type) { StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), type)) { it.close(); return s.getResource(); } } return null; } public static List<Resource> getResourceProperties(Resource subject, Property predicate) { List<Resource> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource()) { results.add(s.getResource()); } } return results; } public static Resource getURIResourceProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isURIResource()) { return s.getResource(); } else { return null; } } public static List<Resource> getURIResourceProperties(Resource subject, Property predicate) { List<Resource> results = new LinkedList<>(); StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isURIResource()) { results.add(s.getResource()); } } return results; } public static String getStringProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getString(); } else { return null; } } public static boolean getBooleanProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getBoolean(); } else { return false; } } public static Double getDoubleProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isLiteral()) { return s.getDouble(); } else { return null; } } public static double getDoubleProperty(Resource subject, Property predicate, double defaultValue) { Double d = getDoubleProperty(subject, predicate); if(d != null) { return d; } else { return defaultValue; } } public static List<Graph> getSubGraphs(MultiUnion union) { List<Graph> results = new LinkedList<>(); Graph baseGraph = union.getBaseGraph(); if(baseGraph != null) { results.add(baseGraph); } results.addAll(union.getSubGraphs()); return results; } /** * Gets a Set of all superclasses (rdfs:subClassOf) of a given Resource. * @param subClass the subClass Resource * @return a Collection of class resources */ public static Collection<Resource> getSuperClasses(Resource subClass) { NodeIterator it = subClass.getModel().listObjectsOfProperty(subClass, RDFS.subClassOf); Set<Resource> results = new HashSet<>(); while (it.hasNext()) { RDFNode node = it.nextNode(); if (node instanceof Resource) { results.add((Resource)node); } } return results; } /** * Gets the "first" type of a given Resource. * @param instance the instance to get the type of * @return the type or null */ public static Resource getType(Resource instance) { return instance.getPropertyResourceValue(RDF.type); } /** * Gets a Set of all rdf:types of a given Resource. * @param instance the instance Resource * @return a Collection of type resources */ public static List<Resource> getTypes(Resource instance) { return JenaUtil.getResourceProperties(instance, RDF.type); } /** * Checks whether a given Resource is an instance of a given type, or * a subclass thereof. Make sure that the expectedType parameter is associated * with the right Model, because the system will try to walk up the superclasses * of expectedType. The expectedType may have no Model, in which case * the method will use the instance's Model. * @param instance the Resource to test * @param expectedType the type that instance is expected to have * @return true if resource has rdf:type expectedType */ public static boolean hasIndirectType(Resource instance, Resource expectedType) { if(expectedType.getModel() == null) { expectedType = expectedType.inModel(instance.getModel()); } StmtIterator it = instance.listProperties(RDF.type); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource()) { Resource actualType = s.getResource(); if(actualType.equals(expectedType) || JenaUtil.hasSuperClass(actualType, expectedType)) { it.close(); return true; } } } return false; } /** * Checks whether a given class has a given (transitive) super class. * @param subClass the sub-class * @param superClass the super-class * @return true if subClass has superClass (somewhere up the tree) */ public static boolean hasSuperClass(Resource subClass, Resource superClass) { return hasSuperClass(subClass, superClass, new HashSet<>()); } private static boolean hasSuperClass(Resource subClass, Resource superClass, Set<Resource> reached) { StmtIterator it = subClass.listProperties(RDFS.subClassOf); while(it.hasNext()) { Statement s = it.next(); if(superClass.equals(s.getObject())) { it.close(); return true; } else if(!reached.contains(s.getResource())) { reached.add(s.getResource()); if(hasSuperClass(s.getResource(), superClass, reached)) { it.close(); return true; } } } return false; } /** * Checks whether a given property has a given (transitive) super property. * @param subProperty the sub-property * @param superProperty the super-property * @return true if subProperty has superProperty (somewhere up the tree) */ public static boolean hasSuperProperty(Property subProperty, Property superProperty) { return getAllSuperProperties(subProperty).contains(superProperty); } /** * Sets the usual default namespaces for rdf, rdfs, owl and xsd. * @param graph the Graph to modify */ public static void initNamespaces(Graph graph) { PrefixMapping prefixMapping = graph.getPrefixMapping(); initNamespaces(prefixMapping); } /** * Sets the usual default namespaces for rdf, rdfs, owl and xsd. * @param prefixMapping the Model to modify */ public static void initNamespaces(PrefixMapping prefixMapping) { ensurePrefix(prefixMapping, "rdf", RDF.getURI()); ensurePrefix(prefixMapping, "rdfs", RDFS.getURI()); ensurePrefix(prefixMapping, "owl", OWL.getURI()); ensurePrefix(prefixMapping, "xsd", XSD.getURI()); } private static void ensurePrefix(PrefixMapping prefixMapping, String prefix, String uristr) { // set if not present, or if different if (!uristr.equals(prefixMapping.getNsPrefixURI(prefix))) { prefixMapping.setNsPrefix(prefix, uristr); } } /** * Checks whether a given graph (possibly a MultiUnion) only contains * GraphMemBase instances. * @param graph the Graph to test * @return true if graph is a memory graph */ public static boolean isMemoryGraph(Graph graph) { if(graph instanceof MultiUnion) { for(Graph subGraph : JenaUtil.getSubGraphs((MultiUnion)graph)) { if(!isMemoryGraph(subGraph)) { return false; } } return true; } else { return helper.isMemoryGraph(graph); } } /** * Gets an Iterator over all Statements of a given property or its sub-properties * at a given subject instance. Note that the predicate and subject should be * both attached to a Model to avoid NPEs. * @param subject the subject (may be null) * @param predicate the predicate * @return a StmtIterator */ public static StmtIterator listAllProperties(Resource subject, Property predicate) { List<Statement> results = new LinkedList<>(); helper.setGraphReadOptimization(true); try { listAllProperties(subject, predicate, new HashSet<>(), results); } finally { helper.setGraphReadOptimization(false); } return new StmtIteratorImpl(results.iterator()); } private static void listAllProperties(Resource subject, Property predicate, Set<Property> reached, List<Statement> results) { reached.add(predicate); StmtIterator sit; Model model; if (subject != null) { sit = subject.listProperties(predicate); model = subject.getModel(); } else { model = predicate.getModel(); sit = model.listStatements(null, predicate, (RDFNode)null); } while (sit.hasNext()) { results.add(sit.next()); } // Iterate into direct subproperties StmtIterator it = model.listStatements(null, RDFS.subPropertyOf, predicate); while (it.hasNext()) { Statement sps = it.next(); if (!reached.contains(sps.getSubject())) { Property subProperty = asProperty(sps.getSubject()); listAllProperties(subject, subProperty, reached, results); } } } /** * This indicates that no further changes to the model are needed. * Some implementations may give runtime exceptions if this is violated. * @param m the Model to get as a read-only variant * @return A read-only model */ public static Model asReadOnlyModel(Model m) { return helper.asReadOnlyModel(m); } /** * This indicates that no further changes to the graph are needed. * Some implementations may give runtime exceptions if this is violated. * @param g the Graph to get as a read-only variant * @return a read-only graph */ public static Graph asReadOnlyGraph(Graph g) { return helper.asReadOnlyGraph(g); } // Internal to TopBraid only public static OntModel createOntologyModel(OntModelSpec spec, Model base) { return helper.createOntologyModel(spec,base); } /** * Allows some environments, e.g. TopBraid, to prioritize * a block of code for reading graphs, with no update occurring. * The top of the block should call this with <code>true</code> * with a matching call with <code>false</code> in a finally * block. * * Note: Unstable - don't use outside of TopBraid. * * @param onOrOff true to switch on */ public static void setGraphReadOptimization(boolean onOrOff) { helper.setGraphReadOptimization(onOrOff); } /** * Ensure that we there is a read-only, thread safe version of the * graph. If the graph is not, then create a deep clone that is * both. * * Note: Unstable - don't use outside of TopBraid. * * @param g The given graph * @return A read-only, thread safe version of the given graph. */ public static Graph deepCloneForReadOnlyThreadSafe(Graph g) { return helper.deepCloneReadOnlyGraph(g); } /** * Calls a SPARQL expression and returns the result, using some initial bindings. * * @param expression the expression to execute (must contain absolute URIs) * @param initialBinding the initial bindings for the unbound variables * @param dataset the query Dataset or null for default * @return the result or null */ public static Node invokeExpression(String expression, QuerySolution initialBinding, Dataset dataset) { if (dataset == null) { dataset = ARQFactory.get().getDataset(ModelFactory.createDefaultModel()); } Query query = ARQFactory.get().createExpressionQuery(expression); try(QueryExecution qexec = ARQFactory.get().createQueryExecution(query, dataset, initialBinding)) { ResultSet rs = qexec.execSelect(); Node result = null; if (rs.hasNext()) { QuerySolution qs = rs.next(); String firstVarName = rs.getResultVars().get(0); RDFNode rdfNode = qs.get(firstVarName); if (rdfNode != null) { result = rdfNode.asNode(); } } return result; } } /** * Calls a given SPARQL function with no arguments. * * @param function the URI resource of the function to call * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction0(Resource function, Dataset dataset) { ExprList args = new ExprList(); return invokeFunction(function, args, dataset); } /** * Calls a given SPARQL function with one argument. * * @param function the URI resource of the function to call * @param argument the first argument * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction1(Resource function, RDFNode argument, Dataset dataset) { ExprList args = new ExprList(); args.add(argument != null ? NodeValue.makeNode(argument.asNode()) : new ExprVar("arg1")); return invokeFunction(function, args, dataset); } public static Node invokeFunction1(Resource function, Node argument, Dataset dataset) { return invokeFunction1(function, toRDFNode(argument), dataset); } /** * Calls a given SPARQL function with two arguments. * * @param function the URI resource of the function to call * @param argument1 the first argument * @param argument2 the second argument * @param dataset the Dataset to operate on or null for default * @return the result of the function call */ public static Node invokeFunction2(Resource function, RDFNode argument1, RDFNode argument2, Dataset dataset) { ExprList args = new ExprList(); args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1")); args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2")); return invokeFunction(function, args, dataset); } public static Node invokeFunction2(Resource function, Node argument1, Node argument2, Dataset dataset) { return invokeFunction2(function, toRDFNode(argument1), toRDFNode(argument2), dataset); } public static Node invokeFunction3(Resource function, RDFNode argument1, RDFNode argument2, RDFNode argument3, Dataset dataset) { ExprList args = new ExprList(); args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1")); args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2")); args.add(argument3 != null ? NodeValue.makeNode(argument3.asNode()) : new ExprVar("arg3")); return invokeFunction(function, args, dataset); } private static Node invokeFunction(Resource function, ExprList args, Dataset dataset) { if (dataset == null) { dataset = ARQFactory.get().getDataset(ModelFactory.createDefaultModel()); } E_Function expr = new E_Function(function.getURI(), args); DatasetGraph dsg = dataset.asDatasetGraph(); Context cxt = ARQ.getContext().copy(); cxt.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()); FunctionEnv env = new ExecutionContext(cxt, dsg.getDefaultGraph(), dsg, null); try { NodeValue r = expr.eval(BindingRoot.create(), env); if(r != null) { return r.asNode(); } } catch(ExprEvalException ex) { } return null; } public static Node invokeFunction3(Resource function, Node argument1, Node argument2, Node argument3, Dataset dataset) { return invokeFunction3(function, toRDFNode(argument1), toRDFNode(argument2), toRDFNode(argument3), dataset); } /** * Temp patch for a bug in Jena's syntaxtransform, also applying substitutions on * HAVING clauses. * @param query the Query to transform * @param substitutions the variable bindings * @return a new Query with the bindings applied */ public static Query queryWithSubstitutions(Query query, final Map<Var, Node> substitutions) { Query result = QueryTransformOps.transform(query, substitutions); // TODO: Replace this hack once there is a Jena patch if(result.hasHaving()) { NodeTransform nodeTransform = new NodeTransform() { @Override public Node apply(Node node) { Node n = substitutions.get(node) ; if ( n == null ) { return node ; } return n ; } }; ElementTransform eltrans = new ElementTransformSubst(substitutions) ; ExprTransform exprTrans = new ExprTransformNodeElement(nodeTransform, eltrans) ; List<Expr> havingExprs = result.getHavingExprs(); for(int i = 0; i < havingExprs.size(); i++) { Expr old = havingExprs.get(i); Expr neo = ExprTransformer.transform(exprTrans, old) ; if ( neo != old ) { havingExprs.set(i, neo); } } } return result; } public static void sort(List<Resource> nodes) { Collections.sort(nodes, new Comparator<Resource>() { @Override public int compare(Resource o1, Resource o2) { return NodeUtils.compareRDFTerms(o1.asNode(), o2.asNode()); } }); } public static RDFNode toRDFNode(Node node) { if(node != null) { return dummyModel.asRDFNode(node); } else { return null; } } public static String withImports(String uri) { if(!uri.startsWith(WITH_IMPORTS_PREFIX)) { return WITH_IMPORTS_PREFIX + uri; } else { return uri; } } public static String withoutImports(String uri) { if(uri.startsWith(WITH_IMPORTS_PREFIX)) { return uri.substring(WITH_IMPORTS_PREFIX.length()); } else { return uri; } } } <MSG> More JavaDoc clean up <DFF> @@ -632,7 +632,7 @@ public class JenaUtil { * returns a value for a given Function. * @param cls the class to start at * @param function the Function to execute on each class - * @param T the requested result type + * @param <T> the requested result type * @return the "first" non-null value, or null */ public static <T> T getNearest(Resource cls, java.util.function.Function<Resource,T> function) {
1
More JavaDoc clean up
1
.java
java
apache-2.0
TopQuadrant/shacl
28
<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; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; /** * Vocabulary for http://topbraid.org/tosh */ public class TOSH { public final static String BASE_URI = "http://topbraid.org/tosh"; public final static String NAME = "TopBraid Data Shapes Vocabulary"; 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 NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor"); public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform"); public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform"); 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> Misc performance optimizations and clean up <DFF> @@ -38,6 +38,12 @@ public class TOSH { public final static Resource NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor"); + public final static Resource PropertyGroupShape = ResourceFactory.createResource(NS + "PropertyGroupShape"); + + public final static Resource PropertyShapeShape = ResourceFactory.createResource(NS + "PropertyShapeShape"); + + public final static Resource ShapeShape = ResourceFactory.createResource(NS + "ShapeShape"); + public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform"); public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform");
6
Misc performance optimizations and clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
29
<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; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; /** * Vocabulary for http://topbraid.org/tosh */ public class TOSH { public final static String BASE_URI = "http://topbraid.org/tosh"; public final static String NAME = "TopBraid Data Shapes Vocabulary"; 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 NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor"); public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform"); public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform"); 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> Misc performance optimizations and clean up <DFF> @@ -38,6 +38,12 @@ public class TOSH { public final static Resource NodeProcessor = ResourceFactory.createResource(NS + "NodeProcessor"); + public final static Resource PropertyGroupShape = ResourceFactory.createResource(NS + "PropertyGroupShape"); + + public final static Resource PropertyShapeShape = ResourceFactory.createResource(NS + "PropertyShapeShape"); + + public final static Resource ShapeShape = ResourceFactory.createResource(NS + "ShapeShape"); + public final static Resource TeamworkPlatform = ResourceFactory.createResource(NS + "TeamworkPlatform"); public final static Resource TopBraidPlatform = ResourceFactory.createResource(NS + "TopBraidPlatform");
6
Misc performance optimizations and clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
30
<NME> uniqueLang-001.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/property/uniqueLang-001.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/property/uniqueLang-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/uniqueLang-001.test> rdf:type owl:Ontology ; rdfs:label "Test of sh:uniqueLang at property 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:InvalidInstance1 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidInstance2 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidInstance2 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; ] ; . ex:InvalidInstance1 rdf:type ex:TestShape ; ex:testProperty "Me" ; ex:testProperty "Me"@en ; ex:testProperty "Moi"@fr ; ex:testProperty "Myself"@en ; . ex:InvalidInstance2 rdf:type ex:TestShape ; ex:testProperty "I"@en ; ex:testProperty "Ich"@de ; ex:testProperty "Me"@en ; ex:testProperty "Mich"@de ; sh:property [ sh:predicate ex:testProperty ; rdfs:label "test property" ; sh:datatypeIn ( xsd:string rdf:langString ) ; sh:uniqueLang "true"^^xsd:boolean ; ] ; . sh:property ex:TestShape-testProperty ; . ex:TestShape-testProperty sh:path ex:testProperty ; rdfs:label "test property" ; sh:uniqueLang "true"^^xsd:boolean ; . ex:ValidInstance1 rdf:type ex:TestShape ; ex:testProperty "Me" ; ex:testProperty "Me"@en ; ex:testProperty "Moi"@fr ; ex:testProperty "Myself" ; . <MSG> Latest language updates, esp merging sh:NodeConstraint into sh:Shape (ISSUE-133, 141) <DFF> @@ -62,10 +62,6 @@ ex:TestShape sh:property [ sh:predicate ex:testProperty ; rdfs:label "test property" ; - sh:datatypeIn ( - xsd:string - rdf:langString - ) ; sh:uniqueLang "true"^^xsd:boolean ; ] ; .
0
Latest language updates, esp merging sh:NodeConstraint into sh:Shape (ISSUE-133, 141)
4
.ttl
test
apache-2.0
TopQuadrant/shacl
31
<NME> uniqueLang-001.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/property/uniqueLang-001.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/property/uniqueLang-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/uniqueLang-001.test> rdf:type owl:Ontology ; rdfs:label "Test of sh:uniqueLang at property 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:InvalidInstance1 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidInstance2 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidInstance2 ; sh:resultPath ex:testProperty ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:UniqueLangConstraintComponent ; sh:sourceShape ex:TestShape-testProperty ; ] ; ] ; . ex:InvalidInstance1 rdf:type ex:TestShape ; ex:testProperty "Me" ; ex:testProperty "Me"@en ; ex:testProperty "Moi"@fr ; ex:testProperty "Myself"@en ; . ex:InvalidInstance2 rdf:type ex:TestShape ; ex:testProperty "I"@en ; ex:testProperty "Ich"@de ; ex:testProperty "Me"@en ; ex:testProperty "Mich"@de ; sh:property [ sh:predicate ex:testProperty ; rdfs:label "test property" ; sh:datatypeIn ( xsd:string rdf:langString ) ; sh:uniqueLang "true"^^xsd:boolean ; ] ; . sh:property ex:TestShape-testProperty ; . ex:TestShape-testProperty sh:path ex:testProperty ; rdfs:label "test property" ; sh:uniqueLang "true"^^xsd:boolean ; . ex:ValidInstance1 rdf:type ex:TestShape ; ex:testProperty "Me" ; ex:testProperty "Me"@en ; ex:testProperty "Moi"@fr ; ex:testProperty "Myself" ; . <MSG> Latest language updates, esp merging sh:NodeConstraint into sh:Shape (ISSUE-133, 141) <DFF> @@ -62,10 +62,6 @@ ex:TestShape sh:property [ sh:predicate ex:testProperty ; rdfs:label "test property" ; - sh:datatypeIn ( - xsd:string - rdf:langString - ) ; sh:uniqueLang "true"^^xsd:boolean ; ] ; .
0
Latest language updates, esp merging sh:NodeConstraint into sh:Shape (ISSUE-133, 141)
4
.ttl
test
apache-2.0
TopQuadrant/shacl
32
<NME> SPARQLSyntaxChecker.java <BEF> package org.topbraid.shacl.validation.sparql; import java.util.LinkedList; import java.util.List; import java.util.Set; * * 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.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; import org.apache.jena.sparql.expr.ExprNone; import org.apache.jena.sparql.expr.ExprTripleTerm; import org.apache.jena.sparql.expr.ExprVar; import org.apache.jena.sparql.expr.ExprVisitorFunction; import org.apache.jena.sparql.expr.NodeValue; import org.apache.jena.sparql.syntax.ElementBind; import org.apache.jena.sparql.syntax.ElementData; import org.apache.jena.sparql.syntax.ElementFilter; import org.apache.jena.sparql.syntax.ElementMinus; import org.apache.jena.sparql.syntax.ElementService; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; import org.apache.jena.sparql.syntax.PatternVars; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; /** * Can be used to check for the violation of any of the syntax rules in Appendix A * of the SHACL spec, to prevent certain pre-binding scenarios. * * @author Holger Knublauch */ public class SPARQLSyntaxChecker { /** * Checks whether a given Query violates any of the syntax rules in Appendix A. * @param query the Query to check * @param preBoundVars the potentially pre-bound variables * @return an List of error messages (empty if OK) */ public static List<String> checkQuery(Query query, Set<String> preBoundVars) { List<String> results = new LinkedList<>(); ElementVisitor elementVisitor = new RecursiveElementVisitor(new ElementVisitorBase()) { @Override public void startElement(ElementBind el) { if(preBoundVars.contains(el.getVar().getVarName())) { if(SH.valueVar.getVarName().equals(el.getVar().getVarName()) && el.getExpr().isVariable() && el.getExpr().asVar().equals(SH.thisVar)) { // Ignore clauses injected by engine } else { results.add("Query must not reassign the pre-bound variable " + el.getVar() + " in a BIND clause"); } } } @Override public void startElement(ElementData el) { results.add("Query must not contain VALUES clause"); @Override public void startElement(ElementSubQuery el) { if(!el.getQuery().isQueryResultStar()) { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { if(!project.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including " + varName); } } } if(!queryVars.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including $" + varName); } } } } else { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { if(!project.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including $" + varName); } } } } } private void checkExpression(Expr expr) { final ElementVisitor parent = this; expr.visit(new ExprVisitorFunction() { @Override public void visit(ExprFunctionOp funcOp) { if(funcOp.isGraphPattern()) { funcOp.getElement().visit(parent); } } @Override public void visit(NodeValue nv) { } @Override public void visit(ExprVar nv) { } @Override public void visit(ExprAggregator eAgg) { } @Override public void visit(ExprNone exprNone) { } @Override protected void visitExprFunction(ExprFunction func) { for(Expr expr : func.getArgs()) { expr.visit(this); } } @Override public void visit(ExprTripleTerm tripleTerm) { } }); } }; query.getQueryPattern().visit(elementVisitor); return results; } } <MSG> Tracking latest TopBraid code <DFF> @@ -1,5 +1,6 @@ package org.topbraid.shacl.validation.sparql; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -23,6 +24,7 @@ import org.apache.jena.sparql.syntax.ElementService; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; +import org.apache.jena.sparql.syntax.PatternVars; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; @@ -79,11 +81,24 @@ public class SPARQLSyntaxChecker { @Override public void startElement(ElementSubQuery el) { - if(!el.getQuery().isQueryResultStar()) { + if(el.getQuery().isQueryResultStar()) { + Set<Var> queryVars = new LinkedHashSet<>() ; + PatternVars.vars(queryVars, el.getQuery().getQueryPattern()) ; + for(String varName : preBoundVars) { + if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { + if(!queryVars.contains(Var.alloc(varName))) { + results.add("Sub-query must return all potentially pre-bound variables including $" + varName); + } + } + } + } + else { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { - if(!project.contains(Var.alloc(varName))) { - results.add("Sub-query must return all potentially pre-bound variables including " + varName); + if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { + if(!project.contains(Var.alloc(varName))) { + results.add("Sub-query must return all potentially pre-bound variables including $" + varName); + } } } }
18
Tracking latest TopBraid code
3
.java
java
apache-2.0
TopQuadrant/shacl
33
<NME> SPARQLSyntaxChecker.java <BEF> package org.topbraid.shacl.validation.sparql; import java.util.LinkedList; import java.util.List; import java.util.Set; * * 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.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; import org.apache.jena.sparql.expr.ExprNone; import org.apache.jena.sparql.expr.ExprTripleTerm; import org.apache.jena.sparql.expr.ExprVar; import org.apache.jena.sparql.expr.ExprVisitorFunction; import org.apache.jena.sparql.expr.NodeValue; import org.apache.jena.sparql.syntax.ElementBind; import org.apache.jena.sparql.syntax.ElementData; import org.apache.jena.sparql.syntax.ElementFilter; import org.apache.jena.sparql.syntax.ElementMinus; import org.apache.jena.sparql.syntax.ElementService; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; import org.apache.jena.sparql.syntax.PatternVars; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; /** * Can be used to check for the violation of any of the syntax rules in Appendix A * of the SHACL spec, to prevent certain pre-binding scenarios. * * @author Holger Knublauch */ public class SPARQLSyntaxChecker { /** * Checks whether a given Query violates any of the syntax rules in Appendix A. * @param query the Query to check * @param preBoundVars the potentially pre-bound variables * @return an List of error messages (empty if OK) */ public static List<String> checkQuery(Query query, Set<String> preBoundVars) { List<String> results = new LinkedList<>(); ElementVisitor elementVisitor = new RecursiveElementVisitor(new ElementVisitorBase()) { @Override public void startElement(ElementBind el) { if(preBoundVars.contains(el.getVar().getVarName())) { if(SH.valueVar.getVarName().equals(el.getVar().getVarName()) && el.getExpr().isVariable() && el.getExpr().asVar().equals(SH.thisVar)) { // Ignore clauses injected by engine } else { results.add("Query must not reassign the pre-bound variable " + el.getVar() + " in a BIND clause"); } } } @Override public void startElement(ElementData el) { results.add("Query must not contain VALUES clause"); @Override public void startElement(ElementSubQuery el) { if(!el.getQuery().isQueryResultStar()) { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { if(!project.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including " + varName); } } } if(!queryVars.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including $" + varName); } } } } else { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { if(!project.contains(Var.alloc(varName))) { results.add("Sub-query must return all potentially pre-bound variables including $" + varName); } } } } } private void checkExpression(Expr expr) { final ElementVisitor parent = this; expr.visit(new ExprVisitorFunction() { @Override public void visit(ExprFunctionOp funcOp) { if(funcOp.isGraphPattern()) { funcOp.getElement().visit(parent); } } @Override public void visit(NodeValue nv) { } @Override public void visit(ExprVar nv) { } @Override public void visit(ExprAggregator eAgg) { } @Override public void visit(ExprNone exprNone) { } @Override protected void visitExprFunction(ExprFunction func) { for(Expr expr : func.getArgs()) { expr.visit(this); } } @Override public void visit(ExprTripleTerm tripleTerm) { } }); } }; query.getQueryPattern().visit(elementVisitor); return results; } } <MSG> Tracking latest TopBraid code <DFF> @@ -1,5 +1,6 @@ package org.topbraid.shacl.validation.sparql; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -23,6 +24,7 @@ import org.apache.jena.sparql.syntax.ElementService; import org.apache.jena.sparql.syntax.ElementSubQuery; import org.apache.jena.sparql.syntax.ElementVisitor; import org.apache.jena.sparql.syntax.ElementVisitorBase; +import org.apache.jena.sparql.syntax.PatternVars; import org.apache.jena.sparql.syntax.RecursiveElementVisitor; import org.topbraid.shacl.vocabulary.SH; @@ -79,11 +81,24 @@ public class SPARQLSyntaxChecker { @Override public void startElement(ElementSubQuery el) { - if(!el.getQuery().isQueryResultStar()) { + if(el.getQuery().isQueryResultStar()) { + Set<Var> queryVars = new LinkedHashSet<>() ; + PatternVars.vars(queryVars, el.getQuery().getQueryPattern()) ; + for(String varName : preBoundVars) { + if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { + if(!queryVars.contains(Var.alloc(varName))) { + results.add("Sub-query must return all potentially pre-bound variables including $" + varName); + } + } + } + } + else { VarExprList project = el.getQuery().getProject(); for(String varName : preBoundVars) { - if(!project.contains(Var.alloc(varName))) { - results.add("Sub-query must return all potentially pre-bound variables including " + varName); + if(!SH.currentShapeVar.getVarName().equals(varName) && !SH.shapesGraphVar.getVarName().equals(varName)) { + if(!project.contains(Var.alloc(varName))) { + results.add("Sub-query must return all potentially pre-bound variables including $" + varName); + } } } }
18
Tracking latest TopBraid code
3
.java
java
apache-2.0
TopQuadrant/shacl
34
<NME> RuleUtil.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 import org.apache.jena.vocabulary.RDF; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.vocabulary.TOSH; import org.topbraid.spin.arq.ARQFactory; import java.net.URI; import java.util.ArrayList; import java.util.List; 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.vocabulary.RDF; import org.topbraid.jenax.progress.ProgressMonitor; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.SHACLScriptEngineManager; import org.topbraid.shacl.engine.Shape; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.SH; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to execute SHACL rules. * * @author Holger Knublauch */ public class RuleUtil { /** * Executes all rules from a given shapes Model on a given data Model. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param dataModel the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(Model dataModel, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(dataModel, null, shapesModel, inferencesModel, monitor); } /** * Executes all rules from a given shapes Model on a given focus node (in its data Model). * This only executes the rules from the shapes that have the focus node in their target. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); try { engine.executeAll(); } catch(InterruptedException ex) { } return inferencesModel; } // 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() }); unionGraph.setBaseGraph(shapesModel.getGraph()); shapesModel = ModelFactory.createModelForGraph(unionGraph); } // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); if(inferencesModel == null) { inferencesModel = JenaUtil.createDefaultModel(); inferencesModel.setNsPrefixes(dataModel); inferencesModel.withDefaultMappings(shapesModel); MultiUnion unionGraph = new MultiUnion(new Graph[] { dataModel.getGraph(), inferencesModel.getGraph() }); dataModel = ModelFactory.createModelForGraph(unionGraph); } // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel); RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); boolean nested = SHACLScriptEngineManager.get().begin(); try { engine.applyEntailments(); if(focusNode == null) { engine.setExcludeNeverMaterialize(true); engine.executeAll(); } else { List<Shape> shapes = getShapesWithTargetNode(focusNode, shapesGraph); engine.executeShapes(shapes, focusNode); } } catch(InterruptedException ex) { return null; } finally { SHACLScriptEngineManager.get().end(nested); } return inferencesModel; } public static List<Shape> getShapesWithTargetNode(RDFNode focusNode, ShapesGraph shapesGraph) { // TODO: Not a particularly smart algorithm - walks all shapes that have rules List<Shape> shapes = new ArrayList<>(); for(Shape shape : shapesGraph.getRootShapes()) { if(shape.getShapeResource().hasProperty(SH.rule) && shape.getShapeResource().hasTargetNode(focusNode)) { shapes.add(shape); } } return shapes; } } <MSG> Updated to Jena 3.4.0, misc SHACL-JS improvements <DFF> @@ -12,6 +12,7 @@ import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.vocabulary.RDF; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; +import org.topbraid.shacl.js.SHACLScriptEngineManager; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.vocabulary.TOSH; import org.topbraid.spin.arq.ARQFactory; @@ -72,10 +73,15 @@ public class RuleUtil { RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); + boolean nested = SHACLScriptEngineManager.begin(); try { engine.executeAll(); } catch(InterruptedException ex) { + return null; + } + finally { + SHACLScriptEngineManager.end(nested); } return inferencesModel; }
6
Updated to Jena 3.4.0, misc SHACL-JS improvements
0
.java
java
apache-2.0
TopQuadrant/shacl
35
<NME> RuleUtil.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 import org.apache.jena.vocabulary.RDF; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.vocabulary.TOSH; import org.topbraid.spin.arq.ARQFactory; import java.net.URI; import java.util.ArrayList; import java.util.List; 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.vocabulary.RDF; import org.topbraid.jenax.progress.ProgressMonitor; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.SHACLScriptEngineManager; import org.topbraid.shacl.engine.Shape; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.SH; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to execute SHACL rules. * * @author Holger Knublauch */ public class RuleUtil { /** * Executes all rules from a given shapes Model on a given data Model. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param dataModel the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(Model dataModel, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(dataModel, null, shapesModel, inferencesModel, monitor); } /** * Executes all rules from a given shapes Model on a given focus node (in its data Model). * This only executes the rules from the shapes that have the focus node in their target. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); try { engine.executeAll(); } catch(InterruptedException ex) { } return inferencesModel; } // 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() }); unionGraph.setBaseGraph(shapesModel.getGraph()); shapesModel = ModelFactory.createModelForGraph(unionGraph); } // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); if(inferencesModel == null) { inferencesModel = JenaUtil.createDefaultModel(); inferencesModel.setNsPrefixes(dataModel); inferencesModel.withDefaultMappings(shapesModel); MultiUnion unionGraph = new MultiUnion(new Graph[] { dataModel.getGraph(), inferencesModel.getGraph() }); dataModel = ModelFactory.createModelForGraph(unionGraph); } // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel); RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); boolean nested = SHACLScriptEngineManager.get().begin(); try { engine.applyEntailments(); if(focusNode == null) { engine.setExcludeNeverMaterialize(true); engine.executeAll(); } else { List<Shape> shapes = getShapesWithTargetNode(focusNode, shapesGraph); engine.executeShapes(shapes, focusNode); } } catch(InterruptedException ex) { return null; } finally { SHACLScriptEngineManager.get().end(nested); } return inferencesModel; } public static List<Shape> getShapesWithTargetNode(RDFNode focusNode, ShapesGraph shapesGraph) { // TODO: Not a particularly smart algorithm - walks all shapes that have rules List<Shape> shapes = new ArrayList<>(); for(Shape shape : shapesGraph.getRootShapes()) { if(shape.getShapeResource().hasProperty(SH.rule) && shape.getShapeResource().hasTargetNode(focusNode)) { shapes.add(shape); } } return shapes; } } <MSG> Updated to Jena 3.4.0, misc SHACL-JS improvements <DFF> @@ -12,6 +12,7 @@ import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.vocabulary.RDF; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; +import org.topbraid.shacl.js.SHACLScriptEngineManager; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.vocabulary.TOSH; import org.topbraid.spin.arq.ARQFactory; @@ -72,10 +73,15 @@ public class RuleUtil { RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); + boolean nested = SHACLScriptEngineManager.begin(); try { engine.executeAll(); } catch(InterruptedException ex) { + return null; + } + finally { + SHACLScriptEngineManager.end(nested); } return inferencesModel; }
6
Updated to Jena 3.4.0, misc SHACL-JS improvements
0
.java
java
apache-2.0
TopQuadrant/shacl
36
<NME> nestedShape1.jsonld <BEF> ADDFILE <MSG> Refactoring, moving base dir and splitting validation-engine <DFF> @@ -0,0 +1,365 @@ +{ + "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", + "http://www.w3.org/ns/shacl#Shape" + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#", + "http://www.w3.org/ns/shacl#property": [ + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#node": [ + { + "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", + "http://www.w3.org/ns/shacl#Shape" + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/node-property", + "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" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/city", + "@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#city" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "city" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/country", + "@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#country" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "country" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/postcode", + "@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#postcode" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "postcode" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/street", + "@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#street" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "street" + } + ] + } + ], + "http://www.w3.org/ns/shacl#closed": [ + { + "@value": true + } + ] + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address", + "@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#address" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "address" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/age", + "@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#age" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "age" + } + ], + "http://www.w3.org/ns/shacl#minExclusive": [ + { + "@value": 17 + } + ] + }, + { + "http://raml.org/vocabularies/shapes#ordered": [ + { + "@value": true + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 3 + } + ], + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 5 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer" + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/scores", + "@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#scores" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "scores" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/gender", + "@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#gender" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "gender" + } + ], + "http://www.w3.org/ns/shacl#in": { + "@list": [ + { + "@value": "female" + }, + { + "@value": "male" + } + ] + } + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/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#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 0 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/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#closed": [ + { + "@value": true + } + ] +}
365
Refactoring, moving base dir and splitting validation-engine
0
.jsonld
jsonld
apache-2.0
TopQuadrant/shacl
37
<NME> nestedShape1.jsonld <BEF> ADDFILE <MSG> Refactoring, moving base dir and splitting validation-engine <DFF> @@ -0,0 +1,365 @@ +{ + "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", + "http://www.w3.org/ns/shacl#Shape" + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#", + "http://www.w3.org/ns/shacl#property": [ + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#node": [ + { + "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", + "http://www.w3.org/ns/shacl#Shape" + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/node-property", + "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" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/city", + "@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#city" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "city" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/country", + "@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#country" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "country" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/postcode", + "@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#postcode" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "postcode" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address/property/street", + "@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#street" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "street" + } + ] + } + ], + "http://www.w3.org/ns/shacl#closed": [ + { + "@value": true + } + ] + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/address", + "@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#address" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "address" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/age", + "@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#age" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "age" + } + ], + "http://www.w3.org/ns/shacl#minExclusive": [ + { + "@value": 17 + } + ] + }, + { + "http://raml.org/vocabularies/shapes#ordered": [ + { + "@value": true + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 3 + } + ], + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 5 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer" + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/scores", + "@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#scores" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "scores" + } + ] + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/property/gender", + "@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#gender" + } + ], + "http://raml.org/vocabularies/shapes#propertyLabel": [ + { + "@value": "gender" + } + ], + "http://www.w3.org/ns/shacl#in": { + "@list": [ + { + "@value": "female" + }, + { + "@value": "male" + } + ] + } + }, + { + "http://www.w3.org/ns/shacl#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 1 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/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#maxCount": [ + { + "@value": 1 + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#minCount": [ + { + "@value": 0 + } + ], + "@id": "https://mulesoft-labs.github.io/amf-playground#/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#closed": [ + { + "@value": true + } + ] +}
365
Refactoring, moving base dir and splitting validation-engine
0
.jsonld
jsonld
apache-2.0
TopQuadrant/shacl
38
<NME> NOTICE <BEF> TopBraid SHACL API ================== Copyright 2017 TopQuadrant Inc. <MSG> Note original material <DFF> @@ -1,4 +1,4 @@ TopBraid SHACL API ================== -Copyright 2017 TopQuadrant Inc. +Original commit content: Copyright 2015-2017 TopQuadrant Inc.
1
Note original material
1
NOTICE
apache-2.0
TopQuadrant/shacl
39
<NME> NOTICE <BEF> TopBraid SHACL API ================== Copyright 2017 TopQuadrant Inc. <MSG> Note original material <DFF> @@ -1,4 +1,4 @@ TopBraid SHACL API ================== -Copyright 2017 TopQuadrant Inc. +Original commit content: Copyright 2015-2017 TopQuadrant Inc.
1
Note original material
1
NOTICE
apache-2.0
TopQuadrant/shacl
40
<NME> GraphValidationTestCaseType.java <BEF> ADDFILE <MSG> Missing test case runner file <DFF> @@ -0,0 +1,125 @@ +package org.topbraid.shacl.testcases; + +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.apache.jena.query.Dataset; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Property; +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.vocabulary.RDF; +import org.apache.jena.vocabulary.RDFS; +import org.topbraid.shacl.arq.SHACLPaths; +import org.topbraid.shacl.util.SHACLUtil; +import org.topbraid.shacl.validation.SHACLSuggestionGenerator; +import org.topbraid.shacl.validation.SHACLSuggestionGeneratorFactory; +import org.topbraid.shacl.validation.ShapesGraph; +import org.topbraid.shacl.validation.ValidationEngineFactory; +import org.topbraid.shacl.validation.predicates.ExcludeMetaShapesPredicate; +import org.topbraid.shacl.vocabulary.DASH; +import org.topbraid.shacl.vocabulary.SH; +import org.topbraid.spin.arq.ARQFactory; +import org.topbraid.spin.util.JenaDatatypes; +import org.topbraid.spin.util.JenaUtil; + +public class GraphValidationTestCaseType implements TestCaseType { + + public final static List<Property> IGNORED_PROPERTIES = Arrays.asList(new Property[] { + SH.message, // For TopBraid's suggestions + SH.resultMessage + }); + + + public static void addStatements(Model model, Statement s) { + if(!IGNORED_PROPERTIES.contains(s.getPredicate())) { + model.add(s); + } + if(s.getObject().isAnon()) { + for(Statement t : s.getModel().listStatements(s.getResource(), null, (RDFNode)null).toList()) { + addStatements(model, t); + } + } + } + + + public static void addSuggestions(Model dataModel, Model shapesModel, Model actualResults) { + SHACLSuggestionGenerator generator = SHACLSuggestionGeneratorFactory.get().createSuggestionGenerator(dataModel, shapesModel); + if(generator == null) { + throw new UnsupportedOperationException("Cannot run test due to no suggestion generator installed"); + } + generator.addSuggestions(actualResults, Integer.MAX_VALUE, null); + } + + + @Override + public Collection<TestCase> getTestCases(Model model, Resource graph) { + List<TestCase> results = new LinkedList<TestCase>(); + for(Resource resource : JenaUtil.getAllInstances(model.getResource(DASH.GraphValidationTestCase.getURI()))) { + results.add(new GraphValidationTestCase(graph, resource)); + } + return results; + } + + + private static class GraphValidationTestCase extends TestCase { + + GraphValidationTestCase(Resource graph, Resource resource) { + super(graph, resource); + } + + @Override + public void run(Model results) throws Exception { + + Model dataModel = SHACLUtil.withDefaultValueTypeInferences(getResource().getModel()); + + Dataset dataset = ARQFactory.get().getDataset(dataModel); + URI shapesGraphURI = SHACLUtil.withShapesGraph(dataset); + + ShapesGraph shapesGraph = new ShapesGraph(dataset.getNamedModel(shapesGraphURI.toString()), + getResource().hasProperty(DASH.validateShapes, JenaDatatypes.TRUE) ? null : new ExcludeMetaShapesPredicate()); + Resource actualReport = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null).validateAll(); + Model actualResults = actualReport.getModel(); + if(getResource().hasProperty(DASH.includeSuggestions, JenaDatatypes.TRUE)) { + Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString()); + addSuggestions(dataModel, shapesModel, actualResults); + } + actualResults.setNsPrefix(SH.PREFIX, SH.NS); + actualResults.setNsPrefix("rdf", RDF.getURI()); + actualResults.setNsPrefix("rdfs", RDFS.getURI()); + for(Property ignoredProperty : IGNORED_PROPERTIES) { + actualResults.removeAll(null, ignoredProperty, (RDFNode)null); + } + Model expectedModel = JenaUtil.createDefaultModel(); + Resource expectedReport = getResource().getPropertyResourceValue(DASH.expectedResult); + for(Statement s : expectedReport.listProperties().toList()) { + expectedModel.add(s); + } + for(Statement s : expectedReport.listProperties(SH.result).toList()) { + for(Statement t : s.getResource().listProperties().toList()) { + if(t.getPredicate().equals(DASH.suggestion)) { + addStatements(expectedModel, t); + } + else if(SH.resultPath.equals(t.getPredicate())) { + expectedModel.add(t.getSubject(), t.getPredicate(), + SHACLPaths.clonePath(t.getResource(), expectedModel)); + } + else { + expectedModel.add(t); + } + } + } + if(expectedModel.getGraph().isIsomorphicWith(actualResults.getGraph())) { + createResult(results, DASH.SuccessTestCaseResult); + } + else { + createFailure(results, + "Mismatching validation results. Expected " + expectedModel.size() + " triples, found " + actualResults.size()); + } + } + } +}
125
Missing test case runner file
0
.java
java
apache-2.0
TopQuadrant/shacl
41
<NME> GraphValidationTestCaseType.java <BEF> ADDFILE <MSG> Missing test case runner file <DFF> @@ -0,0 +1,125 @@ +package org.topbraid.shacl.testcases; + +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.apache.jena.query.Dataset; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Property; +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.vocabulary.RDF; +import org.apache.jena.vocabulary.RDFS; +import org.topbraid.shacl.arq.SHACLPaths; +import org.topbraid.shacl.util.SHACLUtil; +import org.topbraid.shacl.validation.SHACLSuggestionGenerator; +import org.topbraid.shacl.validation.SHACLSuggestionGeneratorFactory; +import org.topbraid.shacl.validation.ShapesGraph; +import org.topbraid.shacl.validation.ValidationEngineFactory; +import org.topbraid.shacl.validation.predicates.ExcludeMetaShapesPredicate; +import org.topbraid.shacl.vocabulary.DASH; +import org.topbraid.shacl.vocabulary.SH; +import org.topbraid.spin.arq.ARQFactory; +import org.topbraid.spin.util.JenaDatatypes; +import org.topbraid.spin.util.JenaUtil; + +public class GraphValidationTestCaseType implements TestCaseType { + + public final static List<Property> IGNORED_PROPERTIES = Arrays.asList(new Property[] { + SH.message, // For TopBraid's suggestions + SH.resultMessage + }); + + + public static void addStatements(Model model, Statement s) { + if(!IGNORED_PROPERTIES.contains(s.getPredicate())) { + model.add(s); + } + if(s.getObject().isAnon()) { + for(Statement t : s.getModel().listStatements(s.getResource(), null, (RDFNode)null).toList()) { + addStatements(model, t); + } + } + } + + + public static void addSuggestions(Model dataModel, Model shapesModel, Model actualResults) { + SHACLSuggestionGenerator generator = SHACLSuggestionGeneratorFactory.get().createSuggestionGenerator(dataModel, shapesModel); + if(generator == null) { + throw new UnsupportedOperationException("Cannot run test due to no suggestion generator installed"); + } + generator.addSuggestions(actualResults, Integer.MAX_VALUE, null); + } + + + @Override + public Collection<TestCase> getTestCases(Model model, Resource graph) { + List<TestCase> results = new LinkedList<TestCase>(); + for(Resource resource : JenaUtil.getAllInstances(model.getResource(DASH.GraphValidationTestCase.getURI()))) { + results.add(new GraphValidationTestCase(graph, resource)); + } + return results; + } + + + private static class GraphValidationTestCase extends TestCase { + + GraphValidationTestCase(Resource graph, Resource resource) { + super(graph, resource); + } + + @Override + public void run(Model results) throws Exception { + + Model dataModel = SHACLUtil.withDefaultValueTypeInferences(getResource().getModel()); + + Dataset dataset = ARQFactory.get().getDataset(dataModel); + URI shapesGraphURI = SHACLUtil.withShapesGraph(dataset); + + ShapesGraph shapesGraph = new ShapesGraph(dataset.getNamedModel(shapesGraphURI.toString()), + getResource().hasProperty(DASH.validateShapes, JenaDatatypes.TRUE) ? null : new ExcludeMetaShapesPredicate()); + Resource actualReport = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null).validateAll(); + Model actualResults = actualReport.getModel(); + if(getResource().hasProperty(DASH.includeSuggestions, JenaDatatypes.TRUE)) { + Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString()); + addSuggestions(dataModel, shapesModel, actualResults); + } + actualResults.setNsPrefix(SH.PREFIX, SH.NS); + actualResults.setNsPrefix("rdf", RDF.getURI()); + actualResults.setNsPrefix("rdfs", RDFS.getURI()); + for(Property ignoredProperty : IGNORED_PROPERTIES) { + actualResults.removeAll(null, ignoredProperty, (RDFNode)null); + } + Model expectedModel = JenaUtil.createDefaultModel(); + Resource expectedReport = getResource().getPropertyResourceValue(DASH.expectedResult); + for(Statement s : expectedReport.listProperties().toList()) { + expectedModel.add(s); + } + for(Statement s : expectedReport.listProperties(SH.result).toList()) { + for(Statement t : s.getResource().listProperties().toList()) { + if(t.getPredicate().equals(DASH.suggestion)) { + addStatements(expectedModel, t); + } + else if(SH.resultPath.equals(t.getPredicate())) { + expectedModel.add(t.getSubject(), t.getPredicate(), + SHACLPaths.clonePath(t.getResource(), expectedModel)); + } + else { + expectedModel.add(t); + } + } + } + if(expectedModel.getGraph().isIsomorphicWith(actualResults.getGraph())) { + createResult(results, DASH.SuccessTestCaseResult); + } + else { + createFailure(results, + "Mismatching validation results. Expected " + expectedModel.size() + " triples, found " + actualResults.size()); + } + } + } +}
125
Missing test case runner file
0
.java
java
apache-2.0
TopQuadrant/shacl
42
<NME> log4j.properties <BEF> ADDFILE <MSG> Add resources/log4j.properties for testing <DFF> @@ -0,0 +1,11 @@ +log4j.rootLogger=INFO, stdlog + +log4j.appender.stdlog=org.apache.log4j.ConsoleAppender +## log4j.appender.stdlog.target=System.err +log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout +log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-25c{1} :: %m%n + +log4j.logger.org.apache.jena=WARN +# For TQ-SHACL +log4j.logger.org.apache.jena.riot=ERROR +log4j.logger.org.apache.jena.sparql.expr.NodeValue=ERROR
11
Add resources/log4j.properties for testing
0
.properties
properties
apache-2.0
TopQuadrant/shacl
43
<NME> log4j.properties <BEF> ADDFILE <MSG> Add resources/log4j.properties for testing <DFF> @@ -0,0 +1,11 @@ +log4j.rootLogger=INFO, stdlog + +log4j.appender.stdlog=org.apache.log4j.ConsoleAppender +## log4j.appender.stdlog.target=System.err +log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout +log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-25c{1} :: %m%n + +log4j.logger.org.apache.jena=WARN +# For TQ-SHACL +log4j.logger.org.apache.jena.riot=ERROR +log4j.logger.org.apache.jena.sparql.expr.NodeValue=ERROR
11
Add resources/log4j.properties for testing
0
.properties
properties
apache-2.0
TopQuadrant/shacl
44
<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 checking completes. * If all is good, click "release" at the top. 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> Update process.md <DFF> @@ -116,6 +116,7 @@ It still says "SNAPSHOT" because the dry run does not change the version in POM. This has two steps: `mvn release:clean release:prepare -Prelease $KEY $VER` + `mvn release:perform -Prelease $KEY $VER` ### If it goes wrong:
1
Update process.md
0
.md
md
apache-2.0
TopQuadrant/shacl
45
<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 checking completes. * If all is good, click "release" at the top. 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> Update process.md <DFF> @@ -116,6 +116,7 @@ It still says "SNAPSHOT" because the dry run does not change the version in POM. This has two steps: `mvn release:clean release:prepare -Prelease $KEY $VER` + `mvn release:perform -Prelease $KEY $VER` ### If it goes wrong:
1
Update process.md
0
.md
md
apache-2.0
TopQuadrant/shacl
46
<NME> ValidationExample.java <BEF> package org.topbraid.shacl; import java.net.URI; import java.util.UUID; 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.util.FileUtils; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; public class ValidationExample { /** * Loads an example SHACL file and validates all constraints. * This file can also be used as a starting point for your own custom applications. */ public static void main(String[] args) throws Exception { package org.topbraid.shacl; Model dataModel = JenaUtil.createMemoryModel(); dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle); // Load the shapes Model (here, includes the dataModel because that has shape definitions too) Model shaclModel = SHACLSystemModel.getSHACLModel(); MultiUnion unionGraph = new MultiUnion(new Graph[] { shaclModel.getGraph(), dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Create Dataset that contains both the main query model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString()); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); // Run the validator Model results = new ModelConstraintValidator().validateModel(dataset, shapesGraphURI, null, true, null, null).getModel(); // Print violations System.out.println(ModelPrinter.get().print(results)); } } * 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> Significant code clean up <DFF> @@ -1,25 +1,16 @@ package org.topbraid.shacl; -import java.net.URI; -import java.util.UUID; - -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.Resource; import org.apache.jena.util.FileUtils; -import org.topbraid.shacl.arq.SHACLFunctions; -import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; -import org.topbraid.spin.arq.ARQFactory; +import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.spin.util.JenaUtil; public class ValidationExample { /** - * Loads an example SHACL file and validates all constraints. - * This file can also be used as a starting point for your own custom applications. + * Loads an example SHACL file and validates all focus nodes against all shapes. */ public static void main(String[] args) throws Exception { @@ -27,27 +18,11 @@ public class ValidationExample { Model dataModel = JenaUtil.createMemoryModel(); dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle); - // Load the shapes Model (here, includes the dataModel because that has shape definitions too) - Model shaclModel = SHACLSystemModel.getSHACLModel(); - MultiUnion unionGraph = new MultiUnion(new Graph[] { - shaclModel.getGraph(), - dataModel.getGraph() - }); - Model shapesModel = ModelFactory.createModelForGraph(unionGraph); - - // Make sure all sh:Functions are registered - SHACLFunctions.registerFunctions(shapesModel); - - // Create Dataset that contains both the main query model and the shapes model - // (here, using a temporary URI for the shapes graph) - URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString()); - Dataset dataset = ARQFactory.get().getDataset(dataModel); - dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); - - // Run the validator - Model results = new ModelConstraintValidator().validateModel(dataset, shapesGraphURI, null, true, null, null).getModel(); + // 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(results)); + System.out.println(ModelPrinter.get().print(report.getModel())); } } \ No newline at end of file
7
Significant code clean up
32
.java
java
apache-2.0
TopQuadrant/shacl
47
<NME> ValidationExample.java <BEF> package org.topbraid.shacl; import java.net.URI; import java.util.UUID; 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.util.FileUtils; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; public class ValidationExample { /** * Loads an example SHACL file and validates all constraints. * This file can also be used as a starting point for your own custom applications. */ public static void main(String[] args) throws Exception { package org.topbraid.shacl; Model dataModel = JenaUtil.createMemoryModel(); dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle); // Load the shapes Model (here, includes the dataModel because that has shape definitions too) Model shaclModel = SHACLSystemModel.getSHACLModel(); MultiUnion unionGraph = new MultiUnion(new Graph[] { shaclModel.getGraph(), dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Create Dataset that contains both the main query model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString()); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); // Run the validator Model results = new ModelConstraintValidator().validateModel(dataset, shapesGraphURI, null, true, null, null).getModel(); // Print violations System.out.println(ModelPrinter.get().print(results)); } } * 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> Significant code clean up <DFF> @@ -1,25 +1,16 @@ package org.topbraid.shacl; -import java.net.URI; -import java.util.UUID; - -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.Resource; import org.apache.jena.util.FileUtils; -import org.topbraid.shacl.arq.SHACLFunctions; -import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; -import org.topbraid.spin.arq.ARQFactory; +import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.spin.util.JenaUtil; public class ValidationExample { /** - * Loads an example SHACL file and validates all constraints. - * This file can also be used as a starting point for your own custom applications. + * Loads an example SHACL file and validates all focus nodes against all shapes. */ public static void main(String[] args) throws Exception { @@ -27,27 +18,11 @@ public class ValidationExample { Model dataModel = JenaUtil.createMemoryModel(); dataModel.read(ValidationExample.class.getResourceAsStream("/sh/tests/core/property/class-001.test.ttl"), "urn:dummy", FileUtils.langTurtle); - // Load the shapes Model (here, includes the dataModel because that has shape definitions too) - Model shaclModel = SHACLSystemModel.getSHACLModel(); - MultiUnion unionGraph = new MultiUnion(new Graph[] { - shaclModel.getGraph(), - dataModel.getGraph() - }); - Model shapesModel = ModelFactory.createModelForGraph(unionGraph); - - // Make sure all sh:Functions are registered - SHACLFunctions.registerFunctions(shapesModel); - - // Create Dataset that contains both the main query model and the shapes model - // (here, using a temporary URI for the shapes graph) - URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString()); - Dataset dataset = ARQFactory.get().getDataset(dataModel); - dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); - - // Run the validator - Model results = new ModelConstraintValidator().validateModel(dataset, shapesGraphURI, null, true, null, null).getModel(); + // 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(results)); + System.out.println(ModelPrinter.get().print(report.getModel())); } } \ No newline at end of file
7
Significant code clean up
32
.java
java
apache-2.0
TopQuadrant/shacl
48
<NME> dash.ttl <BEF> # baseURI: http://datashapes.org/dash # imports: http://topbraid.org/tosh # imports: http://www.w3.org/ns/shacl# # prefix: dash @prefix dash: <http://datashapes.org/dash#> . @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 tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/dash> a owl:Ontology ; rdfs:comment "DASH is a SHACL library for frequently needed features and design patterns. The constraint components in this library are 100% standards compliant and will work on any engine that fully supports SHACL." ; rdfs:label "DASH Data Shapes Vocabulary" ; owl:imports <http://topbraid.org/tosh> ; owl:imports sh: ; sh:declare [ sh:namespace "http://datashapes.org/dash#"^^xsd:anyURI ; sh:prefix "dash" ; ] ; sh:declare [ sh:namespace "http://purl.org/dc/terms/"^^xsd:anyURI ; sh:prefix "dcterms" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ; sh:prefix "rdf" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2000/01/rdf-schema#"^^xsd:anyURI ; sh:prefix "rdfs" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2001/XMLSchema#"^^xsd:anyURI ; sh:prefix "xsd" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2002/07/owl#"^^xsd:anyURI ; sh:prefix "owl" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ; sh:prefix "skos" ; ] ; . dash:APIStatus a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of possible values for dash:apiStatus." ; rdfs:label "API Status" ; rdfs:subClassOf rdfs:Resource ; . dash:Action a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An executable command triggered by an agent, backed by a Script implementation. Actions may get deactivated using sh:deactivated." ; rdfs:label "Action" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ActionGroup a dash:ShapeClass ; rdfs:comment "A group of ResourceActions, used to arrange items in menus etc. Similar to sh:PropertyGroups, they may have a sh:order and should have labels (in multiple languages if applicable)." ; rdfs:label "Action group" ; rdfs:subClassOf rdfs:Resource ; . dash:ActionTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a dash:Action using provided input parameters. Requires exactly one value for dash:action and will operate on the test case's graph (with imports) as both data and shapes graph. Currently only supports read-only actions, allowing the comparison of actual results with the expected results.""" ; rdfs:label "Action test case" ; rdfs:subClassOf dash:TestCase ; . dash:AllObjects a dash:AllObjectsTarget ; rdfs:comment "A reusable instance of dash:AllObjectsTarget." ; rdfs:label "All objects" ; . dash:AllObjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all objects in the data graph as focus nodes." ; rdfs:label "All objects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allObjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All objects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?anyS ?anyP ?this . }""" ; . dash:AllSubjects a dash:AllSubjectsTarget ; rdfs:comment "A reusable instance of dash:AllSubjectsTarget." ; rdfs:label "All subjects" ; . dash:AllSubjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all subjects in the data graph as focus nodes." ; rdfs:label "All subjects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allSubjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All subjects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this ?anyP ?anyO . }""" ; . dash:AutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An auto-complete field to enter the label of instances of a class. This is the fallback editor for any URI resource if no other editors are more suitable." ; rdfs:label "Auto-complete editor" ; . dash:BlankNodeViewer a dash:SingleViewer ; rdfs:comment "A Viewer for blank nodes, rendering as the label of the blank node." ; rdfs:label "Blank node viewer" ; . dash:BooleanSelectEditor a dash:SingleEditor ; rdfs:comment """An editor for boolean literals, rendering as a select box with values true and false. Also displays the current value (such as \"1\"^^xsd:boolean), but only allows to switch to true or false.""" ; rdfs:label "Boolean select editor" ; . dash:ChangeScript a dash:ShapeClass ; rdfs:comment """Class of ADS scripts that are executed after edits to the data graph were made. These scripts may access the current changes from the graphs with names dataset.addedGraphURI and dataset.deletedGraphURI to learn about which resource values have been added or deleted. For example query them using graph.withDataGraph(dataset.addedGraphURI, ...) or via SPARQL's GRAPH keyword. Change scripts may then perform further changes which would again become visible to other change scripts. Change scripts are executed by their relative sh:order, with a default value of 0. Use lower values to execute before other rules.""" ; rdfs:label "Change script" ; rdfs:subClassOf dash:Script ; . dash:ClosedByTypesConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to declare that focus nodes are \"closed\" based on their rdf:types, meaning that focus nodes may only have values for the properties that are explicitly enumerated via sh:property/sh:path in property constraints at their rdf:types and the superclasses of those. This assumes that the type classes are also shapes." ; rdfs:label "Closed by types constraint component" ; sh:nodeValidator [ a sh:JSValidator ; sh:jsFunctionName "validateClosedByTypesNode" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Property is not among those permitted for any of the types" ; ] ; sh:nodeValidator [ a sh:SPARQLSelectValidator ; sh:message "Property {?path} is not among those permitted for any of the types" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this (?predicate AS ?path) ?value WHERE { FILTER ($closedByTypes) . $this ?predicate ?value . FILTER (?predicate != rdf:type) . FILTER NOT EXISTS { $this rdf:type ?type . ?type rdfs:subClassOf* ?class . GRAPH $shapesGraph { ?class sh:property/sh:path ?predicate . } } }""" ; ] ; sh:parameter dash:ClosedByTypesConstraintComponent-closedByTypes ; . dash:ClosedByTypesConstraintComponent-closedByTypes a sh:Parameter ; sh:path dash:closedByTypes ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to indicate that the focus nodes are closed by their types. A constraint violation is reported for each property value of the focus node where the property is not among those that are explicitly declared via sh:property/sh:path in any of the rdf:types of the focus node (and their superclasses). The property rdf:type is always permitted." ; sh:maxCount 1 ; . dash:CoExistsWithConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that if the property path has any value then the given property must also have a value, and vice versa." ; rdfs:label "Co-exists-with constraint component" ; sh:message "Values must co-exist with values of {$coExistsWith}" ; sh:parameter dash:CoExistsWithConstraintComponent-coExistsWith ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateCoExistsWith" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { { FILTER (EXISTS { $this $PATH ?any } && NOT EXISTS { $this $coExistsWith ?any }) } UNION { FILTER (NOT EXISTS { $this $PATH ?any } && EXISTS { $this $coExistsWith ?any }) } }""" ; ] ; . dash:CoExistsWithConstraintComponent-coExistsWith a sh:Parameter ; sh:path dash:coExistsWith ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "The properties that must co-exist with the surrounding property (path). If the surrounding property path has any value then the given property must also have a value, and vice versa." ; sh:name "co-exists with" ; sh:nodeKind sh:IRI ; . dash:ConstraintReificationShape a sh:NodeShape ; rdfs:comment "Can be used to attach sh:severity and sh:messages to individual constraints using reification." ; rdfs:label "Constraint reification shape" ; sh:property dash:ConstraintReificationShape-message ; sh:property dash:ConstraintReificationShape-severity ; . dash:ConstraintReificationShape-message a sh:PropertyShape ; sh:path sh:message ; dash:singleLine true ; sh:name "messages" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangString ; . dash:ConstraintReificationShape-severity a sh:PropertyShape ; sh:path sh:severity ; sh:class sh:Severity ; sh:maxCount 1 ; sh:name "severity" ; sh:nodeKind sh:IRI ; . dash:Constructor a dash:ShapeClass ; rdfs:comment """A script that is executed when a new instance of the class associated via dash:constructor is created, e.g. from a New button. Such scripts typically declare one or more parameters that are collected from the user when the script starts. The values of these parameters can be used as named variables in the script for arbitrary purposes such as setting the URI or initializing some property values of the new instance. The variable focusNode will hold the named node of the selected type, for example when a constructor is associated with a superclass but the user has pressed New for a subclass. The last expression of the script will be used as result of the constructor, so that the surrounding tool knows which resource shall be navigated to next.""" ; rdfs:label "Constructor" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:DASHJSLibrary a sh:JSLibrary ; rdfs:label "DASH JavaScript library" ; sh:jsLibrary dash:RDFQueryJSLibrary ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected result of a function call." ; sh:maxCount 1 ; sh:name "expected result" ; ] ; sh:property [ sh:path dash:expression ; sh:description "A valid SPARQL expression calling the function to test." ; sh:maxCount 1 ; . dash:DatePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:date literals, offering a calendar-like date picker." ; rdfs:label "Date picker editor" ; . dash:DateTimePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:dateTime literals, offering a calendar-like date picker and a time selector." ; rdfs:label "Date time picker editor" ; . dash:DepictionRole a dash:PropertyRole ; rdfs:comment "Depiction properties provide images representing the focus nodes. Typical examples may be a photo of an animal or the map of a country." ; rdfs:label "Depiction" ; . dash:Deprecated a dash:APIStatus ; rdfs:comment "Features that have been marked deprecated will remain in the API but should no longer be used by new code and may get deleted in the foreseeable future (e.g., with the next major release)." ; rdfs:label "deprecated" ; . dash:DescriptionRole a dash:PropertyRole ; rdfs:comment "Description properties should produce text literals that may be used as an introduction/summary of what a focus node does." ; rdfs:label "Description" ; . dash:DetailsEditor a dash:SingleEditor ; rdfs:comment "An editor for non-literal values, typically displaying a nested form where the values of the linked resource can be edited directly on the \"parent\" form. Implementations that do not support this (yet) could fall back to an auto-complete widget." ; rdfs:label "Details editor" ; . dash:DetailsViewer a dash:SingleViewer ; rdfs:comment "A Viewer for resources that shows the details of the value using its default view shape as a nested form-like display." ; rdfs:label "Details viewer" ; . dash:Editor a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for editing value nodes." ; rdfs:label "Editor" ; rdfs:subClassOf dash:Widget ; . dash:EnumSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for enumerated values (typically based on sh:in lists)." ; rdfs:label "Enum select editor" ; . dash:ExecutionPlatform a rdfs:Class ; rdfs:comment "An platform (such as TopBraid) that may have features needed to execute, for example, SPARQL queries." ; rdfs:label "Execution platform" ; rdfs:subClassOf rdfs:Resource ; . dash:Experimental a dash:APIStatus ; rdfs:comment "Features that are marked experimental can be used by early adopters but there is no guarantee that they will reach stable state." ; rdfs:label "experimental" ; . dash:ExploreAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in an Explore section of a selected resource. Cannot make changes to the data." ; rdfs:label "Explore action" ; rdfs:subClassOf dash:ResourceAction ; . dash:FailureResult a rdfs:Class ; rdfs:comment "A result representing a validation failure such as an unsupported recursion." ; rdfs:label "Failure result" ; rdfs:subClassOf sh:AbstractResult ; . dash:FailureTestCaseResult a rdfs:Class ; rdfs:comment "Represents a failure of a test case." ; rdfs:label "Failure test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:FunctionTestCase a dash:ShapeClass ; rdfs:comment "A test case that verifies that a given SPARQL expression produces a given, expected result." ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphService a dash:ShapeClass ; rdfs:comment "A service that does not apply to a specific resource (as ResourceService does) but operates on the whole graph. The focusNode variable will be the URI of the current base graph (e.g. <urn:x-evn-master:geo> as a NamedNode." ; rdfs:label "Graph service" ; rdfs:subClassOf dash:Service ; . dash:GraphStoreTestCase a dash:ShapeClass ; rdfs:comment "A test case that can be used to verify that an RDF file could be loaded (from a file) and that the resulting RDF graph is equivalent to a given TTL file." ; rdfs:label "Graph store test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphUpdate a rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:label "Graph update" ; rdfs:subClassOf dash:Suggestion ; . dash:GraphValidationTestCase a dash:ShapeClass ; rdfs:comment "A test case that performs SHACL constraint validation on the whole graph and compares the results with the expected validation results stored with the test case. By default this excludes meta-validation (i.e. the validation of the shape definitions themselves). If that's desired, set dash:validateShapes to true." ; rdfs:label "Graph validation test case" ; rdfs:subClassOf dash:ValidationTestCase ; . dash:HTMLOrStringOrLangString a rdf:List ; rdf:first [ rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected inferred triples, represented by instances of rdfs:Statement." ; sh:name "expected result" ; sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either rdf:HTML, xsd:string or rdf:langString (in that order of preference)." ; rdfs:label "HTML or string or langString" ; . dash:HTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML encoded text from rdf:HTML literals, rendering as parsed HTML DOM elements. Also displays the language if the HTML has a lang attribute on its root DOM element." ; rdfs:label "HTML viewer" ; . rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected result of the JavaScript function call, as an RDF node." ; sh:maxCount 1 ; a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . GRAPH $shapesGraph { $hasValueIn rdf:rest*/rdf:first ?value . } } }""" ; ] ; . dash:HasValueInConstraintComponent-hasValueIn a sh:Parameter ; sh:path dash:hasValueIn ; dash:reifiableBy dash:ConstraintReificationShape ; sh:description "At least one of the value nodes must be a member of the given list." ; sh:name "has value in" ; sh:node dash:ListShape ; . dash:HasValueTarget a sh:SPARQLTargetType ; rdfs:comment "A target type for all subjects where a given predicate has a certain object value." ; rdfs:label "Has Value target" ; rdfs:subClassOf sh:Target ; sh:labelTemplate "All subjects where {$predicate} has value {$object}" ; sh:parameter [ a sh:Parameter ; sh:path dash:object ; sh:description "The value that is expected to be present." ; sh:name "object" ; ] ; sh:parameter [ a sh:Parameter ; sh:path dash:predicate ; sh:description "The predicate property." ; sh:name "predicate" ; sh:nodeKind sh:IRI ; ] ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this $predicate $object . }""" ; . dash:HasValueWithClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be an instance of a given class." ; rdfs:label "Has value with class constraint component" ; sh:message "At least one of the values must be an instance of class {$hasValueWithClass}" ; sh:parameter dash:HasValueWithClassConstraintComponent-hasValueWithClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateHasValueWithClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . ?value a ?type . ?type rdfs:subClassOf* $hasValueWithClass . } }""" ; ] ; . dash:HasValueWithClassConstraintComponent-hasValueWithClass a sh:Parameter ; sh:path dash:hasValueWithClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "One of the values of the property path must be an instance of the given class." ; sh:name "has value with class" ; sh:nodeKind sh:IRI ; . dash:HyperlinkViewer a dash:SingleViewer ; rdfs:comment """A Viewer for literals, rendering as a hyperlink to a URL. For literals it assumes the lexical form is the URL. This is often used as default viewer for xsd:anyURI literals. Unsupported for blank nodes.""" ; rdfs:label "Hyperlink viewer" ; . dash:IDRole a dash:PropertyRole ; rdfs:comment "ID properties are short strings or other literals that identify the focus node among siblings. Examples may include social security numbers." ; rdfs:label "ID" ; . dash:IconRole a dash:PropertyRole ; rdfs:comment """Icon properties produce images that are typically small and almost square-shaped, and that may be displayed in the upper left corner of a focus node's display. Values should be xsd:string or xsd:anyURI literals or IRI nodes pointing at URLs. Those URLs should ideally be vector graphics such as .svg files. Instances of the same class often have the same icon, and this icon may be computed using a sh:values rule or as sh:defaultValue. If the value is a relative URL then those should be resolved against the server that delivered the surrounding page.""" ; rdfs:label "Icon" ; . dash:ImageViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI values that are recognized as images by a browser, rendering as an image." ; rdfs:label "Image viewer" ; . dash:IncludedScript a dash:ShapeClass ; rdfs:comment """The code associated with instances of this class will get injected into the generated APIs, as global code snippets. Typically used to declare libraries of utility functions or constants that are (compared to shape scripts) not necessarily associated with specific classes or shapes. Note that the JavaScript code stored in dash:js cannot use the export keyword because the code must also work in external scripts (such as on Node.js). Instead, you need to enumerate the exported symbols via dash:exports.""" ; rdfs:label "Included script" ; rdfs:subClassOf dash:Script ; sh:property tosh:IncludedScript-exports ; . dash:IndexedConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to mark property shapes to be indexed, meaning that each of its value nodes must carry a dash:index from 0 to N." ; rdfs:label "Indexed constraint component" ; sh:parameter dash:IndexedConstraintComponent-indexed ; . dash:IndexedConstraintComponent-indexed a sh:Parameter ; sh:path dash:indexed ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to activate indexing for this property." ; sh:maxCount 1 ; sh:name "indexed" ; . dash:InferencingTestCase a dash:ShapeClass ; rdfs:comment "A test case to verify whether an inferencing engine is producing identical results to those stored as expected results." ; rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; . dash:InlineViewer a dash:MultiViewer ; rdfs:comment "A multi-viewer that renders all values horizontally, in a more compact form that just a single value per row." ; rdfs:label "Inline viewer" ; . dash:InstancesSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of the target class (based on sh:class of the property)." ; rdfs:label "Instances select editor" ; . dash:JSONTableViewer a dash:SingleViewer ; rdfs:comment """A tabular viewer for rdf:JSON literals with a lexical form in the following format: { vars: [ 'col1', 'col2' ], // These are the column keys headerLabels: [ 'Column 1', 'Column 2' ], // Optional, for the column headers bindings: [ // These become the rows { col1: { lex: 'Value2', datatype: '...#string', }, col2: { uri: 'http://.../Instance', label: 'Example Instance', }, }, ... ], } The resulting table will use the headerLabels (if they exist) as column headers, otherwise derive the headers from the variable names. The vars must match the fields in the bindings. The table will contain one row for each binding. Using Active Data Shapes, you can construct such literals dynamically using a sh:values rule, e.g. ex:MyClass-myProperty a sh:PropertyShape ; sh:path ex:myProperty ; sh:values [ dash:js \"\"\" DataViewers.createTableViewerJSON(focusNode.select(` SELECT ?col1 ?col2 WHERE { $this ex:prop1 ?col1 . $this ex:prop2 ?col2 . } `))\"\"\" ] . rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:SPARQLSelectExecutable ; sh:property [ sh:path dash:expectedResult ; sh:datatype xsd:string ; sh:description "The expected result set, as a JSON string." ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; sh:name "expected result" ; ] ; sh:property [ sh:path sh:select ; sh:datatype xsd:string ; sh:description "The SPARQL SELECT query to execute." ; a dash:PropertyRole ; rdfs:comment "Properties with this role produce strings that may serve as display label for the focus nodes. Labels should be either plain string literals or strings with a language tag. The values should also be single-line." ; rdfs:label "Label" ; . dash:LabelViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI based on the display label of the resource. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "rdfQuery JavaScript Library" ; sh:jsLibraryURL "http://datashapes.org/js/rdfquery.js"^^xsd:anyURI ; . dash:RichTextEditor a dash:Editor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 0 ; ] ; ] [ sh:not [ sh:hasValue () ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $subject, $predicate and $object, as well as the other pre-bound variables for the parameters of the constraint. sh:oneOrMorePath rdf:rest ; ] ; dash:nonRecursive true ; ] ; ] ) ; sh:property [ a sh:PropertyShape ; sh:path [ sh:zeroOrMorePath rdf:rest ; ] ; rdfs:comment "Each list member (including this node) must be have the shape dash:ListNodeShape." ; sh:node dash:ListNodeShape ; ] ; . dash:LiteralViewer a dash:SingleViewer ; rdfs:comment "A simple viewer for literals, rendering the lexical form of the value." ; rdfs:label "Literal viewer" ; . dash:ModifyAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in a Modify section of a selected resource. May make changes to the data." ; rdfs:label "Modify action" ; rdfs:subClassOf dash:ResourceAction ; . dash:MultiEditor a dash:ShapeClass ; rdfs:comment "An editor for multiple/all value nodes at once." ; rdfs:label "Multi editor" ; rdfs:subClassOf dash:Editor ; . dash:MultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """A multi-function is a function that can return zero or more result objects consisting of one or more result variables. While normal (SPARQL/SHACL) functions can only return a single result node, multi-functions may not only return multiple nodes but even multiple individual variables per solution. A common way of defining multi-functions is by wrapping a SPARQL SELECT query, using dash:SPARQLMultiFunction. However, some MultiFunctions (in TopBraid) may also be implemented natively.""" ; rdfs:label "Multi-function" ; rdfs:subClassOf sh:Parameterizable ; sh:nodeKind sh:IRI ; . dash:MultiViewer a dash:ShapeClass ; rdfs:comment "A viewer for multiple/all values at once." ; rdfs:label "Multi viewer" ; rdfs:subClassOf dash:Viewer ; . dash:NoSuitableEditor a dash:SingleEditor ; rdfs:comment "An \"editor\" that simply informs the user that the values cannot be edited here, but for example through source code editing." ; rdfs:label "No suitable editor" ; . dash:NodeExpressionViewer a dash:SingleViewer ; rdfs:comment "A viewer for SHACL Node Expressions."^^rdf:HTML ; rdfs:label "Node expression viewer" ; . dash:NonRecursiveConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Used to state that a property or path must not point back to itself." ; rdfs:label "Non-recursive constraint component" ; sh:message "Points back at itself (recursively)" ; sh:parameter dash:NonRecursiveConstraintComponent-nonRecursive ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateNonRecursiveProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ($this AS ?value) WHERE { { FILTER (?nonRecursive) } $this $PATH $this . }""" ; ] ; . dash:NonRecursiveConstraintComponent-nonRecursive a sh:Parameter ; sh:path dash:nonRecursive ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description """Used to state that a property or path must not point back to itself. For example, \"a person cannot have itself as parent\" can be expressed by setting dash:nonRecursive=true for a given sh:path. To express that a person cannot have itself among any of its (recursive) parents, use a sh:path with the + operator such as ex:parent+.""" ; sh:maxCount 1 ; sh:name "non-recursive" ; . dash:None a sh:NodeShape ; rdfs:comment "A Shape that is no node can conform to." ; rdfs:label "None" ; sh:in () ; . dash:ParameterConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to verify that all value nodes conform to the given Parameter."@en ; rdfs:label "Parameter constraint component"@en ; sh:parameter dash:ParameterConstraintComponent-parameter ; . dash:ParameterConstraintComponent-parameter a sh:Parameter ; sh:path sh:parameter ; . dash:PrimaryKeyConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "Enforces a constraint that the given property (sh:path) serves as primary key for all resources in the target of the shape. If a property has been declared to be the primary key then each resource must have exactly one value for that property. Furthermore, the URIs of those resources must start with a given string (dash:uriStart), followed by the URL-encoded primary key value. For example if dash:uriStart is \"http://example.org/country-\" and the primary key for an instance is \"de\" then the URI must be \"http://example.org/country-de\". Finally, as a result of the URI policy, there can not be any other resource with the same value under the same primary key policy." ; rdfs:label "Primary key constraint component" ; sh:labelTemplate "The property {?predicate} is the primary key and URIs start with {?uriStart}" ; sh:message "Violation of primary key constraint" ; sh:parameter dash:PrimaryKeyConstraintComponent-uriStart ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validatePrimaryKeyProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this WHERE { FILTER ( # Must have a value for the primary key NOT EXISTS { ?this $PATH ?any } || # Must have no more than one value for the primary key EXISTS { ?this $PATH ?value1 . ?this $PATH ?value2 . FILTER (?value1 != ?value2) . } || # The value of the primary key must align with the derived URI EXISTS { { ?this $PATH ?value . FILTER NOT EXISTS { ?this $PATH ?value2 . FILTER (?value != ?value2) } } BIND (CONCAT($uriStart, ENCODE_FOR_URI(str(?value))) AS ?uri) . FILTER (str(?this) != ?uri) . } ) }""" ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart a sh:Parameter ; sh:path dash:uriStart ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "The start of the URIs of well-formed resources. If specified then the associated property/path serves as \"primary key\" for all target nodes (instances). All such target nodes need to have a URI that starts with the given string, followed by the URI-encoded value of the primary key property." ; sh:maxCount 1 ; sh:name "URI start" ; . rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; rdfs:comment "The class of roles that a property (shape) may take for its focus nodes." ; rdfs:label "Property role" ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; sh:property [ sh:path dash:testCase ; sh:class dash:TestCase ; sh:description "The dash:TestCase that was executed." ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . sh:name "test case" ; ] ; sh:property [ sh:path dash:testGraph ; sh:class rdfs:Resource ; sh:description "The graph containing the test case." ; rdfs:label "Reifiable-by constraint component" ; sh:labelTemplate "Reifiable by {$reifiableBy}" ; sh:parameter dash:ReifiableByConstraintComponent-reifiableBy ; . dash:ReifiableByConstraintComponent-reifiableBy a sh:Parameter ; sh:path dash:reifiableBy ; sh:class sh:NodeShape ; sh:description "Can be used to specify the node shape that may be applied to reified statements produced by a property shape. The property shape must have a URI resource as its sh:path. The values of this property must be node shapes. User interfaces can use this information to determine which properties to present to users when reified statements are explored or edited. Also, SHACL validators can use it to determine how to validate reified triples. Use dash:None to indicate that no reification should be permitted." ; sh:maxCount 1 ; sh:name "reifiable by" ; sh:nodeKind sh:IRI ; . dash:ResourceAction a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An Action that can be executed for a selected resource. Such Actions show up in context menus once they have been assigned a sh:group." ; rdfs:label "Resource action" ; rdfs:subClassOf dash:Action ; . dash:ResourceService a dash:ShapeClass ; rdfs:comment "A Service that can (and must) be applied to a given resource as focus node. Use dash:resourceService to link a class to the services that apply to its instances." ; rdfs:label "Resource service" ; rdfs:subClassOf dash:Service ; . dash:RichTextEditor a dash:SingleEditor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; rdfs:label "Rich text editor" ; . dash:RootClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component defining the parameter dash:rootClass, which restricts the values to be either the root class itself or one of its subclasses. This is typically used in conjunction with properties that have rdfs:Class as their type." ; rdfs:label "Root class constraint component" ; sh:labelTemplate "Root class {$rootClass}" ; sh:message "Value must be subclass of {$rootClass}" ; sh:parameter dash:RootClassConstraintComponent-rootClass ; sh:validator dash:hasRootClass ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateRootClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:RootClassConstraintComponent-rootClass a sh:Parameter ; sh:path dash:rootClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "The root class." ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLConstructTemplate a rdfs:Class ; rdfs:comment "Encapsulates one or more SPARQL CONSTRUCT queries that can be parameterized. Parameters will become pre-bound variables in the queries." ; rdfs:label "SPARQL CONSTRUCT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLConstructExecutable ; . dash:SPARQLMultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment "A multi-function based on a SPARQL SELECT query. The query gets executed with the arguments pre-bound to the variables declared as parameters. The results of the multi-function are all result bindings from the SPARQL result set." ; rdfs:label "SPARQL multi-function" ; rdfs:subClassOf dash:MultiFunction ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLSelectTemplate a rdfs:Class ; rdfs:comment "Encapsulates a SPARQL SELECT query that can be parameterized. Parameters will become pre-bound variables in the query." ; rdfs:label "SPARQL SELECT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $focusNode, $predicate and $value, as well as the other pre-bound variables for the parameters of the constraint. In many cases, there may be multiple possible suggestions to fix a problem. For example, with sh:maxLength there are many ways to slice a string. In those cases, the system will first iterate through the result variables from a SELECT query (sh:select) and apply these results as pre-bound variables into the UPDATE query.""" ; rdfs:label "SPARQL UPDATE suggestion generator" ; rdfs:subClassOf dash:SuggestionGenerator ; rdfs:subClassOf sh:SPARQLSelectExecutable ; rdfs:subClassOf sh:SPARQLUpdateExecutable ; . rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:class sh:ValidationReport ; sh:description "The expected validation report." ; a sh:PropertyGroup ; rdfs:label "Script API Generation Rules" ; . dash:ScriptAPIShape a sh:NodeShape ; rdfs:comment "Defines the properties that instruct the ADS Script API generator about what prefixes, constants and classes to generate." ; rdfs:label "Script API" ; sh:property dash:ScriptAPIShape-generateClass ; sh:property dash:ScriptAPIShape-generatePrefixClasses ; sh:property dash:ScriptAPIShape-generatePrefixConstants ; sh:targetClass owl:Ontology ; . dash:ScriptAPIShape-generateClass a sh:PropertyShape ; sh:path dash:generateClass ; sh:class sh:NodeShape ; sh:description "The API generator will produce classes for each value of this property and all its subclasses and superclasses." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate class" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixClasses a sh:PropertyShape ; sh:path dash:generatePrefixClasses ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce classes for all RDFS classes or node shapes from the associated namespace." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix classes" ; sh:order "15"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixConstants a sh:PropertyShape ; sh:path dash:generatePrefixConstants ; sh:datatype xsd:string ; rdfs:range rdf:Statement ; . dash:all rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . rdfs:comment """The class of constraints that are based on Scripts. Depending on whether dash:onAllValues is set to true, these scripts can access the following pre-assigned variables: - focusNode: the focus node of the constraint (a NamedNode) - if dash:onAllValues is not true: value: the current value node (e.g. a JavaScript string for xsd:string literals, a number for numeric literals or true or false for xsd:boolean literals. All other literals become LiteralNodes, and non-literals become instances of NamedNode) - if dash:onAllValues is true: values: an array of current value nodes, as above. If the expression returns an array then each array member will be mapped to one validation result, following the mapping rules below. For string results, a validation result will use the string as sh:resultMessage. For boolean results, a validation result will be produced if the result is false (true means no violation). For object results, a validation result will be produced using the value of the field \"message\" of the object as result message. If the field \"value\" has a value then this will become the sh:value in the violation. Unless another sh:message has been directly returned, the sh:message of the dash:ScriptConstraint will be used, similar to sh:message at SPARQL Constraints. These sh:messages can access the values {$focusNode}, {$value} etc as template variables.""" ; rdfs:label "Script constraint" ; rdfs:subClassOf dash:Script ; . dash:ScriptConstraintComponent a sh:ConstraintComponent ; rdfs:label "Script constraint component" ; sh:parameter dash:ScriptConstraintComponent-scriptConstraint ; . dash:ScriptConstraintComponent-scriptConstraint a sh:Parameter ; sh:path dash:scriptConstraint ; sh:class dash:ScriptConstraint ; sh:description "The Script constraint(s) to apply." ; sh:name "script constraint" ; . dash:ScriptFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """Script functions can be used from SPARQL queries and will be injected into the generated prefix object (in JavaScript, for ADS scripts). The dash:js will be inserted into a generated JavaScript function and therefore needs to use the return keyword to produce results. These JS snippets can access the parameter values based on the local name of the sh:Parameter's path. For example ex:value can be accessed using value. SPARQL use note: Since these functions may be used from any data graph and any shapes graph, they must not rely on any API apart from what's available in the shapes graph that holds the rdf:type triple of the function itself. In other words, at execution time from SPARQL, the ADS shapes graph will be the home graph of the function's declaration.""" ; rdfs:label "Script function" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Function ; . dash:ScriptSuggestionGenerator a dash:ShapeClass ; rdfs:comment """A Suggestion Generator that is backed by an Active Data Shapes script. The script needs to return a JSON object or an array of JSON objects if it shall generate multiple suggestions. It may also return null to indicate that nothing was suggested. Note that the whole script is evaluated as a (JavaScript) expression, and those will use the last value as result. So simply putting an object at the end of your script should do. Alternatively, define the bulk of the operation as a function and simply call that function in the script. Each response object can have the following fields: { message: \"The human readable message\", // Defaults to the rdfs:label(s) of the suggestion generator add: [ // An array of triples to add, each triple as an array with three nodes [ subject, predicate, object ], [ ... ] ], delete: [ ... like add, for the triples to delete ] } Suggestions with neither added nor deleted triples will be discarded. At execution time, the script operates on the data graph as the active graph, with the following pre-bound variables: - focusNode: the NamedNode that is the sh:focusNode of the validation result - predicate: the NamedNode representing the predicate of the validation result, assuming sh:resultPath is a URI - value: the value node from the validation result's sh:value, cast into the most suitable JS object - the other pre-bound variables for the parameters of the constraint, e.g. in a sh:maxCount constraint it would be maxCount The script will be executed in read-only mode, i.e. it cannot modify the graph. Example with dash:js: ({ message: `Copy labels into ${graph.localName(predicate)}`, add: focusNode.values(rdfs.label).map(label => [ focusNode, predicate, label ] ) })""" ; rdfs:label "Script suggestion generator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:SuggestionGenerator ; . dash:ScriptTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a script. Requires exactly one value for dash:js and will operate on the test case's graph (with imports) as both data and shapes graph. Supports read-only scripts only at this stage.""" ; rdfs:label "Script test case" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:TestCase ; . dash:ScriptValidator a dash:ShapeClass ; rdfs:comment """A SHACL validator based on an Active Data Shapes script. See the comment at dash:ScriptConstraint for the basic evaluation approach. Note that in addition to focusNode and value/values, the script can access pre-bound variables for each declared argument of the constraint component.""" ; rdfs:label "Script validator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Validator ; . dash:Service a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A script that gets exposed as a web service, e.g. /tbl/service/ex/MyService" ; rdfs:label "Service" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ShapeClass a dash:ShapeClass ; dash:hidden true ; rdfs:comment "A class that is also a node shape. This class can be used as rdf:type instead of the combination of rdfs:Class and sh:NodeShape." ; rdfs:label "Shape class" ; rdfs:subClassOf rdfs:Class ; rdfs:subClassOf sh:NodeShape ; . dash:ShapeScript a rdfs:Class ; rdfs:comment "A shape script contains extra code that gets injected into the API for the associated node shape. In particular you can use this to define additional functions that operate on the current focus node (the this variable in JavaScript)." ; rdfs:label "Shape script" ; rdfs:subClassOf dash:Script ; . dash:SingleEditor a dash:ShapeClass ; rdfs:comment "An editor for individual value nodes." ; rdfs:label "Single editor" ; rdfs:subClassOf dash:Editor ; . dash:SingleLineConstraintComponent a sh:ConstraintComponent ; rdfs:comment """A constraint component that can be used to declare that all values that are literals must have a lexical form that contains no line breaks ('\\n' or '\\r'). User interfaces may use the dash:singleLine flag to prefer a text field over a (multi-line) text area.""" ; rdfs:label "Single line constraint component" ; sh:message "Must not contain line breaks." ; sh:parameter dash:SingleLineConstraintComponent-singleLine ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSingleLine" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { FILTER (!$singleLine || !isLiteral($value) || (!contains(str($value), '\\n') && !contains(str($value), '\\r'))) }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; . dash:SingleLineConstraintComponent-singleLine a sh:Parameter ; sh:path dash:singleLine ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to state that the lexical form of literal value nodes must not contain any line breaks. False to state that line breaks are explicitly permitted." ; sh:group tosh:StringConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "single line" ; sh:order "30"^^xsd:decimal ; . dash:SingleViewer a dash:ShapeClass ; rdfs:comment "A viewer for a single value." ; rdfs:label "Single viewer" ; rdfs:subClassOf dash:Viewer ; . dash:Stable a dash:APIStatus ; rdfs:comment "Features that have been marked stable are deemed of good quality and can be used until marked deprecated." ; rdfs:label "stable" ; . dash:StemConstraintComponent a sh:ConstraintComponent ; dash:staticConstraint true ; rdfs:comment "A constraint component that can be used to verify that every value node is an IRI and the IRI starts with a given string value."@en ; rdfs:label "Stem constraint component"@en ; sh:labelTemplate "Value needs to have stem {$stem}" ; sh:message "Value does not have stem {$stem}" ; sh:parameter dash:StemConstraintComponent-stem ; sh:validator dash:hasStem ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateStem" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:StemConstraintComponent-stem a sh:Parameter ; sh:path dash:stem ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "If specified then every value node must be an IRI and the IRI must start with the given string value." ; sh:maxCount 1 ; sh:name "stem" ; . dash:StringOrLangString a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string or rdf:langString." ; rdfs:label "String or langString" ; . dash:StringOrLangStringOrHTML a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] [ rdfs:label "height" ; rdfs:range xsd:integer ; . dash:includedExecutionPlatform a rdf:Property ; rdfs:comment "Can be used to state that one (subject) execution platform includes all features of another platform (object)." ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to state that the set of value nodes must be a subset of the value of a given property." ; rdfs:label "Sub set of constraint component" ; sh:message "Must be one of the values of {$subSetOf}" ; sh:parameter dash:SubSetOfConstraintComponent-subSetOf ; sh:propertyValidator [ a sh:SPARQLAskValidator ; sh:ask """ASK { $this $subSetOf $value . }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSubSetOf" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:SubSetOfConstraintComponent-subSetOf a sh:Parameter ; sh:path dash:subSetOf ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "Can be used to state that all value nodes must also be values of a specified other property at the same focus node." ; sh:name "sub-set of" ; sh:nodeKind sh:IRI ; . dash:SuccessResult a rdfs:Class ; rdfs:comment "A result representing a successfully validated constraint." ; rdfs:label "Success result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SuccessTestCaseResult a rdfs:Class ; rdfs:comment "Represents a successful run of a test case." ; rdfs:label "Success test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:Suggestion a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of suggestions that modify a graph to \"fix\" the source of a validation result." ; rdfs:label "Suggestion" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionGenerator a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of objects that can generate suggestions (added or deleted triples) for a validation result of a given constraint component." ; rdfs:label "Suggestion generator" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionResult a rdfs:Class ; rdfs:comment "Class of results that have been produced as suggestions, not through SHACL validation. How the actual results are produced is up to implementers. Each instance of this class should have values for sh:focusNode, sh:resultMessage, sh:resultSeverity (suggested default: sh:Info), and dash:suggestion to point at one or more suggestions." ; rdfs:label "Suggestion result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SymmetricConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A contraint component for property shapes to validate that a property is symmetric. For symmetric properties, if A relates to B then B must relate to A." ; rdfs:label "Symmetric constraint component" ; sh:message "Symmetric value expected" ; sh:parameter dash:SymmetricConstraintComponent-symmetric ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateSymmetric" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this ?value { FILTER ($symmetric) . $this $PATH ?value . FILTER NOT EXISTS { ?value $PATH $this . } }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric a sh:Parameter ; sh:path dash:symmetric ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "If set to true then if A relates to B then B must relate to A." ; sh:maxCount 1 ; sh:name "symmetric" ; . dash:TestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class for results produced by running test cases." ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; . dash:TestEnvironment a rdfs:Class ; dash:abstract true ; rdfs:comment "Abstract base class for test environments, holding information on how to set up a test case." ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:TextAreaEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal." ; rdfs:label "Text area editor" ; . dash:readOnly a rdf:Property ; rdfs:comment "Used as a hint for user interfaces that values of the associated property should not be editable." ; rdfs:domain sh:PropertyShape ; rdfs:label "read only" ; rdfs:range xsd:boolean ; . dash:requiredExecutionPlatform a rdf:Property ; rdfs:label "Text field with lang editor" ; . dash:URIEditor a dash:SingleEditor ; rdfs:comment "An input field to enter the URI of a resource, e.g. rdfs:seeAlso links or images." ; rdfs:label "URI editor" ; . dash:URIViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "URI viewer" ; . dash:UniqueValueForClassConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment "A constraint component that can be used to state that the values of a property must be unique for all instances of a given class (and its subclasses)." ; rdfs:label "Unique value for class constraint component" ; sh:labelTemplate "Values must be unique among all instances of {?uniqueValueForClass}" ; sh:parameter dash:UniqueValueForClassConstraintComponent-uniqueValueForClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateUniqueValueForClass" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Value {?value} must be unique but is also used by {?other}" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Value {?value} must be unique but is also used by {?other}" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ?value ?other WHERE { { $this $PATH ?value . ?other $PATH ?value . FILTER (?other != $this) . } ?other a ?type . ?type rdfs:subClassOf* $uniqueValueForClass . }""" ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass a sh:Parameter ; sh:path dash:uniqueValueForClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "States that the values of the property must be unique for all instances of a given class (and its subclasses)." ; sh:name "unique value for class" ; sh:nodeKind sh:IRI ; . dash:UntrustedHTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML content from untrusted sources. This viewer will sanitize the HTML before rendering. Any a, button, checkbox, form, hidden, input, img, script, select, style and textarea tags and class and style attributes will be removed." ; rdfs:label "Untrusted HTML viewer" ; . dash:ValidationTestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Abstract superclass for test cases concerning SHACL constraint validation. Future versions may add new kinds of validatin test cases, e.g. to validate a single resource only." ; rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; . dash:ValueTableViewer a dash:MultiViewer ; rdfs:comment "A viewer that renders all values of a given property as a table, with one value per row, and the columns defined by the shape that is the sh:node or sh:class of the property." ; rdfs:label "Value table viewer" ; . dash:Viewer a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for viewing value nodes." ; rdfs:label "Viewer" ; rdfs:subClassOf dash:Widget ; . dash:Widget a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Base class of user interface components that can be used to display or edit value nodes." ; rdfs:label "Widget" ; rdfs:subClassOf rdfs:Resource ; . dash:abstract a rdf:Property ; rdfs:comment "Indicates that a class is \"abstract\" and cannot be used in asserted rdf:type triples. Only non-abstract subclasses of abstract classes should be instantiated directly." ; rdfs:domain rdfs:Class ; rdfs:label "abstract" ; rdfs:range xsd:boolean ; . dash:actionGroup a rdf:Property ; rdfs:comment "Links an Action with the ActionGroup that it should be arranged in." ; rdfs:domain dash:Action ; rdfs:label "action group" ; rdfs:range dash:ActionGroup ; . dash:actionIconClass a rdf:Property ; rdfs:comment "The (CSS) class of an Action for display purposes alongside the label." ; rdfs:domain dash:Action ; rdfs:label "action icon class" ; rdfs:range xsd:string ; . dash:addedTriple a rdf:Property ; rdfs:comment "May link a dash:GraphUpdate with one or more triples (represented as instances of rdf:Statement) that should be added to fix the source of the result." ; rdfs:domain dash:GraphUpdate ; rdfs:label "added triple" ; rdfs:range rdf:Statement ; . dash:all a rdfs:Resource ; rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . dash:apiStatus a rdf:Property ; rdfs:comment "Defines how and whether the associated feature is part of an external API. APIs may be implemented as (REST) web services, via GraphQL or ADS Script APIs." ; rdfs:label "API status" ; rdfs:range dash:APIStatus ; . dash:applicableToClass a rdf:Property ; rdfs:comment "Can be used to state that a shape is applicable to instances of a given class. This is a softer statement than \"target class\": a target means that all instances of the class must conform to the shape. Being applicable to simply means that the shape may apply to (some) instances of the class. This information can be used by algorithms or humans." ; rdfs:domain sh:Shape ; rdfs:label "applicable to class" ; rdfs:range rdfs:Class ; . dash:cachable a rdf:Property ; rdfs:comment "If set to true then the results of the SHACL function can be cached in between invocations with the same arguments. In other words, they are stateless and do not depend on triples in any graph, or the current time stamp etc." ; rdfs:domain sh:Function ; rdfs:label "cachable" ; rdfs:range xsd:boolean ; . dash:closedByTypes a rdf:Property ; rdfs:label "closed by types" ; . dash:coExistsWith a rdf:Property ; rdfs:comment "Specifies a property that must have a value whenever the property path has a value, and must have no value whenever the property path has no value." ; rdfs:label "co-exists with" ; rdfs:range rdf:Property ; . dash:composite a rdf:Property ; rdfs:comment "Can be used to indicate that a property/path represented by a property constraint represents a composite relationship. In a composite relationship, the life cycle of a \"child\" object (value of the property/path) depends on the \"parent\" object (focus node). If the parent gets deleted, then the child objects should be deleted, too. Tools may use dash:composite (if set to true) to implement cascading delete operations." ; rdfs:domain sh:PropertyShape ; rdfs:label "composite" ; rdfs:range xsd:boolean ; . dash:defaultLang a rdf:Property ; rdfs:comment "Can be used to annotate a graph (usually the owl:Ontology) with the default language that tools should suggest for new literal values. For example, predominantly English graphs should have \"en\" as default language." ; rdfs:domain owl:Ontology ; rdfs:label "default language" ; rdfs:range xsd:string ; . dash:defaultViewForRole a rdf:Property ; rdfs:comment "Links a node shape with the roles
60
Added support for DASH templates - http://datashapes.org/templates.html Also: Catching up with latest TopBraid changes.
5
.ttl
ttl
apache-2.0
TopQuadrant/shacl
49
<NME> dash.ttl <BEF> # baseURI: http://datashapes.org/dash # imports: http://topbraid.org/tosh # imports: http://www.w3.org/ns/shacl# # prefix: dash @prefix dash: <http://datashapes.org/dash#> . @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 tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/dash> a owl:Ontology ; rdfs:comment "DASH is a SHACL library for frequently needed features and design patterns. The constraint components in this library are 100% standards compliant and will work on any engine that fully supports SHACL." ; rdfs:label "DASH Data Shapes Vocabulary" ; owl:imports <http://topbraid.org/tosh> ; owl:imports sh: ; sh:declare [ sh:namespace "http://datashapes.org/dash#"^^xsd:anyURI ; sh:prefix "dash" ; ] ; sh:declare [ sh:namespace "http://purl.org/dc/terms/"^^xsd:anyURI ; sh:prefix "dcterms" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ; sh:prefix "rdf" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2000/01/rdf-schema#"^^xsd:anyURI ; sh:prefix "rdfs" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2001/XMLSchema#"^^xsd:anyURI ; sh:prefix "xsd" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2002/07/owl#"^^xsd:anyURI ; sh:prefix "owl" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ; sh:prefix "skos" ; ] ; . dash:APIStatus a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of possible values for dash:apiStatus." ; rdfs:label "API Status" ; rdfs:subClassOf rdfs:Resource ; . dash:Action a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An executable command triggered by an agent, backed by a Script implementation. Actions may get deactivated using sh:deactivated." ; rdfs:label "Action" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ActionGroup a dash:ShapeClass ; rdfs:comment "A group of ResourceActions, used to arrange items in menus etc. Similar to sh:PropertyGroups, they may have a sh:order and should have labels (in multiple languages if applicable)." ; rdfs:label "Action group" ; rdfs:subClassOf rdfs:Resource ; . dash:ActionTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a dash:Action using provided input parameters. Requires exactly one value for dash:action and will operate on the test case's graph (with imports) as both data and shapes graph. Currently only supports read-only actions, allowing the comparison of actual results with the expected results.""" ; rdfs:label "Action test case" ; rdfs:subClassOf dash:TestCase ; . dash:AllObjects a dash:AllObjectsTarget ; rdfs:comment "A reusable instance of dash:AllObjectsTarget." ; rdfs:label "All objects" ; . dash:AllObjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all objects in the data graph as focus nodes." ; rdfs:label "All objects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allObjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All objects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?anyS ?anyP ?this . }""" ; . dash:AllSubjects a dash:AllSubjectsTarget ; rdfs:comment "A reusable instance of dash:AllSubjectsTarget." ; rdfs:label "All subjects" ; . dash:AllSubjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all subjects in the data graph as focus nodes." ; rdfs:label "All subjects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allSubjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All subjects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this ?anyP ?anyO . }""" ; . dash:AutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An auto-complete field to enter the label of instances of a class. This is the fallback editor for any URI resource if no other editors are more suitable." ; rdfs:label "Auto-complete editor" ; . dash:BlankNodeViewer a dash:SingleViewer ; rdfs:comment "A Viewer for blank nodes, rendering as the label of the blank node." ; rdfs:label "Blank node viewer" ; . dash:BooleanSelectEditor a dash:SingleEditor ; rdfs:comment """An editor for boolean literals, rendering as a select box with values true and false. Also displays the current value (such as \"1\"^^xsd:boolean), but only allows to switch to true or false.""" ; rdfs:label "Boolean select editor" ; . dash:ChangeScript a dash:ShapeClass ; rdfs:comment """Class of ADS scripts that are executed after edits to the data graph were made. These scripts may access the current changes from the graphs with names dataset.addedGraphURI and dataset.deletedGraphURI to learn about which resource values have been added or deleted. For example query them using graph.withDataGraph(dataset.addedGraphURI, ...) or via SPARQL's GRAPH keyword. Change scripts may then perform further changes which would again become visible to other change scripts. Change scripts are executed by their relative sh:order, with a default value of 0. Use lower values to execute before other rules.""" ; rdfs:label "Change script" ; rdfs:subClassOf dash:Script ; . dash:ClosedByTypesConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to declare that focus nodes are \"closed\" based on their rdf:types, meaning that focus nodes may only have values for the properties that are explicitly enumerated via sh:property/sh:path in property constraints at their rdf:types and the superclasses of those. This assumes that the type classes are also shapes." ; rdfs:label "Closed by types constraint component" ; sh:nodeValidator [ a sh:JSValidator ; sh:jsFunctionName "validateClosedByTypesNode" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Property is not among those permitted for any of the types" ; ] ; sh:nodeValidator [ a sh:SPARQLSelectValidator ; sh:message "Property {?path} is not among those permitted for any of the types" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this (?predicate AS ?path) ?value WHERE { FILTER ($closedByTypes) . $this ?predicate ?value . FILTER (?predicate != rdf:type) . FILTER NOT EXISTS { $this rdf:type ?type . ?type rdfs:subClassOf* ?class . GRAPH $shapesGraph { ?class sh:property/sh:path ?predicate . } } }""" ; ] ; sh:parameter dash:ClosedByTypesConstraintComponent-closedByTypes ; . dash:ClosedByTypesConstraintComponent-closedByTypes a sh:Parameter ; sh:path dash:closedByTypes ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to indicate that the focus nodes are closed by their types. A constraint violation is reported for each property value of the focus node where the property is not among those that are explicitly declared via sh:property/sh:path in any of the rdf:types of the focus node (and their superclasses). The property rdf:type is always permitted." ; sh:maxCount 1 ; . dash:CoExistsWithConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that if the property path has any value then the given property must also have a value, and vice versa." ; rdfs:label "Co-exists-with constraint component" ; sh:message "Values must co-exist with values of {$coExistsWith}" ; sh:parameter dash:CoExistsWithConstraintComponent-coExistsWith ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateCoExistsWith" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { { FILTER (EXISTS { $this $PATH ?any } && NOT EXISTS { $this $coExistsWith ?any }) } UNION { FILTER (NOT EXISTS { $this $PATH ?any } && EXISTS { $this $coExistsWith ?any }) } }""" ; ] ; . dash:CoExistsWithConstraintComponent-coExistsWith a sh:Parameter ; sh:path dash:coExistsWith ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "The properties that must co-exist with the surrounding property (path). If the surrounding property path has any value then the given property must also have a value, and vice versa." ; sh:name "co-exists with" ; sh:nodeKind sh:IRI ; . dash:ConstraintReificationShape a sh:NodeShape ; rdfs:comment "Can be used to attach sh:severity and sh:messages to individual constraints using reification." ; rdfs:label "Constraint reification shape" ; sh:property dash:ConstraintReificationShape-message ; sh:property dash:ConstraintReificationShape-severity ; . dash:ConstraintReificationShape-message a sh:PropertyShape ; sh:path sh:message ; dash:singleLine true ; sh:name "messages" ; sh:nodeKind sh:Literal ; sh:or dash:StringOrLangString ; . dash:ConstraintReificationShape-severity a sh:PropertyShape ; sh:path sh:severity ; sh:class sh:Severity ; sh:maxCount 1 ; sh:name "severity" ; sh:nodeKind sh:IRI ; . dash:Constructor a dash:ShapeClass ; rdfs:comment """A script that is executed when a new instance of the class associated via dash:constructor is created, e.g. from a New button. Such scripts typically declare one or more parameters that are collected from the user when the script starts. The values of these parameters can be used as named variables in the script for arbitrary purposes such as setting the URI or initializing some property values of the new instance. The variable focusNode will hold the named node of the selected type, for example when a constructor is associated with a superclass but the user has pressed New for a subclass. The last expression of the script will be used as result of the constructor, so that the surrounding tool knows which resource shall be navigated to next.""" ; rdfs:label "Constructor" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:DASHJSLibrary a sh:JSLibrary ; rdfs:label "DASH JavaScript library" ; sh:jsLibrary dash:RDFQueryJSLibrary ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected result of a function call." ; sh:maxCount 1 ; sh:name "expected result" ; ] ; sh:property [ sh:path dash:expression ; sh:description "A valid SPARQL expression calling the function to test." ; sh:maxCount 1 ; . dash:DatePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:date literals, offering a calendar-like date picker." ; rdfs:label "Date picker editor" ; . dash:DateTimePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:dateTime literals, offering a calendar-like date picker and a time selector." ; rdfs:label "Date time picker editor" ; . dash:DepictionRole a dash:PropertyRole ; rdfs:comment "Depiction properties provide images representing the focus nodes. Typical examples may be a photo of an animal or the map of a country." ; rdfs:label "Depiction" ; . dash:Deprecated a dash:APIStatus ; rdfs:comment "Features that have been marked deprecated will remain in the API but should no longer be used by new code and may get deleted in the foreseeable future (e.g., with the next major release)." ; rdfs:label "deprecated" ; . dash:DescriptionRole a dash:PropertyRole ; rdfs:comment "Description properties should produce text literals that may be used as an introduction/summary of what a focus node does." ; rdfs:label "Description" ; . dash:DetailsEditor a dash:SingleEditor ; rdfs:comment "An editor for non-literal values, typically displaying a nested form where the values of the linked resource can be edited directly on the \"parent\" form. Implementations that do not support this (yet) could fall back to an auto-complete widget." ; rdfs:label "Details editor" ; . dash:DetailsViewer a dash:SingleViewer ; rdfs:comment "A Viewer for resources that shows the details of the value using its default view shape as a nested form-like display." ; rdfs:label "Details viewer" ; . dash:Editor a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for editing value nodes." ; rdfs:label "Editor" ; rdfs:subClassOf dash:Widget ; . dash:EnumSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for enumerated values (typically based on sh:in lists)." ; rdfs:label "Enum select editor" ; . dash:ExecutionPlatform a rdfs:Class ; rdfs:comment "An platform (such as TopBraid) that may have features needed to execute, for example, SPARQL queries." ; rdfs:label "Execution platform" ; rdfs:subClassOf rdfs:Resource ; . dash:Experimental a dash:APIStatus ; rdfs:comment "Features that are marked experimental can be used by early adopters but there is no guarantee that they will reach stable state." ; rdfs:label "experimental" ; . dash:ExploreAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in an Explore section of a selected resource. Cannot make changes to the data." ; rdfs:label "Explore action" ; rdfs:subClassOf dash:ResourceAction ; . dash:FailureResult a rdfs:Class ; rdfs:comment "A result representing a validation failure such as an unsupported recursion." ; rdfs:label "Failure result" ; rdfs:subClassOf sh:AbstractResult ; . dash:FailureTestCaseResult a rdfs:Class ; rdfs:comment "Represents a failure of a test case." ; rdfs:label "Failure test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:FunctionTestCase a dash:ShapeClass ; rdfs:comment "A test case that verifies that a given SPARQL expression produces a given, expected result." ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphService a dash:ShapeClass ; rdfs:comment "A service that does not apply to a specific resource (as ResourceService does) but operates on the whole graph. The focusNode variable will be the URI of the current base graph (e.g. <urn:x-evn-master:geo> as a NamedNode." ; rdfs:label "Graph service" ; rdfs:subClassOf dash:Service ; . dash:GraphStoreTestCase a dash:ShapeClass ; rdfs:comment "A test case that can be used to verify that an RDF file could be loaded (from a file) and that the resulting RDF graph is equivalent to a given TTL file." ; rdfs:label "Graph store test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphUpdate a rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:label "Graph update" ; rdfs:subClassOf dash:Suggestion ; . dash:GraphValidationTestCase a dash:ShapeClass ; rdfs:comment "A test case that performs SHACL constraint validation on the whole graph and compares the results with the expected validation results stored with the test case. By default this excludes meta-validation (i.e. the validation of the shape definitions themselves). If that's desired, set dash:validateShapes to true." ; rdfs:label "Graph validation test case" ; rdfs:subClassOf dash:ValidationTestCase ; . dash:HTMLOrStringOrLangString a rdf:List ; rdf:first [ rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected inferred triples, represented by instances of rdfs:Statement." ; sh:name "expected result" ; sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either rdf:HTML, xsd:string or rdf:langString (in that order of preference)." ; rdfs:label "HTML or string or langString" ; . dash:HTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML encoded text from rdf:HTML literals, rendering as parsed HTML DOM elements. Also displays the language if the HTML has a lang attribute on its root DOM element." ; rdfs:label "HTML viewer" ; . rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; sh:property [ sh:path dash:expectedResult ; sh:description "The expected result of the JavaScript function call, as an RDF node." ; sh:maxCount 1 ; a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . GRAPH $shapesGraph { $hasValueIn rdf:rest*/rdf:first ?value . } } }""" ; ] ; . dash:HasValueInConstraintComponent-hasValueIn a sh:Parameter ; sh:path dash:hasValueIn ; dash:reifiableBy dash:ConstraintReificationShape ; sh:description "At least one of the value nodes must be a member of the given list." ; sh:name "has value in" ; sh:node dash:ListShape ; . dash:HasValueTarget a sh:SPARQLTargetType ; rdfs:comment "A target type for all subjects where a given predicate has a certain object value." ; rdfs:label "Has Value target" ; rdfs:subClassOf sh:Target ; sh:labelTemplate "All subjects where {$predicate} has value {$object}" ; sh:parameter [ a sh:Parameter ; sh:path dash:object ; sh:description "The value that is expected to be present." ; sh:name "object" ; ] ; sh:parameter [ a sh:Parameter ; sh:path dash:predicate ; sh:description "The predicate property." ; sh:name "predicate" ; sh:nodeKind sh:IRI ; ] ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this $predicate $object . }""" ; . dash:HasValueWithClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be an instance of a given class." ; rdfs:label "Has value with class constraint component" ; sh:message "At least one of the values must be an instance of class {$hasValueWithClass}" ; sh:parameter dash:HasValueWithClassConstraintComponent-hasValueWithClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateHasValueWithClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . ?value a ?type . ?type rdfs:subClassOf* $hasValueWithClass . } }""" ; ] ; . dash:HasValueWithClassConstraintComponent-hasValueWithClass a sh:Parameter ; sh:path dash:hasValueWithClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "One of the values of the property path must be an instance of the given class." ; sh:name "has value with class" ; sh:nodeKind sh:IRI ; . dash:HyperlinkViewer a dash:SingleViewer ; rdfs:comment """A Viewer for literals, rendering as a hyperlink to a URL. For literals it assumes the lexical form is the URL. This is often used as default viewer for xsd:anyURI literals. Unsupported for blank nodes.""" ; rdfs:label "Hyperlink viewer" ; . dash:IDRole a dash:PropertyRole ; rdfs:comment "ID properties are short strings or other literals that identify the focus node among siblings. Examples may include social security numbers." ; rdfs:label "ID" ; . dash:IconRole a dash:PropertyRole ; rdfs:comment """Icon properties produce images that are typically small and almost square-shaped, and that may be displayed in the upper left corner of a focus node's display. Values should be xsd:string or xsd:anyURI literals or IRI nodes pointing at URLs. Those URLs should ideally be vector graphics such as .svg files. Instances of the same class often have the same icon, and this icon may be computed using a sh:values rule or as sh:defaultValue. If the value is a relative URL then those should be resolved against the server that delivered the surrounding page.""" ; rdfs:label "Icon" ; . dash:ImageViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI values that are recognized as images by a browser, rendering as an image." ; rdfs:label "Image viewer" ; . dash:IncludedScript a dash:ShapeClass ; rdfs:comment """The code associated with instances of this class will get injected into the generated APIs, as global code snippets. Typically used to declare libraries of utility functions or constants that are (compared to shape scripts) not necessarily associated with specific classes or shapes. Note that the JavaScript code stored in dash:js cannot use the export keyword because the code must also work in external scripts (such as on Node.js). Instead, you need to enumerate the exported symbols via dash:exports.""" ; rdfs:label "Included script" ; rdfs:subClassOf dash:Script ; sh:property tosh:IncludedScript-exports ; . dash:IndexedConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to mark property shapes to be indexed, meaning that each of its value nodes must carry a dash:index from 0 to N." ; rdfs:label "Indexed constraint component" ; sh:parameter dash:IndexedConstraintComponent-indexed ; . dash:IndexedConstraintComponent-indexed a sh:Parameter ; sh:path dash:indexed ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to activate indexing for this property." ; sh:maxCount 1 ; sh:name "indexed" ; . dash:InferencingTestCase a dash:ShapeClass ; rdfs:comment "A test case to verify whether an inferencing engine is producing identical results to those stored as expected results." ; rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; . dash:InlineViewer a dash:MultiViewer ; rdfs:comment "A multi-viewer that renders all values horizontally, in a more compact form that just a single value per row." ; rdfs:label "Inline viewer" ; . dash:InstancesSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of the target class (based on sh:class of the property)." ; rdfs:label "Instances select editor" ; . dash:JSONTableViewer a dash:SingleViewer ; rdfs:comment """A tabular viewer for rdf:JSON literals with a lexical form in the following format: { vars: [ 'col1', 'col2' ], // These are the column keys headerLabels: [ 'Column 1', 'Column 2' ], // Optional, for the column headers bindings: [ // These become the rows { col1: { lex: 'Value2', datatype: '...#string', }, col2: { uri: 'http://.../Instance', label: 'Example Instance', }, }, ... ], } The resulting table will use the headerLabels (if they exist) as column headers, otherwise derive the headers from the variable names. The vars must match the fields in the bindings. The table will contain one row for each binding. Using Active Data Shapes, you can construct such literals dynamically using a sh:values rule, e.g. ex:MyClass-myProperty a sh:PropertyShape ; sh:path ex:myProperty ; sh:values [ dash:js \"\"\" DataViewers.createTableViewerJSON(focusNode.select(` SELECT ?col1 ?col2 WHERE { $this ex:prop1 ?col1 . $this ex:prop2 ?col2 . } `))\"\"\" ] . rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:SPARQLSelectExecutable ; sh:property [ sh:path dash:expectedResult ; sh:datatype xsd:string ; sh:description "The expected result set, as a JSON string." ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; sh:name "expected result" ; ] ; sh:property [ sh:path sh:select ; sh:datatype xsd:string ; sh:description "The SPARQL SELECT query to execute." ; a dash:PropertyRole ; rdfs:comment "Properties with this role produce strings that may serve as display label for the focus nodes. Labels should be either plain string literals or strings with a language tag. The values should also be single-line." ; rdfs:label "Label" ; . dash:LabelViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI based on the display label of the resource. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "rdfQuery JavaScript Library" ; sh:jsLibraryURL "http://datashapes.org/js/rdfquery.js"^^xsd:anyURI ; . dash:RichTextEditor a dash:Editor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 0 ; ] ; ] [ sh:not [ sh:hasValue () ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $subject, $predicate and $object, as well as the other pre-bound variables for the parameters of the constraint. sh:oneOrMorePath rdf:rest ; ] ; dash:nonRecursive true ; ] ; ] ) ; sh:property [ a sh:PropertyShape ; sh:path [ sh:zeroOrMorePath rdf:rest ; ] ; rdfs:comment "Each list member (including this node) must be have the shape dash:ListNodeShape." ; sh:node dash:ListNodeShape ; ] ; . dash:LiteralViewer a dash:SingleViewer ; rdfs:comment "A simple viewer for literals, rendering the lexical form of the value." ; rdfs:label "Literal viewer" ; . dash:ModifyAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in a Modify section of a selected resource. May make changes to the data." ; rdfs:label "Modify action" ; rdfs:subClassOf dash:ResourceAction ; . dash:MultiEditor a dash:ShapeClass ; rdfs:comment "An editor for multiple/all value nodes at once." ; rdfs:label "Multi editor" ; rdfs:subClassOf dash:Editor ; . dash:MultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """A multi-function is a function that can return zero or more result objects consisting of one or more result variables. While normal (SPARQL/SHACL) functions can only return a single result node, multi-functions may not only return multiple nodes but even multiple individual variables per solution. A common way of defining multi-functions is by wrapping a SPARQL SELECT query, using dash:SPARQLMultiFunction. However, some MultiFunctions (in TopBraid) may also be implemented natively.""" ; rdfs:label "Multi-function" ; rdfs:subClassOf sh:Parameterizable ; sh:nodeKind sh:IRI ; . dash:MultiViewer a dash:ShapeClass ; rdfs:comment "A viewer for multiple/all values at once." ; rdfs:label "Multi viewer" ; rdfs:subClassOf dash:Viewer ; . dash:NoSuitableEditor a dash:SingleEditor ; rdfs:comment "An \"editor\" that simply informs the user that the values cannot be edited here, but for example through source code editing." ; rdfs:label "No suitable editor" ; . dash:NodeExpressionViewer a dash:SingleViewer ; rdfs:comment "A viewer for SHACL Node Expressions."^^rdf:HTML ; rdfs:label "Node expression viewer" ; . dash:NonRecursiveConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Used to state that a property or path must not point back to itself." ; rdfs:label "Non-recursive constraint component" ; sh:message "Points back at itself (recursively)" ; sh:parameter dash:NonRecursiveConstraintComponent-nonRecursive ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateNonRecursiveProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ($this AS ?value) WHERE { { FILTER (?nonRecursive) } $this $PATH $this . }""" ; ] ; . dash:NonRecursiveConstraintComponent-nonRecursive a sh:Parameter ; sh:path dash:nonRecursive ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description """Used to state that a property or path must not point back to itself. For example, \"a person cannot have itself as parent\" can be expressed by setting dash:nonRecursive=true for a given sh:path. To express that a person cannot have itself among any of its (recursive) parents, use a sh:path with the + operator such as ex:parent+.""" ; sh:maxCount 1 ; sh:name "non-recursive" ; . dash:None a sh:NodeShape ; rdfs:comment "A Shape that is no node can conform to." ; rdfs:label "None" ; sh:in () ; . dash:ParameterConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to verify that all value nodes conform to the given Parameter."@en ; rdfs:label "Parameter constraint component"@en ; sh:parameter dash:ParameterConstraintComponent-parameter ; . dash:ParameterConstraintComponent-parameter a sh:Parameter ; sh:path sh:parameter ; . dash:PrimaryKeyConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "Enforces a constraint that the given property (sh:path) serves as primary key for all resources in the target of the shape. If a property has been declared to be the primary key then each resource must have exactly one value for that property. Furthermore, the URIs of those resources must start with a given string (dash:uriStart), followed by the URL-encoded primary key value. For example if dash:uriStart is \"http://example.org/country-\" and the primary key for an instance is \"de\" then the URI must be \"http://example.org/country-de\". Finally, as a result of the URI policy, there can not be any other resource with the same value under the same primary key policy." ; rdfs:label "Primary key constraint component" ; sh:labelTemplate "The property {?predicate} is the primary key and URIs start with {?uriStart}" ; sh:message "Violation of primary key constraint" ; sh:parameter dash:PrimaryKeyConstraintComponent-uriStart ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validatePrimaryKeyProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this WHERE { FILTER ( # Must have a value for the primary key NOT EXISTS { ?this $PATH ?any } || # Must have no more than one value for the primary key EXISTS { ?this $PATH ?value1 . ?this $PATH ?value2 . FILTER (?value1 != ?value2) . } || # The value of the primary key must align with the derived URI EXISTS { { ?this $PATH ?value . FILTER NOT EXISTS { ?this $PATH ?value2 . FILTER (?value != ?value2) } } BIND (CONCAT($uriStart, ENCODE_FOR_URI(str(?value))) AS ?uri) . FILTER (str(?this) != ?uri) . } ) }""" ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart a sh:Parameter ; sh:path dash:uriStart ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "The start of the URIs of well-formed resources. If specified then the associated property/path serves as \"primary key\" for all target nodes (instances). All such target nodes need to have a URI that starts with the given string, followed by the URI-encoded value of the primary key property." ; sh:maxCount 1 ; sh:name "URI start" ; . rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; rdfs:comment "The class of roles that a property (shape) may take for its focus nodes." ; rdfs:label "Property role" ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; sh:property [ sh:path dash:testCase ; sh:class dash:TestCase ; sh:description "The dash:TestCase that was executed." ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . sh:name "test case" ; ] ; sh:property [ sh:path dash:testGraph ; sh:class rdfs:Resource ; sh:description "The graph containing the test case." ; rdfs:label "Reifiable-by constraint component" ; sh:labelTemplate "Reifiable by {$reifiableBy}" ; sh:parameter dash:ReifiableByConstraintComponent-reifiableBy ; . dash:ReifiableByConstraintComponent-reifiableBy a sh:Parameter ; sh:path dash:reifiableBy ; sh:class sh:NodeShape ; sh:description "Can be used to specify the node shape that may be applied to reified statements produced by a property shape. The property shape must have a URI resource as its sh:path. The values of this property must be node shapes. User interfaces can use this information to determine which properties to present to users when reified statements are explored or edited. Also, SHACL validators can use it to determine how to validate reified triples. Use dash:None to indicate that no reification should be permitted." ; sh:maxCount 1 ; sh:name "reifiable by" ; sh:nodeKind sh:IRI ; . dash:ResourceAction a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An Action that can be executed for a selected resource. Such Actions show up in context menus once they have been assigned a sh:group." ; rdfs:label "Resource action" ; rdfs:subClassOf dash:Action ; . dash:ResourceService a dash:ShapeClass ; rdfs:comment "A Service that can (and must) be applied to a given resource as focus node. Use dash:resourceService to link a class to the services that apply to its instances." ; rdfs:label "Resource service" ; rdfs:subClassOf dash:Service ; . dash:RichTextEditor a dash:SingleEditor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; rdfs:label "Rich text editor" ; . dash:RootClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component defining the parameter dash:rootClass, which restricts the values to be either the root class itself or one of its subclasses. This is typically used in conjunction with properties that have rdfs:Class as their type." ; rdfs:label "Root class constraint component" ; sh:labelTemplate "Root class {$rootClass}" ; sh:message "Value must be subclass of {$rootClass}" ; sh:parameter dash:RootClassConstraintComponent-rootClass ; sh:validator dash:hasRootClass ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateRootClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:RootClassConstraintComponent-rootClass a sh:Parameter ; sh:path dash:rootClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "The root class." ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLConstructTemplate a rdfs:Class ; rdfs:comment "Encapsulates one or more SPARQL CONSTRUCT queries that can be parameterized. Parameters will become pre-bound variables in the queries." ; rdfs:label "SPARQL CONSTRUCT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLConstructExecutable ; . dash:SPARQLMultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment "A multi-function based on a SPARQL SELECT query. The query gets executed with the arguments pre-bound to the variables declared as parameters. The results of the multi-function are all result bindings from the SPARQL result set." ; rdfs:label "SPARQL multi-function" ; rdfs:subClassOf dash:MultiFunction ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLSelectTemplate a rdfs:Class ; rdfs:comment "Encapsulates a SPARQL SELECT query that can be parameterized. Parameters will become pre-bound variables in the query." ; rdfs:label "SPARQL SELECT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $focusNode, $predicate and $value, as well as the other pre-bound variables for the parameters of the constraint. In many cases, there may be multiple possible suggestions to fix a problem. For example, with sh:maxLength there are many ways to slice a string. In those cases, the system will first iterate through the result variables from a SELECT query (sh:select) and apply these results as pre-bound variables into the UPDATE query.""" ; rdfs:label "SPARQL UPDATE suggestion generator" ; rdfs:subClassOf dash:SuggestionGenerator ; rdfs:subClassOf sh:SPARQLSelectExecutable ; rdfs:subClassOf sh:SPARQLUpdateExecutable ; . rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; sh:property [ sh:path dash:expectedResult ; sh:class sh:ValidationReport ; sh:description "The expected validation report." ; a sh:PropertyGroup ; rdfs:label "Script API Generation Rules" ; . dash:ScriptAPIShape a sh:NodeShape ; rdfs:comment "Defines the properties that instruct the ADS Script API generator about what prefixes, constants and classes to generate." ; rdfs:label "Script API" ; sh:property dash:ScriptAPIShape-generateClass ; sh:property dash:ScriptAPIShape-generatePrefixClasses ; sh:property dash:ScriptAPIShape-generatePrefixConstants ; sh:targetClass owl:Ontology ; . dash:ScriptAPIShape-generateClass a sh:PropertyShape ; sh:path dash:generateClass ; sh:class sh:NodeShape ; sh:description "The API generator will produce classes for each value of this property and all its subclasses and superclasses." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate class" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixClasses a sh:PropertyShape ; sh:path dash:generatePrefixClasses ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce classes for all RDFS classes or node shapes from the associated namespace." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix classes" ; sh:order "15"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixConstants a sh:PropertyShape ; sh:path dash:generatePrefixConstants ; sh:datatype xsd:string ; rdfs:range rdf:Statement ; . dash:all rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . rdfs:comment """The class of constraints that are based on Scripts. Depending on whether dash:onAllValues is set to true, these scripts can access the following pre-assigned variables: - focusNode: the focus node of the constraint (a NamedNode) - if dash:onAllValues is not true: value: the current value node (e.g. a JavaScript string for xsd:string literals, a number for numeric literals or true or false for xsd:boolean literals. All other literals become LiteralNodes, and non-literals become instances of NamedNode) - if dash:onAllValues is true: values: an array of current value nodes, as above. If the expression returns an array then each array member will be mapped to one validation result, following the mapping rules below. For string results, a validation result will use the string as sh:resultMessage. For boolean results, a validation result will be produced if the result is false (true means no violation). For object results, a validation result will be produced using the value of the field \"message\" of the object as result message. If the field \"value\" has a value then this will become the sh:value in the violation. Unless another sh:message has been directly returned, the sh:message of the dash:ScriptConstraint will be used, similar to sh:message at SPARQL Constraints. These sh:messages can access the values {$focusNode}, {$value} etc as template variables.""" ; rdfs:label "Script constraint" ; rdfs:subClassOf dash:Script ; . dash:ScriptConstraintComponent a sh:ConstraintComponent ; rdfs:label "Script constraint component" ; sh:parameter dash:ScriptConstraintComponent-scriptConstraint ; . dash:ScriptConstraintComponent-scriptConstraint a sh:Parameter ; sh:path dash:scriptConstraint ; sh:class dash:ScriptConstraint ; sh:description "The Script constraint(s) to apply." ; sh:name "script constraint" ; . dash:ScriptFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """Script functions can be used from SPARQL queries and will be injected into the generated prefix object (in JavaScript, for ADS scripts). The dash:js will be inserted into a generated JavaScript function and therefore needs to use the return keyword to produce results. These JS snippets can access the parameter values based on the local name of the sh:Parameter's path. For example ex:value can be accessed using value. SPARQL use note: Since these functions may be used from any data graph and any shapes graph, they must not rely on any API apart from what's available in the shapes graph that holds the rdf:type triple of the function itself. In other words, at execution time from SPARQL, the ADS shapes graph will be the home graph of the function's declaration.""" ; rdfs:label "Script function" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Function ; . dash:ScriptSuggestionGenerator a dash:ShapeClass ; rdfs:comment """A Suggestion Generator that is backed by an Active Data Shapes script. The script needs to return a JSON object or an array of JSON objects if it shall generate multiple suggestions. It may also return null to indicate that nothing was suggested. Note that the whole script is evaluated as a (JavaScript) expression, and those will use the last value as result. So simply putting an object at the end of your script should do. Alternatively, define the bulk of the operation as a function and simply call that function in the script. Each response object can have the following fields: { message: \"The human readable message\", // Defaults to the rdfs:label(s) of the suggestion generator add: [ // An array of triples to add, each triple as an array with three nodes [ subject, predicate, object ], [ ... ] ], delete: [ ... like add, for the triples to delete ] } Suggestions with neither added nor deleted triples will be discarded. At execution time, the script operates on the data graph as the active graph, with the following pre-bound variables: - focusNode: the NamedNode that is the sh:focusNode of the validation result - predicate: the NamedNode representing the predicate of the validation result, assuming sh:resultPath is a URI - value: the value node from the validation result's sh:value, cast into the most suitable JS object - the other pre-bound variables for the parameters of the constraint, e.g. in a sh:maxCount constraint it would be maxCount The script will be executed in read-only mode, i.e. it cannot modify the graph. Example with dash:js: ({ message: `Copy labels into ${graph.localName(predicate)}`, add: focusNode.values(rdfs.label).map(label => [ focusNode, predicate, label ] ) })""" ; rdfs:label "Script suggestion generator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:SuggestionGenerator ; . dash:ScriptTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a script. Requires exactly one value for dash:js and will operate on the test case's graph (with imports) as both data and shapes graph. Supports read-only scripts only at this stage.""" ; rdfs:label "Script test case" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:TestCase ; . dash:ScriptValidator a dash:ShapeClass ; rdfs:comment """A SHACL validator based on an Active Data Shapes script. See the comment at dash:ScriptConstraint for the basic evaluation approach. Note that in addition to focusNode and value/values, the script can access pre-bound variables for each declared argument of the constraint component.""" ; rdfs:label "Script validator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Validator ; . dash:Service a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A script that gets exposed as a web service, e.g. /tbl/service/ex/MyService" ; rdfs:label "Service" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ShapeClass a dash:ShapeClass ; dash:hidden true ; rdfs:comment "A class that is also a node shape. This class can be used as rdf:type instead of the combination of rdfs:Class and sh:NodeShape." ; rdfs:label "Shape class" ; rdfs:subClassOf rdfs:Class ; rdfs:subClassOf sh:NodeShape ; . dash:ShapeScript a rdfs:Class ; rdfs:comment "A shape script contains extra code that gets injected into the API for the associated node shape. In particular you can use this to define additional functions that operate on the current focus node (the this variable in JavaScript)." ; rdfs:label "Shape script" ; rdfs:subClassOf dash:Script ; . dash:SingleEditor a dash:ShapeClass ; rdfs:comment "An editor for individual value nodes." ; rdfs:label "Single editor" ; rdfs:subClassOf dash:Editor ; . dash:SingleLineConstraintComponent a sh:ConstraintComponent ; rdfs:comment """A constraint component that can be used to declare that all values that are literals must have a lexical form that contains no line breaks ('\\n' or '\\r'). User interfaces may use the dash:singleLine flag to prefer a text field over a (multi-line) text area.""" ; rdfs:label "Single line constraint component" ; sh:message "Must not contain line breaks." ; sh:parameter dash:SingleLineConstraintComponent-singleLine ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSingleLine" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { FILTER (!$singleLine || !isLiteral($value) || (!contains(str($value), '\\n') && !contains(str($value), '\\r'))) }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; . dash:SingleLineConstraintComponent-singleLine a sh:Parameter ; sh:path dash:singleLine ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to state that the lexical form of literal value nodes must not contain any line breaks. False to state that line breaks are explicitly permitted." ; sh:group tosh:StringConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "single line" ; sh:order "30"^^xsd:decimal ; . dash:SingleViewer a dash:ShapeClass ; rdfs:comment "A viewer for a single value." ; rdfs:label "Single viewer" ; rdfs:subClassOf dash:Viewer ; . dash:Stable a dash:APIStatus ; rdfs:comment "Features that have been marked stable are deemed of good quality and can be used until marked deprecated." ; rdfs:label "stable" ; . dash:StemConstraintComponent a sh:ConstraintComponent ; dash:staticConstraint true ; rdfs:comment "A constraint component that can be used to verify that every value node is an IRI and the IRI starts with a given string value."@en ; rdfs:label "Stem constraint component"@en ; sh:labelTemplate "Value needs to have stem {$stem}" ; sh:message "Value does not have stem {$stem}" ; sh:parameter dash:StemConstraintComponent-stem ; sh:validator dash:hasStem ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateStem" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:StemConstraintComponent-stem a sh:Parameter ; sh:path dash:stem ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "If specified then every value node must be an IRI and the IRI must start with the given string value." ; sh:maxCount 1 ; sh:name "stem" ; . dash:StringOrLangString a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string or rdf:langString." ; rdfs:label "String or langString" ; . dash:StringOrLangStringOrHTML a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] [ rdfs:label "height" ; rdfs:range xsd:integer ; . dash:includedExecutionPlatform a rdf:Property ; rdfs:comment "Can be used to state that one (subject) execution platform includes all features of another platform (object)." ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to state that the set of value nodes must be a subset of the value of a given property." ; rdfs:label "Sub set of constraint component" ; sh:message "Must be one of the values of {$subSetOf}" ; sh:parameter dash:SubSetOfConstraintComponent-subSetOf ; sh:propertyValidator [ a sh:SPARQLAskValidator ; sh:ask """ASK { $this $subSetOf $value . }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSubSetOf" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:SubSetOfConstraintComponent-subSetOf a sh:Parameter ; sh:path dash:subSetOf ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "Can be used to state that all value nodes must also be values of a specified other property at the same focus node." ; sh:name "sub-set of" ; sh:nodeKind sh:IRI ; . dash:SuccessResult a rdfs:Class ; rdfs:comment "A result representing a successfully validated constraint." ; rdfs:label "Success result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SuccessTestCaseResult a rdfs:Class ; rdfs:comment "Represents a successful run of a test case." ; rdfs:label "Success test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:Suggestion a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of suggestions that modify a graph to \"fix\" the source of a validation result." ; rdfs:label "Suggestion" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionGenerator a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of objects that can generate suggestions (added or deleted triples) for a validation result of a given constraint component." ; rdfs:label "Suggestion generator" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionResult a rdfs:Class ; rdfs:comment "Class of results that have been produced as suggestions, not through SHACL validation. How the actual results are produced is up to implementers. Each instance of this class should have values for sh:focusNode, sh:resultMessage, sh:resultSeverity (suggested default: sh:Info), and dash:suggestion to point at one or more suggestions." ; rdfs:label "Suggestion result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SymmetricConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A contraint component for property shapes to validate that a property is symmetric. For symmetric properties, if A relates to B then B must relate to A." ; rdfs:label "Symmetric constraint component" ; sh:message "Symmetric value expected" ; sh:parameter dash:SymmetricConstraintComponent-symmetric ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateSymmetric" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this ?value { FILTER ($symmetric) . $this $PATH ?value . FILTER NOT EXISTS { ?value $PATH $this . } }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric a sh:Parameter ; sh:path dash:symmetric ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "If set to true then if A relates to B then B must relate to A." ; sh:maxCount 1 ; sh:name "symmetric" ; . dash:TestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class for results produced by running test cases." ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; . dash:TestEnvironment a rdfs:Class ; dash:abstract true ; rdfs:comment "Abstract base class for test environments, holding information on how to set up a test case." ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:TextAreaEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal." ; rdfs:label "Text area editor" ; . dash:readOnly a rdf:Property ; rdfs:comment "Used as a hint for user interfaces that values of the associated property should not be editable." ; rdfs:domain sh:PropertyShape ; rdfs:label "read only" ; rdfs:range xsd:boolean ; . dash:requiredExecutionPlatform a rdf:Property ; rdfs:label "Text field with lang editor" ; . dash:URIEditor a dash:SingleEditor ; rdfs:comment "An input field to enter the URI of a resource, e.g. rdfs:seeAlso links or images." ; rdfs:label "URI editor" ; . dash:URIViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "URI viewer" ; . dash:UniqueValueForClassConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment "A constraint component that can be used to state that the values of a property must be unique for all instances of a given class (and its subclasses)." ; rdfs:label "Unique value for class constraint component" ; sh:labelTemplate "Values must be unique among all instances of {?uniqueValueForClass}" ; sh:parameter dash:UniqueValueForClassConstraintComponent-uniqueValueForClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateUniqueValueForClass" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Value {?value} must be unique but is also used by {?other}" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Value {?value} must be unique but is also used by {?other}" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ?value ?other WHERE { { $this $PATH ?value . ?other $PATH ?value . FILTER (?other != $this) . } ?other a ?type . ?type rdfs:subClassOf* $uniqueValueForClass . }""" ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass a sh:Parameter ; sh:path dash:uniqueValueForClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "States that the values of the property must be unique for all instances of a given class (and its subclasses)." ; sh:name "unique value for class" ; sh:nodeKind sh:IRI ; . dash:UntrustedHTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML content from untrusted sources. This viewer will sanitize the HTML before rendering. Any a, button, checkbox, form, hidden, input, img, script, select, style and textarea tags and class and style attributes will be removed." ; rdfs:label "Untrusted HTML viewer" ; . dash:ValidationTestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Abstract superclass for test cases concerning SHACL constraint validation. Future versions may add new kinds of validatin test cases, e.g. to validate a single resource only." ; rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; . dash:ValueTableViewer a dash:MultiViewer ; rdfs:comment "A viewer that renders all values of a given property as a table, with one value per row, and the columns defined by the shape that is the sh:node or sh:class of the property." ; rdfs:label "Value table viewer" ; . dash:Viewer a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for viewing value nodes." ; rdfs:label "Viewer" ; rdfs:subClassOf dash:Widget ; . dash:Widget a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Base class of user interface components that can be used to display or edit value nodes." ; rdfs:label "Widget" ; rdfs:subClassOf rdfs:Resource ; . dash:abstract a rdf:Property ; rdfs:comment "Indicates that a class is \"abstract\" and cannot be used in asserted rdf:type triples. Only non-abstract subclasses of abstract classes should be instantiated directly." ; rdfs:domain rdfs:Class ; rdfs:label "abstract" ; rdfs:range xsd:boolean ; . dash:actionGroup a rdf:Property ; rdfs:comment "Links an Action with the ActionGroup that it should be arranged in." ; rdfs:domain dash:Action ; rdfs:label "action group" ; rdfs:range dash:ActionGroup ; . dash:actionIconClass a rdf:Property ; rdfs:comment "The (CSS) class of an Action for display purposes alongside the label." ; rdfs:domain dash:Action ; rdfs:label "action icon class" ; rdfs:range xsd:string ; . dash:addedTriple a rdf:Property ; rdfs:comment "May link a dash:GraphUpdate with one or more triples (represented as instances of rdf:Statement) that should be added to fix the source of the result." ; rdfs:domain dash:GraphUpdate ; rdfs:label "added triple" ; rdfs:range rdf:Statement ; . dash:all a rdfs:Resource ; rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . dash:apiStatus a rdf:Property ; rdfs:comment "Defines how and whether the associated feature is part of an external API. APIs may be implemented as (REST) web services, via GraphQL or ADS Script APIs." ; rdfs:label "API status" ; rdfs:range dash:APIStatus ; . dash:applicableToClass a rdf:Property ; rdfs:comment "Can be used to state that a shape is applicable to instances of a given class. This is a softer statement than \"target class\": a target means that all instances of the class must conform to the shape. Being applicable to simply means that the shape may apply to (some) instances of the class. This information can be used by algorithms or humans." ; rdfs:domain sh:Shape ; rdfs:label "applicable to class" ; rdfs:range rdfs:Class ; . dash:cachable a rdf:Property ; rdfs:comment "If set to true then the results of the SHACL function can be cached in between invocations with the same arguments. In other words, they are stateless and do not depend on triples in any graph, or the current time stamp etc." ; rdfs:domain sh:Function ; rdfs:label "cachable" ; rdfs:range xsd:boolean ; . dash:closedByTypes a rdf:Property ; rdfs:label "closed by types" ; . dash:coExistsWith a rdf:Property ; rdfs:comment "Specifies a property that must have a value whenever the property path has a value, and must have no value whenever the property path has no value." ; rdfs:label "co-exists with" ; rdfs:range rdf:Property ; . dash:composite a rdf:Property ; rdfs:comment "Can be used to indicate that a property/path represented by a property constraint represents a composite relationship. In a composite relationship, the life cycle of a \"child\" object (value of the property/path) depends on the \"parent\" object (focus node). If the parent gets deleted, then the child objects should be deleted, too. Tools may use dash:composite (if set to true) to implement cascading delete operations." ; rdfs:domain sh:PropertyShape ; rdfs:label "composite" ; rdfs:range xsd:boolean ; . dash:defaultLang a rdf:Property ; rdfs:comment "Can be used to annotate a graph (usually the owl:Ontology) with the default language that tools should suggest for new literal values. For example, predominantly English graphs should have \"en\" as default language." ; rdfs:domain owl:Ontology ; rdfs:label "default language" ; rdfs:range xsd:string ; . dash:defaultViewForRole a rdf:Property ; rdfs:comment "Links a node shape with the roles
60
Added support for DASH templates - http://datashapes.org/templates.html Also: Catching up with latest TopBraid changes.
5
.ttl
ttl
apache-2.0
TopQuadrant/shacl
50
<NME> RuleUtil.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.rules; import java.net.URI; import java.util.ArrayList; import java.util.List; 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.vocabulary.RDF; import org.topbraid.jenax.progress.ProgressMonitor; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.SHACLScriptEngineManager; import org.topbraid.shacl.engine.Shape; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.SH; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to execute SHACL rules. * * @author Holger Knublauch */ public class RuleUtil { /** * Executes all rules from a given shapes Model on a given data Model. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param dataModel the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(Model dataModel, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(dataModel, null, shapesModel, inferencesModel, monitor); } /** * Executes all rules from a given shapes Model on a given focus node (in its data Model). * This only executes the rules from the shapes that have the focus node in their target. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param focusNode the focus node in the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(RDFNode focusNode, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(focusNode.getModel(), focusNode, shapesModel, inferencesModel, monitor); } private static Model executeRulesHelper(Model dataModel, RDFNode focusNode, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { // 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); } // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); if(inferencesModel == null) { inferencesModel = JenaUtil.createDefaultModel(); inferencesModel.setNsPrefixes(dataModel); inferencesModel.withDefaultMappings(shapesModel); MultiUnion unionGraph = new MultiUnion(new Graph[] { dataModel.getGraph(), inferencesModel.getGraph() }); dataModel = ModelFactory.createModelForGraph(unionGraph); } // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel); RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); boolean nested = SHACLScriptEngineManager.get().begin(); try { engine.applyEntailments(); if(focusNode == null) { engine.setExcludeNeverMaterialize(true); engine.executeAll(); } else { List<Shape> shapes = getShapesWithTargetNode(focusNode, shapesGraph); engine.executeShapes(shapes, focusNode); } } catch(InterruptedException ex) { return null; } finally { SHACLScriptEngineManager.get().end(nested); } return inferencesModel; } public static List<Shape> getShapesWithTargetNode(RDFNode focusNode, ShapesGraph shapesGraph) { // TODO: Not a particularly smart algorithm - walks all shapes that have rules List<Shape> shapes = new ArrayList<>(); for(Shape shape : shapesGraph.getRootShapes()) { if(shape.getShapeResource().hasProperty(SH.rule) && shape.getShapeResource().hasTargetNode(focusNode)) { shapes.add(shape); } } return shapes; } } <MSG> #112: (Corrected) now setting base graph for shapes graph parsing issue <DFF> @@ -93,6 +93,7 @@ public class RuleUtil { unionModel.getGraph(), shapesModel.getGraph() }); + unionGraph.setBaseGraph(shapesModel.getGraph()); shapesModel = ModelFactory.createModelForGraph(unionGraph); }
1
#112: (Corrected) now setting base graph for shapes graph parsing issue
0
.java
java
apache-2.0
TopQuadrant/shacl
51
<NME> RuleUtil.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.rules; import java.net.URI; import java.util.ArrayList; import java.util.List; 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.vocabulary.RDF; import org.topbraid.jenax.progress.ProgressMonitor; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.SHACLScriptEngineManager; import org.topbraid.shacl.engine.Shape; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.SH; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to execute SHACL rules. * * @author Holger Knublauch */ public class RuleUtil { /** * Executes all rules from a given shapes Model on a given data Model. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param dataModel the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(Model dataModel, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(dataModel, null, shapesModel, inferencesModel, monitor); } /** * Executes all rules from a given shapes Model on a given focus node (in its data Model). * This only executes the rules from the shapes that have the focus node in their target. * If the shapesModel does not include the system graph triples then these will be added. * If inferencesModel is not null then it must be part of the dataModel (e.g. a sub-graph) * of a Jena MultiUnion object. * Otherwise, the function will create a new inferences Model which is merged with the * dataModel for the duration of the execution. * @param focusNode the focus node in the data Model * @param shapesModel the shapes Model * @param inferencesModel the Model for the inferred triples or null * @param monitor an optional progress monitor * @return the Model of inferred triples (i.e. inferencesModel if not null, or a new Model) */ public static Model executeRules(RDFNode focusNode, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { return executeRulesHelper(focusNode.getModel(), focusNode, shapesModel, inferencesModel, monitor); } private static Model executeRulesHelper(Model dataModel, RDFNode focusNode, Model shapesModel, Model inferencesModel, ProgressMonitor monitor) { // 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); } // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); if(inferencesModel == null) { inferencesModel = JenaUtil.createDefaultModel(); inferencesModel.setNsPrefixes(dataModel); inferencesModel.withDefaultMappings(shapesModel); MultiUnion unionGraph = new MultiUnion(new Graph[] { dataModel.getGraph(), inferencesModel.getGraph() }); dataModel = ModelFactory.createModelForGraph(unionGraph); } // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); Dataset dataset = ARQFactory.get().getDataset(dataModel); dataset.addNamedModel(shapesGraphURI.toString(), shapesModel); ShapesGraph shapesGraph = ShapesGraphFactory.get().createShapesGraph(shapesModel); RuleEngine engine = new RuleEngine(dataset, shapesGraphURI, shapesGraph, inferencesModel); engine.setProgressMonitor(monitor); boolean nested = SHACLScriptEngineManager.get().begin(); try { engine.applyEntailments(); if(focusNode == null) { engine.setExcludeNeverMaterialize(true); engine.executeAll(); } else { List<Shape> shapes = getShapesWithTargetNode(focusNode, shapesGraph); engine.executeShapes(shapes, focusNode); } } catch(InterruptedException ex) { return null; } finally { SHACLScriptEngineManager.get().end(nested); } return inferencesModel; } public static List<Shape> getShapesWithTargetNode(RDFNode focusNode, ShapesGraph shapesGraph) { // TODO: Not a particularly smart algorithm - walks all shapes that have rules List<Shape> shapes = new ArrayList<>(); for(Shape shape : shapesGraph.getRootShapes()) { if(shape.getShapeResource().hasProperty(SH.rule) && shape.getShapeResource().hasTargetNode(focusNode)) { shapes.add(shape); } } return shapes; } } <MSG> #112: (Corrected) now setting base graph for shapes graph parsing issue <DFF> @@ -93,6 +93,7 @@ public class RuleUtil { unionModel.getGraph(), shapesModel.getGraph() }); + unionGraph.setBaseGraph(shapesModel.getGraph()); shapesModel = ModelFactory.createModelForGraph(unionGraph); }
1
#112: (Corrected) now setting base graph for shapes graph parsing issue
0
.java
java
apache-2.0
TopQuadrant/shacl
52
<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 The maven release plugin will move the version from SNAPSHOT to the release version, and tag the github repository. It will also move to the next SNAPSHOT version after building the release (autoVersionSubmodules is set true). 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`. ### Dry run It is advisable to dry run the release: ``` mvn release:clean release:prepare -DdryRun=true $KEY ``` ### Check Look in `target/` You should see various files built. 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` `mvn release:perform $KEY` ### If it goes wrong: `mvn release:rollback` `mvn release:clean` ### Release to central The steps so far pushed the built artifacts to the staging repository. 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 checking completes. * If all is good, click "release" at the top. 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> Updates to the release process <DFF> @@ -59,10 +59,20 @@ repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`). ### Setup Release Process -The maven release plugin will move the version from SNAPSHOT to the -release version, and tag the github repository. It will also move to -the next SNAPSHOT version after building the release -(autoVersionSubmodules is set true). +#### 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: @@ -78,20 +88,26 @@ If you have only one key, set this to the empty string: export KEY="" ``` -or omit `$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 $KEY +mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY ``` ### Check -Look in `target/` +Look in `target/`. + +You should see various files built including thebinary ".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. -You should see various files built. +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. @@ -99,14 +115,19 @@ It still says "SNAPSHOT" because the dry run does not change the version in POM. This has two steps: -`mvn release:clean release:prepare` -`mvn release:perform $KEY` +`mvn release:clean release:prepare -Prelease $KEY $VER` +`mvn release:perform -Prelease $KEY $VER` ### If it goes wrong: -`mvn release:rollback` +`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.
32
Updates to the release process
11
.md
md
apache-2.0
TopQuadrant/shacl
53
<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 The maven release plugin will move the version from SNAPSHOT to the release version, and tag the github repository. It will also move to the next SNAPSHOT version after building the release (autoVersionSubmodules is set true). 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`. ### Dry run It is advisable to dry run the release: ``` mvn release:clean release:prepare -DdryRun=true $KEY ``` ### Check Look in `target/` You should see various files built. 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` `mvn release:perform $KEY` ### If it goes wrong: `mvn release:rollback` `mvn release:clean` ### Release to central The steps so far pushed the built artifacts to the staging repository. 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 checking completes. * If all is good, click "release" at the top. 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> Updates to the release process <DFF> @@ -59,10 +59,20 @@ repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`). ### Setup Release Process -The maven release plugin will move the version from SNAPSHOT to the -release version, and tag the github repository. It will also move to -the next SNAPSHOT version after building the release -(autoVersionSubmodules is set true). +#### 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: @@ -78,20 +88,26 @@ If you have only one key, set this to the empty string: export KEY="" ``` -or omit `$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 $KEY +mvn release:clean release:prepare -DdryRun=true -Prelease $VER $KEY ``` ### Check -Look in `target/` +Look in `target/`. + +You should see various files built including thebinary ".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. -You should see various files built. +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. @@ -99,14 +115,19 @@ It still says "SNAPSHOT" because the dry run does not change the version in POM. This has two steps: -`mvn release:clean release:prepare` -`mvn release:perform $KEY` +`mvn release:clean release:prepare -Prelease $KEY $VER` +`mvn release:perform -Prelease $KEY $VER` ### If it goes wrong: -`mvn release:rollback` +`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.
32
Updates to the release process
11
.md
md
apache-2.0
TopQuadrant/shacl
54
<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 import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; 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 dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); shapesModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Print violations System.out.println(ModelPrinter.get().print(report.getModel())); } } <MSG> No longer requires default value type inferences, fixes in SPIN API allowing subjects (of magic properties etc) to be literals in SPARQL <DFF> @@ -12,7 +12,6 @@ import org.apache.jena.util.FileUtils; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; -import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; @@ -35,8 +34,6 @@ public class ValidationExample { dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); - - shapesModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel);
0
No longer requires default value type inferences, fixes in SPIN API allowing subjects (of magic properties etc) to be literals in SPARQL
3
.java
java
apache-2.0
TopQuadrant/shacl
55
<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 import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; 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 dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); shapesModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Print violations System.out.println(ModelPrinter.get().print(report.getModel())); } } <MSG> No longer requires default value type inferences, fixes in SPIN API allowing subjects (of magic properties etc) to be literals in SPARQL <DFF> @@ -12,7 +12,6 @@ import org.apache.jena.util.FileUtils; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.constraints.ModelConstraintValidator; import org.topbraid.shacl.util.ModelPrinter; -import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.util.JenaUtil; @@ -35,8 +34,6 @@ public class ValidationExample { dataModel.getGraph() }); Model shapesModel = ModelFactory.createModelForGraph(unionGraph); - - shapesModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel);
0
No longer requires default value type inferences, fixes in SPIN API allowing subjects (of magic properties etc) to be literals in SPARQL
3
.java
java
apache-2.0
TopQuadrant/shacl
56
<NME> tosh.ttl <BEF> ADDFILE <MSG> Adding removed resources for Java tests <DFF> @@ -0,0 +1,1032 @@ +# baseURI: http://topbraid.org/tosh +# imports: http://datashapes.org/dash +# prefix: tosh + +@prefix dash: <http://datashapes.org/dash#> . +@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"^^xsd:boolean ; +. +dash:ClosedByTypesConstraintComponent-closedByTypes + sh:group tosh:OtherConstraintPropertyGroup ; +. +dash:NonRecursiveConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + sh:property [ + sh:path dash:nonRecursive ; + sh:group tosh:RelationshipPropertyGroup ; + ] ; +. +dash:RootClassConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +dash:StemConstraintComponent-stem + sh:group tosh:StringBasedConstraintPropertyGroup ; +. +<http://spinrdf.org/sp#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://spinrdf.org/spin#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://spinrdf.org/spl#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://topbraid.org/tosh> + rdf:type owl:Ontology ; + rdfs:comment """A collection of SHACL features that are used whenever SHACL graphs are used within TopBraid Suite products. This includes things like suggested PropertyGroups and Shapes that control the layout of forms. Some of these may be of general use outside of TopBraid too. + +This namespace also includes the function tosh:hasShape, which can be used to implement some advanced constraint components using SPARQL only.""" ; + rdfs:label "TopBraid Data Shapes Library" ; + owl:imports <http://datashapes.org/dash> ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; + sh:prefix "afn" ; + ] ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; + sh:prefix "spif" ; + ] ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; + sh:prefix "tosh" ; + ] ; +. +tosh: + tosh:systemNamespace "true"^^xsd:boolean ; +. +tosh:AboutPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "This Shape" ; + sh:order 0 ; +. +tosh:CardinalityConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "Cardinality" ; + sh:order 2 ; +. +tosh:ComplexConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Complex Constraints" ; + sh:order 9 ; +. +tosh:ConstraintMetadataPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "Constraint Metadata" ; +. +tosh:DeleteTripleSuggestionGenerator + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + rdfs:label "Delete triple suggestion generator" ; + sh:message "Delete the invalid statement" ; + sh:update """DELETE { + $focusNode $predicate $value . +} +WHERE { +}""" ; +. +tosh:DisplayPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:comment "A group for properties that are primarily for display purposes (names, ordering etc)." ; + rdfs:label "Display" ; + sh:order 1 ; +. +tosh:MemberShapeConstraintComponent + rdf:type 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 [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "List member {?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 + rdf:type 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:OtherConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Other Constraints" ; + sh:order 10 ; +. +tosh:PropertyGroupShape + rdf:type sh:NodeShape ; + rdfs:label "Property group shape" ; + sh:property [ + sh:path sh:order ; + sh:maxCount 1 ; + ] ; + sh:targetClass sh:PropertyGroup ; +. +tosh:PropertyPairConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Property Pairs" ; + sh:order 6 ; +. +tosh:PropertyShapeShape + rdf:type sh:NodeShape ; + rdfs:label "Property shape shape" ; + sh:property [ + sh:path tosh:editWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectEditorClass that shall be used to edit values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "edit widget" ; + sh:nodeKind sh:IRI ; + sh:order 21 ; + ] ; + sh:property [ + sh:path tosh:searchWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectFacetClass that shall be used to search for values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "search widget" ; + sh:nodeKind sh:IRI ; + sh:order 22 ; + ] ; + sh:property [ + sh:path tosh:viewWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectViewerClass that shall be used to view values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "view widget" ; + sh:nodeKind sh:IRI ; + sh:order 20 ; + ] ; + sh:property [ + sh:path sh:defaultValue ; + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:description "The default value to be used for this property at new instances." ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + ] ; + sh:property [ + sh:path sh:description ; + tosh:editWidget swa:TextAreaEditor ; + sh:description "A human-readable description of the role of the property in the constraint." ; + sh:group tosh:DisplayPropertyGroup ; + sh:name "description" ; + sh:order 2 ; + ] ; + sh:property [ + sh:path sh:group ; + sh:description "The sh:PropertyGroup that the property belongs to." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "group" ; + sh:order 10 ; + ] ; + sh:property [ + sh:path sh:name ; + tosh:editWidget swa:TextFieldEditorWithLang ; + sh:description "The display name of the property." ; + sh:group tosh:DisplayPropertyGroup ; + sh:name "name" ; + sh:order 1 ; + ] ; + sh:property [ + sh:path sh:order ; + sh:description "The relative position of the property among its peers, e.g. a property with order 5 shows up before one with order 6." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "order" ; + sh:order 11 ; + ] ; + sh:property [ + sh:path sh:path ; + tosh:editWidget <http://topbraid.org/tosh.ui#PathEditor> ; + tosh:viewWidget <http://topbraid.org/tosh.ui#PathViewer> ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:minCount 1 ; + sh:name "on property" ; + sh:order 0 ; + ] ; + sh:targetClass sh:PropertyShape ; +. +tosh:RelationshipPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Relationship" ; + sh:order 8 ; +. +tosh:ShapeShape + rdf:type sh:NodeShape ; + rdfs:label "Shape of shapes" ; + sh:property tosh:ShapeShape-deactivated ; + sh:property tosh:ShapeShape-severity ; + sh:targetClass sh:Shape ; +. +tosh:ShapeShape-deactivated + rdf:type sh:PropertyShape ; + sh:path sh:deactivated ; + sh:description "Can be used to deactivate the whole constraint." ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:name "deactivated" ; + sh:order "1"^^xsd:decimal ; +. +tosh:ShapeShape-severity + rdf:type sh:PropertyShape ; + sh:path sh:severity ; + tosh:editWidget swa:InstancesSelectEditor ; + sh:class sh:Severity ; + sh:description "The severity to be used for validation results produced by the associated constraint." ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:name "severity" ; + sh:order "2"^^xsd:decimal ; +. +tosh:StringBasedConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "String Constraints" ; + sh:order 7 ; +. +tosh:SystemNamespaceShape + rdf:type 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 [ + rdf:type 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:UseDeclaredDatatypeConstraintComponent + rdf:type sh:ConstraintComponent ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Change datatype of the invalid value to the specified sh:datatype" ; + 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 "Use declared datatype constraint component" ; + sh:parameter [ + sh:path tosh:useDeclaredDatatype ; + sh:datatype xsd:boolean ; + sh:description "True to state that the datatype of literal values must be the same as the declared sh:datatype." ; + sh:name "use declared datatype" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Datatype must match the declared datatype {?datatype}" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?datatype + WHERE { + { + FILTER ($useDeclaredDatatype) + } + $this sh:datatype ?datatype . + $this $PATH ?value . + FILTER (isLiteral(?value) && datatype(?value) != ?datatype) . + }""" ; + ] ; + sh:targetClass sh:PropertyShape ; +. +tosh:ValueRangeConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Value Range" ; + sh:order 5 ; +. +tosh:ValueTypeConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:editGroupDescription "Hint: Use \"or\" under Complex Constraints to represent choices between multiple value types." ; + rdfs:comment "A property group for constraint parameters that restrict the value types of values." ; + rdfs:label "Value Type" ; + sh:order 3 ; +. +tosh:countShapesWithMatchResult + rdf:type 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." ; + rdfs:label "count shapes with match result" ; + sh:parameter [ + sh:path sh:expectedValue ; + sh:datatype xsd:boolean ; + sh:description "The expected value of tosh:hasShape to count." ; + sh:order 3 ; + ] ; + sh:parameter [ + sh:path sh:focusNode ; + sh:class rdfs:Resource ; + sh:description "The focus node." ; + sh:order 0 ; + ] ; + sh:parameter [ + sh:path sh:shapes ; + sh:class rdf:List ; + sh:description "The list of shapes to walk through." ; + sh:order 1 ; + ] ; + sh:parameter [ + sh:path sh:shapesGraph ; + sh:class rdfs:Resource ; + sh:description "The shapes graph." ; + sh:order 2 ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType xsd:integer ; + sh:select """ + # The SUM will fail with an error if one of the operands is not a number + # (this mechanism is used to propagate errors from tosh:hasShape calls) + SELECT (SUM(?s) AS ?result) + WHERE { + GRAPH $shapesGraph { + $shapes rdf:rest*/rdf:first ?shape . + } + BIND (tosh:hasShape($focusNode, ?shape, true) AS ?hasShape) . + BIND (IF(bound(?hasShape), IF(?hasShape = $expectedValue, 1, 0), 'error') AS ?s) . + } + """ ; +. +tosh:editGroupDescription + rdf:type rdf:Property ; + rdfs:comment "A description of the property group when in \"edit\" mode." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "edit group description" ; + rdfs:range xsd:string ; +. +tosh:editWidget + rdf:type rdf:Property ; + rdfs:label "edit widget" ; + rdfs:range swa:ObjectEditorClass ; +. +tosh:hasDatatype + rdf:type sh:SPARQLAskValidator ; + rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; + rdfs:label "has datatype" ; + sh:ask """ + ASK { + FILTER (datatype($value) = $datatype && spif:isValidForDatatype($value, $datatype)) . + } + """ ; + sh:prefixes <http://topbraid.org/tosh> ; +. +tosh:hasShape + rdf:type sh:Function ; + rdfs:comment """A built-in function of the TopBraid SHACL implementation. + Can be used to validate a given (focus) node against a given shape, + returning <code>true</code> if the node is valid. + + If executed within a SHACL validation engine, this uses the shapes graph that was provided when the engine started. + If executed in other contexts, e.g. in a stand-alone SPARQL query, the function attempts to use the URI of the current + default graph as the shapes graph. This may not always be supported. If called from within an SWP engine, the + shapes graph is the current query graph."""^^rdf:HTML ; + rdfs:label "has shape" ; + sh:parameter [ + sh:path tosh:node ; + sh:description "The node to validate." ; + ] ; + sh:parameter [ + sh:path tosh:shape ; + sh:description "The shape that the node is supposed to have." ; + ] ; + sh:returnType xsd:boolean ; +. +tosh:isInTargetOf + rdf:type sh:Function ; + rdfs:comment "Checks whether a given node is in the target of a given shape." ; + rdfs:label "is in target of" ; + sh:parameter [ + sh:path tosh:node ; + sh:description "The node to check." ; + sh:name "node" ; + ] ; + sh:parameter [ + sh:path tosh:shape ; + sh:class sh:Shape ; + sh:description "The shape that the node is supposed to be in the target of." ; + sh:name "shape" ; + ] ; + sh:returnType xsd:boolean ; +. +tosh:open + rdf:type rdf:Property ; + rdfs:comment "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:domain sh:PropertyGroup ; + rdfs:label "open" ; + rdfs:range xsd:boolean ; +. +tosh:openable + rdf:type rdf:Property ; + rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "openable" ; + rdfs:range xsd:boolean ; +. +tosh:searchWidget + rdf:type rdf:Property ; + rdfs:label "search widget" ; + rdfs:range swa:ObjectFacetClass ; +. +tosh:shaclExists + rdf:type sh:Function ; + rdfs:comment "Checks whether the current query graph has SHACL activated, i.e. imports the triples typically found in the SHACL namespace. This is currently relying on an approximation, only certain triples, and is natively implemented for TopBraid. Future versions may expose the actual logic as a SPARQL query." ; + rdfs:label "SHACL exists" ; + sh:returnType xsd:boolean ; +. +tosh:systemNamespace + rdf:type rdf:Property ; + rdfs:comment "Can be used to mark namespace resources (subjects) to count as \"system namespace\" that should be filtered by tosh:SystemNamespaceShape. Search for the usage of this predicate for examples. Anyone can add their own namespaces to their graphs." ; + rdfs:label "system namespace" ; + rdfs:range xsd:boolean ; +. +tosh:validatorForContext + rdf:type sh:SPARQLFunction ; + rdfs:comment "Gets a suitable validator for a given context, following the resolution rules from the spec." ; + rdfs:label "validator for context" ; + sh:parameter [ + sh:path tosh:component ; + sh:class sh:ConstraintComponent ; + sh:description "The constraint component." ; + sh:name "component" ; + ] ; + sh:parameter [ + sh:path tosh:context ; + sh:class rdfs:Class ; + sh:description "The context, e.g. sh:PropertyShape." ; + sh:name "context" ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType sh:Validator ; + sh:select """ + SELECT ?validator + WHERE { + { + BIND (IF($context = sh:PropertyShape, sh:propertyValidator, sh:nodeValidator) AS ?predicate) . + } + OPTIONAL { + $component ?predicate ?specialized . + } + OPTIONAL { + $component sh:validator ?default . + } + BIND (COALESCE(?specialized, ?default) AS ?validator) . + }""" ; +. +tosh:valuesWithShapeCount + rdf:type sh:SPARQLFunction ; + rdfs:comment "Counts the number of values from a given subject (?arg1) / predicate (?arg2) combination that do not produce any error-level constraint violations for a given shape (?arg3) in a given shapes graph (?arg4). The function produces an error if one of the shapes validated to a fatal error." ; + rdfs:label "values with shape count" ; + sh:parameter [ + sh:path dash:arg1 ; + sh:class rdfs:Resource ; + sh:description "The subject to count the values of." ; + ] ; + sh:parameter [ + sh:path dash:arg2 ; + sh:class rdf:Property ; + sh:description "The property to count the values of." ; + ] ; + sh:parameter [ + sh:path dash:arg3 ; + sh:class sh:Shape ; + sh:description "The shape to validate." ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType xsd:integer ; + sh:select """ + # The SUM will fail with an error if one of the operands is not a number + # (this mechanism is used to propagate errors from tosh:hasShape calls) + SELECT (SUM(?s) AS ?result) + WHERE { + { + FILTER NOT EXISTS { $arg1 $arg2 ?value } + BIND (0 AS ?s) + } + UNION { + FILTER EXISTS { $arg1 $arg2 ?value } + $arg1 $arg2 ?value . + BIND (tosh:hasShape(?value, $arg3, true) AS ?hasShape) . + BIND (IF(bound(?hasShape), IF(?hasShape, 1, 0), 'error') AS ?s) . + } + } + """ ; +. +tosh:viewGroupDescription + rdf:type rdf:Property ; + rdfs:comment "A description of the property group when in \"view\" mode." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "view group description" ; + rdfs:range xsd:string ; +. +tosh:viewWidget + rdf:type rdf:Property ; + rdfs:label "view widget" ; + rdfs:range swa:ObjectViewerClass ; +. +rdf: + tosh:systemNamespace "true"^^xsd:boolean ; +. +rdfs: + tosh:systemNamespace "true"^^xsd:boolean ; +. +xsd: + tosh:systemNamespace "true"^^xsd:boolean ; +. +owl: + tosh:systemNamespace "true"^^xsd:boolean ; +. +sh: + tosh:systemNamespace "true"^^xsd:boolean ; +. +sh:AndConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $and, $shapesGraph, false) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count > 0) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $and, $shapesGraph, false) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count > 0) . + } +""" ; + ] ; +. +sh:AndConstraintComponent-and + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 11 ; +. +sh:ClassConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +sh:ClassConstraintComponent-class + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:order 2 ; +. +sh:ClosedConstraintComponent-closed + sh:group tosh:OtherConstraintPropertyGroup ; + sh:order "0"^^xsd:decimal ; +. +sh:ClosedConstraintComponent-ignoredProperties + sh:group tosh:OtherConstraintPropertyGroup ; + sh:order "1"^^xsd:decimal ; +. +sh:DatatypeConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Change the datatype of the invalid value to {$datatype}" ; + sh:order -2 ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate ?newValue . +} +WHERE { + BIND (spif:invoke($datatype, str($value)) AS ?newValue) . + FILTER bound(?newValue) . +}""" ; + ] ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Convert the invalid date/time value into a date value" ; + sh:order -1 ; + sh:update """DELETE { + $subject $predicate $object +} +INSERT { + $subject $predicate ?newObject . +} +WHERE { + { + FILTER (datatype($object) = xsd:dateTime && $datatype = xsd:date) . + } + BIND (xsd:date(substr(str($object), 1, 10)) AS ?newObject) . + FILTER bound(?newObject) . +}""" ; + ] ; + sh:validator tosh:hasDatatype ; +. +sh:DatatypeConstraintComponent-datatype + tosh:editWidget <http://topbraid.org/tosh.ui#DatatypeEditor> ; + sh:class rdfs:Datatype ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 1 ; +. +sh:DisjointConstraintComponent-disjoint + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 1 ; +. +sh:EqualsConstraintComponent-equals + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 0 ; +. +sh:HasValueConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Add {$hasValue} to the existing values" ; + sh:update """INSERT { + $focusNode $predicate $hasValue . +} +WHERE { +}""" ; + ] ; + sh:property [ + sh:path sh:hasValue ; + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + ] ; +. +sh:HasValueConstraintComponent-hasValue + sh:group tosh:OtherConstraintPropertyGroup ; +. +sh:InConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace invalid value with {$newObject}" ; + sh:order 2 ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """SELECT ?newObject +WHERE { + $in <http://jena.hpl.hp.com/ARQ/list#index> (?index ?newObject ) . +} +ORDER BY ?index""" ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate $newObject . +} +WHERE { +}""" ; + ] ; +. +sh:InConstraintComponent-in + sh:group tosh:OtherConstraintPropertyGroup ; +. +sh:JSConstraint-js + sh:group tosh:ComplexConstraintPropertyGroup ; +. +sh:LanguageInConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +sh:LanguageInConstraintComponent-languageIn + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order "9"^^xsd:decimal ; + sh:property [ + sh:path ( + [ + sh:zeroOrMorePath rdf:rest ; + ] + rdf:first + ) ; + sh:datatype xsd:string ; + sh:minLength 1 ; + ] ; +. +sh:LessThanConstraintComponent-lessThan + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 2 ; +. +sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 3 ; +. +sh:MaxCountConstraintComponent-maxCount + sh:group tosh:CardinalityConstraintPropertyGroup ; + sh:order 1 ; +. +sh:MaxExclusiveConstraintComponent-maxExclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 3 ; +. +sh:MaxInclusiveConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace the invalid value with {$maxInclusive}" ; + sh:update """DELETE { + $subject $predicate $object . +} +INSERT { + $subject $predicate $maxInclusive . +} +WHERE { +}""" ; + ] ; +. +sh:MaxInclusiveConstraintComponent-maxInclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 2 ; +. +sh:MaxLengthConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Prune string to only {$maxLength} characters" ; + sh:order 1 ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate $newValue . +} +WHERE { + FILTER (isLiteral($value) && datatype($value) = xsd:string) . + BIND (SUBSTR($value, 1, $maxLength) AS ?newValue) . +}""" ; + ] ; +. +sh:MaxLengthConstraintComponent-maxLength + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 4 ; +. +sh:MinCountConstraintComponent-minCount + sh:group tosh:CardinalityConstraintPropertyGroup ; + sh:order 0 ; +. +sh:MinExclusiveConstraintComponent-minExclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 0 ; +. +sh:MinInclusiveConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace the invalid value with {$minInclusive}" ; + sh:update """DELETE { + $subject $predicate $object . +} +INSERT { + $subject $predicate $minInclusive . +} +WHERE { +}""" ; + ] ; +. +sh:MinInclusiveConstraintComponent-minInclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 1 ; +. +sh:MinLengthConstraintComponent-minLength + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 3 ; +. +sh:NodeConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ($this AS $value) ?failure + WHERE { + BIND (tosh:hasShape($this, $node) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || !?hasShape) . + } + """ ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:hasShape(?value, $node) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || !?hasShape) . + } + """ ; + ] ; +. +sh:NodeConstraintComponent-node + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 0 ; +. +sh:NodeKindConstraintComponent-nodeKind + tosh:editWidget <http://topbraid.org/tosh.ui#NodeKindEditor> ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:name "value kinds" ; + sh:order 0 ; +. +sh:NotConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ($this AS ?value) ?failure + WHERE { + BIND (tosh:hasShape($this, $not) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || ?hasShape) . + } + """ ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:hasShape(?value, $not) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || ?hasShape) . + } + """ ; + ] ; +. +sh:NotConstraintComponent-not + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 10 ; +. +sh:OrConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Focus node has none of the shapes from the 'or' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $or, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count = 0) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Value has none of the shapes from the 'or' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $or, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count = 0) . + } +""" ; + ] ; +. +sh:OrConstraintComponent-or + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 12 ; +. +sh:PatternConstraintComponent-flags + tosh:editWidget <http://topbraid.org/tosh.ui#FlagsEditor> ; + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:name "regex flags" ; +. +sh:PatternConstraintComponent-pattern + tosh:editWidget swa:PlainTextFieldEditor ; + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:name "regex pattern" ; + sh:sparql [ + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """SELECT $this ?value ?message +WHERE { + $this $PATH ?value . + BIND (spif:checkRegexSyntax(?value) AS ?error) . + FILTER bound(?error) . + BIND (CONCAT(\"Malformed pattern: \", ?error) AS ?message) . +}""" ; + ] ; +. +sh:QualifiedMaxCountConstraintComponent-qualifiedMaxCount + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 3 ; +. +sh:QualifiedMinCountConstraintComponent-qualifiedMinCount + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 2 ; +. +sh:QualifiedMinCountConstraintComponent-qualifiedValueShape + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 1 ; +. +sh:UniqueLangConstraintComponent-uniqueLang + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 8 ; +. +sh:XoneConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Focus node has {?count} of the shapes from the 'exactly one' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ?count ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $xone, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count != 1) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Value node has {?count} of the shapes from the 'exactly one' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure ?count + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $xone, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count != 1) . + } +""" ; + ] ; +. +sh:XoneConstraintComponent-xone + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 13 ; +.
1,032
Adding removed resources for Java tests
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
57
<NME> tosh.ttl <BEF> ADDFILE <MSG> Adding removed resources for Java tests <DFF> @@ -0,0 +1,1032 @@ +# baseURI: http://topbraid.org/tosh +# imports: http://datashapes.org/dash +# prefix: tosh + +@prefix dash: <http://datashapes.org/dash#> . +@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"^^xsd:boolean ; +. +dash:ClosedByTypesConstraintComponent-closedByTypes + sh:group tosh:OtherConstraintPropertyGroup ; +. +dash:NonRecursiveConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + sh:property [ + sh:path dash:nonRecursive ; + sh:group tosh:RelationshipPropertyGroup ; + ] ; +. +dash:RootClassConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +dash:StemConstraintComponent-stem + sh:group tosh:StringBasedConstraintPropertyGroup ; +. +<http://spinrdf.org/sp#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://spinrdf.org/spin#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://spinrdf.org/spl#> + tosh:systemNamespace "true"^^xsd:boolean ; +. +<http://topbraid.org/tosh> + rdf:type owl:Ontology ; + rdfs:comment """A collection of SHACL features that are used whenever SHACL graphs are used within TopBraid Suite products. This includes things like suggested PropertyGroups and Shapes that control the layout of forms. Some of these may be of general use outside of TopBraid too. + +This namespace also includes the function tosh:hasShape, which can be used to implement some advanced constraint components using SPARQL only.""" ; + rdfs:label "TopBraid Data Shapes Library" ; + owl:imports <http://datashapes.org/dash> ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; + sh:prefix "afn" ; + ] ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; + sh:prefix "spif" ; + ] ; + sh:declare [ + rdf:type sh:PrefixDeclaration ; + sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; + sh:prefix "tosh" ; + ] ; +. +tosh: + tosh:systemNamespace "true"^^xsd:boolean ; +. +tosh:AboutPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "This Shape" ; + sh:order 0 ; +. +tosh:CardinalityConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "Cardinality" ; + sh:order 2 ; +. +tosh:ComplexConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Complex Constraints" ; + sh:order 9 ; +. +tosh:ConstraintMetadataPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:label "Constraint Metadata" ; +. +tosh:DeleteTripleSuggestionGenerator + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + rdfs:label "Delete triple suggestion generator" ; + sh:message "Delete the invalid statement" ; + sh:update """DELETE { + $focusNode $predicate $value . +} +WHERE { +}""" ; +. +tosh:DisplayPropertyGroup + rdf:type sh:PropertyGroup ; + rdfs:comment "A group for properties that are primarily for display purposes (names, ordering etc)." ; + rdfs:label "Display" ; + sh:order 1 ; +. +tosh:MemberShapeConstraintComponent + rdf:type 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 [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "List member {?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 + rdf:type 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:OtherConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Other Constraints" ; + sh:order 10 ; +. +tosh:PropertyGroupShape + rdf:type sh:NodeShape ; + rdfs:label "Property group shape" ; + sh:property [ + sh:path sh:order ; + sh:maxCount 1 ; + ] ; + sh:targetClass sh:PropertyGroup ; +. +tosh:PropertyPairConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Property Pairs" ; + sh:order 6 ; +. +tosh:PropertyShapeShape + rdf:type sh:NodeShape ; + rdfs:label "Property shape shape" ; + sh:property [ + sh:path tosh:editWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectEditorClass that shall be used to edit values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "edit widget" ; + sh:nodeKind sh:IRI ; + sh:order 21 ; + ] ; + sh:property [ + sh:path tosh:searchWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectFacetClass that shall be used to search for values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "search widget" ; + sh:nodeKind sh:IRI ; + sh:order 22 ; + ] ; + sh:property [ + sh:path tosh:viewWidget ; + tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; + tosh:viewWidget swa:ResourceInUIGraphViewer ; + sh:description "The swa:ObjectViewerClass that shall be used to view values of this predicate." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "view widget" ; + sh:nodeKind sh:IRI ; + sh:order 20 ; + ] ; + sh:property [ + sh:path sh:defaultValue ; + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:description "The default value to be used for this property at new instances." ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + ] ; + sh:property [ + sh:path sh:description ; + tosh:editWidget swa:TextAreaEditor ; + sh:description "A human-readable description of the role of the property in the constraint." ; + sh:group tosh:DisplayPropertyGroup ; + sh:name "description" ; + sh:order 2 ; + ] ; + sh:property [ + sh:path sh:group ; + sh:description "The sh:PropertyGroup that the property belongs to." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "group" ; + sh:order 10 ; + ] ; + sh:property [ + sh:path sh:name ; + tosh:editWidget swa:TextFieldEditorWithLang ; + sh:description "The display name of the property." ; + sh:group tosh:DisplayPropertyGroup ; + sh:name "name" ; + sh:order 1 ; + ] ; + sh:property [ + sh:path sh:order ; + sh:description "The relative position of the property among its peers, e.g. a property with order 5 shows up before one with order 6." ; + sh:group tosh:DisplayPropertyGroup ; + sh:maxCount 1 ; + sh:name "order" ; + sh:order 11 ; + ] ; + sh:property [ + sh:path sh:path ; + tosh:editWidget <http://topbraid.org/tosh.ui#PathEditor> ; + tosh:viewWidget <http://topbraid.org/tosh.ui#PathViewer> ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:minCount 1 ; + sh:name "on property" ; + sh:order 0 ; + ] ; + sh:targetClass sh:PropertyShape ; +. +tosh:RelationshipPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Relationship" ; + sh:order 8 ; +. +tosh:ShapeShape + rdf:type sh:NodeShape ; + rdfs:label "Shape of shapes" ; + sh:property tosh:ShapeShape-deactivated ; + sh:property tosh:ShapeShape-severity ; + sh:targetClass sh:Shape ; +. +tosh:ShapeShape-deactivated + rdf:type sh:PropertyShape ; + sh:path sh:deactivated ; + sh:description "Can be used to deactivate the whole constraint." ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:name "deactivated" ; + sh:order "1"^^xsd:decimal ; +. +tosh:ShapeShape-severity + rdf:type sh:PropertyShape ; + sh:path sh:severity ; + tosh:editWidget swa:InstancesSelectEditor ; + sh:class sh:Severity ; + sh:description "The severity to be used for validation results produced by the associated constraint." ; + sh:group tosh:AboutPropertyGroup ; + sh:maxCount 1 ; + sh:name "severity" ; + sh:order "2"^^xsd:decimal ; +. +tosh:StringBasedConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "String Constraints" ; + sh:order 7 ; +. +tosh:SystemNamespaceShape + rdf:type 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 [ + rdf:type 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:UseDeclaredDatatypeConstraintComponent + rdf:type sh:ConstraintComponent ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Change datatype of the invalid value to the specified sh:datatype" ; + 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 "Use declared datatype constraint component" ; + sh:parameter [ + sh:path tosh:useDeclaredDatatype ; + sh:datatype xsd:boolean ; + sh:description "True to state that the datatype of literal values must be the same as the declared sh:datatype." ; + sh:name "use declared datatype" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Datatype must match the declared datatype {?datatype}" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?datatype + WHERE { + { + FILTER ($useDeclaredDatatype) + } + $this sh:datatype ?datatype . + $this $PATH ?value . + FILTER (isLiteral(?value) && datatype(?value) != ?datatype) . + }""" ; + ] ; + sh:targetClass sh:PropertyShape ; +. +tosh:ValueRangeConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:openable "true"^^xsd:boolean ; + rdfs:label "Value Range" ; + sh:order 5 ; +. +tosh:ValueTypeConstraintPropertyGroup + rdf:type sh:PropertyGroup ; + tosh:editGroupDescription "Hint: Use \"or\" under Complex Constraints to represent choices between multiple value types." ; + rdfs:comment "A property group for constraint parameters that restrict the value types of values." ; + rdfs:label "Value Type" ; + sh:order 3 ; +. +tosh:countShapesWithMatchResult + rdf:type 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." ; + rdfs:label "count shapes with match result" ; + sh:parameter [ + sh:path sh:expectedValue ; + sh:datatype xsd:boolean ; + sh:description "The expected value of tosh:hasShape to count." ; + sh:order 3 ; + ] ; + sh:parameter [ + sh:path sh:focusNode ; + sh:class rdfs:Resource ; + sh:description "The focus node." ; + sh:order 0 ; + ] ; + sh:parameter [ + sh:path sh:shapes ; + sh:class rdf:List ; + sh:description "The list of shapes to walk through." ; + sh:order 1 ; + ] ; + sh:parameter [ + sh:path sh:shapesGraph ; + sh:class rdfs:Resource ; + sh:description "The shapes graph." ; + sh:order 2 ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType xsd:integer ; + sh:select """ + # The SUM will fail with an error if one of the operands is not a number + # (this mechanism is used to propagate errors from tosh:hasShape calls) + SELECT (SUM(?s) AS ?result) + WHERE { + GRAPH $shapesGraph { + $shapes rdf:rest*/rdf:first ?shape . + } + BIND (tosh:hasShape($focusNode, ?shape, true) AS ?hasShape) . + BIND (IF(bound(?hasShape), IF(?hasShape = $expectedValue, 1, 0), 'error') AS ?s) . + } + """ ; +. +tosh:editGroupDescription + rdf:type rdf:Property ; + rdfs:comment "A description of the property group when in \"edit\" mode." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "edit group description" ; + rdfs:range xsd:string ; +. +tosh:editWidget + rdf:type rdf:Property ; + rdfs:label "edit widget" ; + rdfs:range swa:ObjectEditorClass ; +. +tosh:hasDatatype + rdf:type sh:SPARQLAskValidator ; + rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; + rdfs:label "has datatype" ; + sh:ask """ + ASK { + FILTER (datatype($value) = $datatype && spif:isValidForDatatype($value, $datatype)) . + } + """ ; + sh:prefixes <http://topbraid.org/tosh> ; +. +tosh:hasShape + rdf:type sh:Function ; + rdfs:comment """A built-in function of the TopBraid SHACL implementation. + Can be used to validate a given (focus) node against a given shape, + returning <code>true</code> if the node is valid. + + If executed within a SHACL validation engine, this uses the shapes graph that was provided when the engine started. + If executed in other contexts, e.g. in a stand-alone SPARQL query, the function attempts to use the URI of the current + default graph as the shapes graph. This may not always be supported. If called from within an SWP engine, the + shapes graph is the current query graph."""^^rdf:HTML ; + rdfs:label "has shape" ; + sh:parameter [ + sh:path tosh:node ; + sh:description "The node to validate." ; + ] ; + sh:parameter [ + sh:path tosh:shape ; + sh:description "The shape that the node is supposed to have." ; + ] ; + sh:returnType xsd:boolean ; +. +tosh:isInTargetOf + rdf:type sh:Function ; + rdfs:comment "Checks whether a given node is in the target of a given shape." ; + rdfs:label "is in target of" ; + sh:parameter [ + sh:path tosh:node ; + sh:description "The node to check." ; + sh:name "node" ; + ] ; + sh:parameter [ + sh:path tosh:shape ; + sh:class sh:Shape ; + sh:description "The shape that the node is supposed to be in the target of." ; + sh:name "shape" ; + ] ; + sh:returnType xsd:boolean ; +. +tosh:open + rdf:type rdf:Property ; + rdfs:comment "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:domain sh:PropertyGroup ; + rdfs:label "open" ; + rdfs:range xsd:boolean ; +. +tosh:openable + rdf:type rdf:Property ; + rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "openable" ; + rdfs:range xsd:boolean ; +. +tosh:searchWidget + rdf:type rdf:Property ; + rdfs:label "search widget" ; + rdfs:range swa:ObjectFacetClass ; +. +tosh:shaclExists + rdf:type sh:Function ; + rdfs:comment "Checks whether the current query graph has SHACL activated, i.e. imports the triples typically found in the SHACL namespace. This is currently relying on an approximation, only certain triples, and is natively implemented for TopBraid. Future versions may expose the actual logic as a SPARQL query." ; + rdfs:label "SHACL exists" ; + sh:returnType xsd:boolean ; +. +tosh:systemNamespace + rdf:type rdf:Property ; + rdfs:comment "Can be used to mark namespace resources (subjects) to count as \"system namespace\" that should be filtered by tosh:SystemNamespaceShape. Search for the usage of this predicate for examples. Anyone can add their own namespaces to their graphs." ; + rdfs:label "system namespace" ; + rdfs:range xsd:boolean ; +. +tosh:validatorForContext + rdf:type sh:SPARQLFunction ; + rdfs:comment "Gets a suitable validator for a given context, following the resolution rules from the spec." ; + rdfs:label "validator for context" ; + sh:parameter [ + sh:path tosh:component ; + sh:class sh:ConstraintComponent ; + sh:description "The constraint component." ; + sh:name "component" ; + ] ; + sh:parameter [ + sh:path tosh:context ; + sh:class rdfs:Class ; + sh:description "The context, e.g. sh:PropertyShape." ; + sh:name "context" ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType sh:Validator ; + sh:select """ + SELECT ?validator + WHERE { + { + BIND (IF($context = sh:PropertyShape, sh:propertyValidator, sh:nodeValidator) AS ?predicate) . + } + OPTIONAL { + $component ?predicate ?specialized . + } + OPTIONAL { + $component sh:validator ?default . + } + BIND (COALESCE(?specialized, ?default) AS ?validator) . + }""" ; +. +tosh:valuesWithShapeCount + rdf:type sh:SPARQLFunction ; + rdfs:comment "Counts the number of values from a given subject (?arg1) / predicate (?arg2) combination that do not produce any error-level constraint violations for a given shape (?arg3) in a given shapes graph (?arg4). The function produces an error if one of the shapes validated to a fatal error." ; + rdfs:label "values with shape count" ; + sh:parameter [ + sh:path dash:arg1 ; + sh:class rdfs:Resource ; + sh:description "The subject to count the values of." ; + ] ; + sh:parameter [ + sh:path dash:arg2 ; + sh:class rdf:Property ; + sh:description "The property to count the values of." ; + ] ; + sh:parameter [ + sh:path dash:arg3 ; + sh:class sh:Shape ; + sh:description "The shape to validate." ; + ] ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:returnType xsd:integer ; + sh:select """ + # The SUM will fail with an error if one of the operands is not a number + # (this mechanism is used to propagate errors from tosh:hasShape calls) + SELECT (SUM(?s) AS ?result) + WHERE { + { + FILTER NOT EXISTS { $arg1 $arg2 ?value } + BIND (0 AS ?s) + } + UNION { + FILTER EXISTS { $arg1 $arg2 ?value } + $arg1 $arg2 ?value . + BIND (tosh:hasShape(?value, $arg3, true) AS ?hasShape) . + BIND (IF(bound(?hasShape), IF(?hasShape, 1, 0), 'error') AS ?s) . + } + } + """ ; +. +tosh:viewGroupDescription + rdf:type rdf:Property ; + rdfs:comment "A description of the property group when in \"view\" mode." ; + rdfs:domain sh:PropertyGroup ; + rdfs:label "view group description" ; + rdfs:range xsd:string ; +. +tosh:viewWidget + rdf:type rdf:Property ; + rdfs:label "view widget" ; + rdfs:range swa:ObjectViewerClass ; +. +rdf: + tosh:systemNamespace "true"^^xsd:boolean ; +. +rdfs: + tosh:systemNamespace "true"^^xsd:boolean ; +. +xsd: + tosh:systemNamespace "true"^^xsd:boolean ; +. +owl: + tosh:systemNamespace "true"^^xsd:boolean ; +. +sh: + tosh:systemNamespace "true"^^xsd:boolean ; +. +sh:AndConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $and, $shapesGraph, false) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count > 0) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $and, $shapesGraph, false) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count > 0) . + } +""" ; + ] ; +. +sh:AndConstraintComponent-and + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 11 ; +. +sh:ClassConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +sh:ClassConstraintComponent-class + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:order 2 ; +. +sh:ClosedConstraintComponent-closed + sh:group tosh:OtherConstraintPropertyGroup ; + sh:order "0"^^xsd:decimal ; +. +sh:ClosedConstraintComponent-ignoredProperties + sh:group tosh:OtherConstraintPropertyGroup ; + sh:order "1"^^xsd:decimal ; +. +sh:DatatypeConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Change the datatype of the invalid value to {$datatype}" ; + sh:order -2 ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate ?newValue . +} +WHERE { + BIND (spif:invoke($datatype, str($value)) AS ?newValue) . + FILTER bound(?newValue) . +}""" ; + ] ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Convert the invalid date/time value into a date value" ; + sh:order -1 ; + sh:update """DELETE { + $subject $predicate $object +} +INSERT { + $subject $predicate ?newObject . +} +WHERE { + { + FILTER (datatype($object) = xsd:dateTime && $datatype = xsd:date) . + } + BIND (xsd:date(substr(str($object), 1, 10)) AS ?newObject) . + FILTER bound(?newObject) . +}""" ; + ] ; + sh:validator tosh:hasDatatype ; +. +sh:DatatypeConstraintComponent-datatype + tosh:editWidget <http://topbraid.org/tosh.ui#DatatypeEditor> ; + sh:class rdfs:Datatype ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 1 ; +. +sh:DisjointConstraintComponent-disjoint + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 1 ; +. +sh:EqualsConstraintComponent-equals + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 0 ; +. +sh:HasValueConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Add {$hasValue} to the existing values" ; + sh:update """INSERT { + $focusNode $predicate $hasValue . +} +WHERE { +}""" ; + ] ; + sh:property [ + sh:path sh:hasValue ; + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + ] ; +. +sh:HasValueConstraintComponent-hasValue + sh:group tosh:OtherConstraintPropertyGroup ; +. +sh:InConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace invalid value with {$newObject}" ; + sh:order 2 ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """SELECT ?newObject +WHERE { + $in <http://jena.hpl.hp.com/ARQ/list#index> (?index ?newObject ) . +} +ORDER BY ?index""" ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate $newObject . +} +WHERE { +}""" ; + ] ; +. +sh:InConstraintComponent-in + sh:group tosh:OtherConstraintPropertyGroup ; +. +sh:JSConstraint-js + sh:group tosh:ComplexConstraintPropertyGroup ; +. +sh:LanguageInConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; +. +sh:LanguageInConstraintComponent-languageIn + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order "9"^^xsd:decimal ; + sh:property [ + sh:path ( + [ + sh:zeroOrMorePath rdf:rest ; + ] + rdf:first + ) ; + sh:datatype xsd:string ; + sh:minLength 1 ; + ] ; +. +sh:LessThanConstraintComponent-lessThan + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 2 ; +. +sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals + sh:deactivated "true"^^xsd:boolean ; + sh:group tosh:PropertyPairConstraintPropertyGroup ; + sh:order 3 ; +. +sh:MaxCountConstraintComponent-maxCount + sh:group tosh:CardinalityConstraintPropertyGroup ; + sh:order 1 ; +. +sh:MaxExclusiveConstraintComponent-maxExclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 3 ; +. +sh:MaxInclusiveConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace the invalid value with {$maxInclusive}" ; + sh:update """DELETE { + $subject $predicate $object . +} +INSERT { + $subject $predicate $maxInclusive . +} +WHERE { +}""" ; + ] ; +. +sh:MaxInclusiveConstraintComponent-maxInclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 2 ; +. +sh:MaxLengthConstraintComponent + dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Prune string to only {$maxLength} characters" ; + sh:order 1 ; + sh:update """DELETE { + $focusNode $predicate $value . +} +INSERT { + $focusNode $predicate $newValue . +} +WHERE { + FILTER (isLiteral($value) && datatype($value) = xsd:string) . + BIND (SUBSTR($value, 1, $maxLength) AS ?newValue) . +}""" ; + ] ; +. +sh:MaxLengthConstraintComponent-maxLength + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 4 ; +. +sh:MinCountConstraintComponent-minCount + sh:group tosh:CardinalityConstraintPropertyGroup ; + sh:order 0 ; +. +sh:MinExclusiveConstraintComponent-minExclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 0 ; +. +sh:MinInclusiveConstraintComponent + dash:propertySuggestionGenerator [ + rdf:type dash:SPARQLUpdateSuggestionGenerator ; + sh:message "Replace the invalid value with {$minInclusive}" ; + sh:update """DELETE { + $subject $predicate $object . +} +INSERT { + $subject $predicate $minInclusive . +} +WHERE { +}""" ; + ] ; +. +sh:MinInclusiveConstraintComponent-minInclusive + tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; + tosh:useDeclaredDatatype "true"^^xsd:boolean ; + sh:group tosh:ValueRangeConstraintPropertyGroup ; + sh:order 1 ; +. +sh:MinLengthConstraintComponent-minLength + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 3 ; +. +sh:NodeConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ($this AS $value) ?failure + WHERE { + BIND (tosh:hasShape($this, $node) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || !?hasShape) . + } + """ ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:hasShape(?value, $node) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || !?hasShape) . + } + """ ; + ] ; +. +sh:NodeConstraintComponent-node + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 0 ; +. +sh:NodeKindConstraintComponent-nodeKind + tosh:editWidget <http://topbraid.org/tosh.ui#NodeKindEditor> ; + sh:group tosh:ValueTypeConstraintPropertyGroup ; + sh:name "value kinds" ; + sh:order 0 ; +. +sh:NotConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ($this AS ?value) ?failure + WHERE { + BIND (tosh:hasShape($this, $not) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || ?hasShape) . + } + """ ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:hasShape(?value, $not) AS ?hasShape) . + BIND (!bound(?hasShape) AS ?failure) . + FILTER (?failure || ?hasShape) . + } + """ ; + ] ; +. +sh:NotConstraintComponent-not + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 10 ; +. +sh:OrConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Focus node has none of the shapes from the 'or' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $or, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count = 0) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Value has none of the shapes from the 'or' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $or, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count = 0) . + } +""" ; + ] ; +. +sh:OrConstraintComponent-or + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 12 ; +. +sh:PatternConstraintComponent-flags + tosh:editWidget <http://topbraid.org/tosh.ui#FlagsEditor> ; + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:name "regex flags" ; +. +sh:PatternConstraintComponent-pattern + tosh:editWidget swa:PlainTextFieldEditor ; + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:name "regex pattern" ; + sh:sparql [ + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """SELECT $this ?value ?message +WHERE { + $this $PATH ?value . + BIND (spif:checkRegexSyntax(?value) AS ?error) . + FILTER bound(?error) . + BIND (CONCAT(\"Malformed pattern: \", ?error) AS ?message) . +}""" ; + ] ; +. +sh:QualifiedMaxCountConstraintComponent-qualifiedMaxCount + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 3 ; +. +sh:QualifiedMinCountConstraintComponent-qualifiedMinCount + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 2 ; +. +sh:QualifiedMinCountConstraintComponent-qualifiedValueShape + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:maxCount 1 ; + sh:order 1 ; +. +sh:UniqueLangConstraintComponent-uniqueLang + sh:group tosh:StringBasedConstraintPropertyGroup ; + sh:order 8 ; +. +sh:XoneConstraintComponent + sh:nodeValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Focus node has {?count} of the shapes from the 'exactly one' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT $this ?failure ?count ($this AS ?value) + WHERE { + BIND (tosh:countShapesWithMatchResult($this, $xone, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count != 1) . + } +""" ; + ] ; + sh:propertyValidator [ + rdf:type sh:SPARQLSelectValidator ; + sh:message "Value node has {?count} of the shapes from the 'exactly one' list" ; + sh:prefixes <http://topbraid.org/tosh> ; + sh:select """ + SELECT DISTINCT $this ?value ?failure ?count + WHERE { + $this $PATH ?value . + BIND (tosh:countShapesWithMatchResult(?value, $xone, $shapesGraph, true) AS ?count) + BIND (!bound(?count) AS ?failure) . + FILTER IF(?failure, true, ?count != 1) . + } +""" ; + ] ; +. +sh:XoneConstraintComponent-xone + tosh:editWidget swa:SourceCodeEditor ; + tosh:viewWidget swa:SourceCodeViewer ; + sh:group tosh:ComplexConstraintPropertyGroup ; + sh:order 13 ; +.
1,032
Adding removed resources for Java tests
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
58
<NME> README.md <BEF> # TopBraid SHACL API An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API. Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. The code is totally not optimized for performance, just on correctness. The same code is used in the TopBraid products - which is also why we use this particular Jena version. For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library 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 Please prefix your messages with [SHACL API] To get started, look at the classes ModelConstraintValidator and ResourceConstraintValidator in the package org.topbraid.shacl.constraints. 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> Update README.md <DFF> @@ -1,12 +1,12 @@ # TopBraid SHACL API -An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API. +**An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API.** Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. -The code is totally not optimized for performance, just on correctness. +**The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products - which is also why we use this particular Jena version. For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library @@ -18,4 +18,4 @@ https://groups.google.com/forum/#!forum/topbraid-users Please prefix your messages with [SHACL API] To get started, look at the classes ModelConstraintValidator and ResourceConstraintValidator in -the package org.topbraid.shacl.constraints. +the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidateSquareExampleTest.java)
3
Update README.md
3
.md
md
apache-2.0
TopQuadrant/shacl
59
<NME> README.md <BEF> # TopBraid SHACL API An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API. Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. The code is totally not optimized for performance, just on correctness. The same code is used in the TopBraid products - which is also why we use this particular Jena version. For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library 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 Please prefix your messages with [SHACL API] To get started, look at the classes ModelConstraintValidator and ResourceConstraintValidator in the package org.topbraid.shacl.constraints. 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> Update README.md <DFF> @@ -1,12 +1,12 @@ # TopBraid SHACL API -An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API. +**An open source implementation of the evolving W3C Shapes Constraint Language (SHACL) based on the Jena API.** Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. -The code is totally not optimized for performance, just on correctness. +**The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products - which is also why we use this particular Jena version. For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library @@ -18,4 +18,4 @@ https://groups.google.com/forum/#!forum/topbraid-users Please prefix your messages with [SHACL API] To get started, look at the classes ModelConstraintValidator and ResourceConstraintValidator in -the package org.topbraid.shacl.constraints. +the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidateSquareExampleTest.java)
3
Update README.md
3
.md
md
apache-2.0
TopQuadrant/shacl
60
<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](https://www.w3.org/TR/shacl/) 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 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> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -6,7 +6,8 @@ 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.** + +**The code is not really optimized for performance, just for correctness. An optimized version of the code is used in the TopBraid products such as [TopBraid EDG](https://www.topquadrant.com/products/topbraid-enterprise-data-governance/)** Coverage: * [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
2
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
61
<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](https://www.w3.org/TR/shacl/) 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 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> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -6,7 +6,8 @@ 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.** + +**The code is not really optimized for performance, just for correctness. An optimized version of the code is used in the TopBraid products such as [TopBraid EDG](https://www.topquadrant.com/products/topbraid-enterprise-data-governance/)** Coverage: * [SHACL Core and SHACL-SPARQL validation](https://www.w3.org/TR/shacl/)
2
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
62
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-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/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 002" ; owl:imports <http://datashapes.org/dash> ; . ex:GraphValidationTestCase rdf:type dash:GraphValidationTestCase ; dash:expectedResult [ dash:expectedResult [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; sh:path ex:property ; sh:severity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; . sh:sourceShape [] ; ] ; ] ; dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -21,8 +21,8 @@ ex:GraphValidationTestCase dash:expectedResult [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; - sh:path ex:property ; - sh:severity sh:Violation ; + sh:resultPath ex:property ; + sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; .
2
Tracking latest SHACL spec
2
.ttl
test
apache-2.0
TopQuadrant/shacl
63
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-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/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 002" ; owl:imports <http://datashapes.org/dash> ; . ex:GraphValidationTestCase rdf:type dash:GraphValidationTestCase ; dash:expectedResult [ dash:expectedResult [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; sh:path ex:property ; sh:severity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; . sh:sourceShape [] ; ] ; ] ; dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -21,8 +21,8 @@ ex:GraphValidationTestCase dash:expectedResult [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; - sh:path ex:property ; - sh:severity sh:Violation ; + sh:resultPath ex:property ; + sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; .
2
Tracking latest SHACL spec
2
.ttl
test
apache-2.0
TopQuadrant/shacl
64
<NME> valueClass-001.ttl <BEF> ADDFILE <MSG> Latest updates <DFF> @@ -0,0 +1,58 @@ +# baseURI: http://www.w3.org/ns/shacl/test/features/core/valueClass-001 + +@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:property [ + sh:predicate ex:value ; + sh:valueClass ex:SuperClass ; + ] ; +. + + +# Data ------------------------------------------------------------------------ + +ex:SuperClass + a rdfs:Class ; + rdfs:subClassOf rdfs:Resource ; +. + +ex:SubClass + a rdfs:Class ; + rdfs:subClassOf ex:SuperClass ; +. + +ex:SuperInstance + a ex:SuperClass ; +. + +ex:SubInstance + a ex:SubClass ; +. + +ex:ValidInstance1 + sh:nodeShape ex:MyShape ; + ex:value ex:SuperInstance ; +. + +ex:ValidInstance2 + sh:nodeShape ex:MyShape ; + ex:value ex:SubInstance ; +. + +ex:InvalidInstance1 + sh:nodeShape ex:MyShape ; + ex:value ex:InvalidInstance1 ; +.
58
Latest updates
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
65
<NME> valueClass-001.ttl <BEF> ADDFILE <MSG> Latest updates <DFF> @@ -0,0 +1,58 @@ +# baseURI: http://www.w3.org/ns/shacl/test/features/core/valueClass-001 + +@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:property [ + sh:predicate ex:value ; + sh:valueClass ex:SuperClass ; + ] ; +. + + +# Data ------------------------------------------------------------------------ + +ex:SuperClass + a rdfs:Class ; + rdfs:subClassOf rdfs:Resource ; +. + +ex:SubClass + a rdfs:Class ; + rdfs:subClassOf ex:SuperClass ; +. + +ex:SuperInstance + a ex:SuperClass ; +. + +ex:SubInstance + a ex:SubClass ; +. + +ex:ValidInstance1 + sh:nodeShape ex:MyShape ; + ex:value ex:SuperInstance ; +. + +ex:ValidInstance2 + sh:nodeShape ex:MyShape ; + ex:value ex:SubInstance ; +. + +ex:InvalidInstance1 + sh:nodeShape ex:MyShape ; + ex:value ex:InvalidInstance1 ; +.
58
Latest updates
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
66
<NME> dash.ttl <BEF> # baseURI: http://datashapes.org/dash # imports: http://topbraid.org/tosh # imports: http://www.w3.org/ns/shacl# # prefix: dash @prefix dash: <http://datashapes.org/dash#> . @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 tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/dash> a owl:Ontology ; rdfs:comment "DASH is a SHACL library for frequently needed features and design patterns. The constraint components in this library are 100% standards compliant and will work on any engine that fully supports SHACL." ; rdfs:label "DASH Data Shapes Vocabulary" ; owl:imports <http://topbraid.org/tosh> ; owl:imports sh: ; sh:declare [ sh:namespace "http://datashapes.org/dash#"^^xsd:anyURI ; sh:prefix "dash" ; ] ; sh:declare [ sh:namespace "http://purl.org/dc/terms/"^^xsd:anyURI ; sh:prefix "dcterms" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ; sh:prefix "rdf" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2000/01/rdf-schema#"^^xsd:anyURI ; sh:prefix "rdfs" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2001/XMLSchema#"^^xsd:anyURI ; sh:prefix "xsd" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2002/07/owl#"^^xsd:anyURI ; sh:prefix "owl" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ; sh:prefix "skos" ; ] ; . dash:APIStatus a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of possible values for dash:apiStatus." ; rdfs:label "API Status" ; rdfs:subClassOf rdfs:Resource ; . dash:Action a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An executable command triggered by an agent, backed by a Script implementation. Actions may get deactivated using sh:deactivated." ; rdfs:label "Action" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ActionGroup a dash:ShapeClass ; rdfs:comment "A group of ResourceActions, used to arrange items in menus etc. Similar to sh:PropertyGroups, they may have a sh:order and should have labels (in multiple languages if applicable)." ; rdfs:label "Action group" ; rdfs:subClassOf rdfs:Resource ; . dash:ActionTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a dash:Action using provided input parameters. Requires exactly one value for dash:action and will operate on the test case's graph (with imports) as both data and shapes graph. Currently only supports read-only actions, allowing the comparison of actual results with the expected results.""" ; rdfs:label "Action test case" ; rdfs:subClassOf dash:TestCase ; . dash:AllObjects a dash:AllObjectsTarget ; rdfs:comment "A reusable instance of dash:AllObjectsTarget." ; rdfs:label "All objects" ; . dash:AllObjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all objects in the data graph as focus nodes." ; rdfs:label "All objects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allObjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All objects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?anyS ?anyP ?this . }""" ; . dash:AllSubjects a dash:AllSubjectsTarget ; rdfs:comment "A reusable instance of dash:AllSubjectsTarget." ; rdfs:label "All subjects" ; . dash:AllSubjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all subjects in the data graph as focus nodes." ; rdfs:label "All subjects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allSubjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All subjects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this ?anyP ?anyO . }""" ; . dash:AutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An auto-complete field to enter the label of instances of a class. This is the fallback editor for any URI resource if no other editors are more suitable." ; rdfs:label "Auto-complete editor" ; . dash:BlankNodeViewer a dash:SingleViewer ; rdfs:comment "A Viewer for blank nodes, rendering as the label of the blank node." ; rdfs:label "Blank node viewer" ; . dash:BooleanSelectEditor a dash:SingleEditor ; rdfs:comment """An editor for boolean literals, rendering as a select box with values true and false. Also displays the current value (such as \"1\"^^xsd:boolean), but only allows to switch to true or false.""" ; rdfs:label "Boolean select editor" ; . dash:ChangeScript a dash:ShapeClass ; rdfs:comment """Class of ADS scripts that are executed after edits to the data graph were made. These scripts may access the current changes from the graphs with names dataset.addedGraphURI and dataset.deletedGraphURI to learn about which resource values have been added or deleted. For example query them using graph.withDataGraph(dataset.addedGraphURI, ...) or via SPARQL's GRAPH keyword. Change scripts may then perform further changes which would again become visible to other change scripts. Change scripts are executed by their relative sh:order, with a default value of 0. Use lower values to execute before other rules.""" ; rdfs:label "Change script" ; rdfs:subClassOf dash:Script ; . dash:ClosedByTypesConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to declare that focus nodes are \"closed\" based on their rdf:types, meaning that focus nodes may only have values for the properties that are explicitly enumerated via sh:property/sh:path in property constraints at their rdf:types and the superclasses of those. This assumes that the type classes are also shapes." ; rdfs:label "Closed by types constraint component" ; sh:nodeValidator [ a sh:JSValidator ; sh:jsFunctionName "validateClosedByTypesNode" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Property is not among those permitted for any of the types" ; ] ; sh:nodeValidator [ a sh:SPARQLSelectValidator ; sh:message "Property {?path} is not among those permitted for any of the types" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this (?predicate AS ?path) ?value WHERE { FILTER ($closedByTypes) . $this ?predicate ?value . FILTER (?predicate != rdf:type) . FILTER NOT EXISTS { $this rdf:type ?type . ?type rdfs:subClassOf* ?class . GRAPH $shapesGraph { ?class sh:property/sh:path ?predicate . } } }""" ; ] ; sh:parameter dash:ClosedByTypesConstraintComponent-closedByTypes ; . dash:ClosedByTypesConstraintComponent-closedByTypes a sh:Parameter ; sh:path dash:closedByTypes ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to indicate that the focus nodes are closed by their types. A constraint violation is reported for each property value of the focus node where the property is not among those that are explicitly declared via sh:property/sh:path in any of the rdf:types of the focus node (and their superclasses). The property rdf:type is always permitted." ; sh:maxCount 1 ; . dash:CoExistsWithConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that if the property path has any value then the given property must also have a value, and vice versa." ; rdfs:label "Co-exists-with constraint component" ; sh:message "Values must co-exist with values of {$coExistsWith}" ; sh:parameter dash:CoExistsWithConstraintComponent-coExistsWith ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateCoExistsWith" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { { FILTER (EXISTS { $this $PATH ?any } && NOT EXISTS { $this $coExistsWith ?any }) } UNION { FILTER (NOT EXISTS { $this $PATH ?any } && EXISTS { $this $coExistsWith ?any }) } }""" ; ] ; . dash:CoExistsWithConstraintComponent-coExistsWith a sh:Parameter ; sh:path dash:coExistsWith ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "The properties that must co-exist with the surrounding property (path). If the surrounding property path has any value then the given property must also have a value, and vice versa." ; sh:name "co-exists with" ; sh:nodeKind sh:IRI ; . dash:ConstraintReificationShape a sh:NodeShape ; sh:name "expression" ; ] ; . dash:GraphUpdate rdf:type rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:subClassOf sh:Parameterizable ; . dash:DASHJSLibrary a sh:JSLibrary ; rdfs:label "DASH JavaScript library" ; sh:jsLibrary dash:RDFQueryJSLibrary ; sh:jsLibraryURL "http://datashapes.org/js/dash.js"^^xsd:anyURI ; . dash:DateOrDateTime a rdf:List ; rdf:first [ sh:datatype xsd:date ; ] ; rdf:rest ( [ sh:datatype xsd:dateTime ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:date or xsd:dateTime." ; rdfs:label "Date or date time" ; . dash:DatePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:date literals, offering a calendar-like date picker." ; rdfs:label "Date picker editor" ; . dash:DateTimePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:dateTime literals, offering a calendar-like date picker and a time selector." ; rdfs:label "Date time picker editor" ; . dash:DepictionRole a dash:PropertyRole ; rdfs:comment "Depiction properties provide images representing the focus nodes. Typical examples may be a photo of an animal or the map of a country." ; rdfs:label "Depiction" ; . dash:Deprecated a dash:APIStatus ; rdfs:comment "Features that have been marked deprecated will remain in the API but should no longer be used by new code and may get deleted in the foreseeable future (e.g., with the next major release)." ; rdfs:label "deprecated" ; . dash:DescriptionRole a dash:PropertyRole ; rdfs:comment "Description properties should produce text literals that may be used as an introduction/summary of what a focus node does." ; rdfs:label "Description" ; . dash:DetailsEditor a dash:SingleEditor ; rdfs:comment "An editor for non-literal values, typically displaying a nested form where the values of the linked resource can be edited directly on the \"parent\" form. Implementations that do not support this (yet) could fall back to an auto-complete widget." ; rdfs:label "Details editor" ; . dash:DetailsViewer a dash:SingleViewer ; rdfs:comment "A Viewer for resources that shows the details of the value using its default view shape as a nested form-like display." ; rdfs:label "Details viewer" ; . dash:Editor a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for editing value nodes." ; rdfs:label "Editor" ; rdfs:subClassOf dash:Widget ; . dash:EnumSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for enumerated values (typically based on sh:in lists)." ; rdfs:label "Enum select editor" ; . dash:ExecutionPlatform a rdfs:Class ; rdfs:comment "An platform (such as TopBraid) that may have features needed to execute, for example, SPARQL queries." ; rdfs:label "Execution platform" ; rdfs:subClassOf rdfs:Resource ; . dash:Experimental a dash:APIStatus ; rdfs:comment "Features that are marked experimental can be used by early adopters but there is no guarantee that they will reach stable state." ; rdfs:label "experimental" ; . dash:ExploreAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in an Explore section of a selected resource. Cannot make changes to the data." ; rdfs:label "Explore action" ; rdfs:subClassOf dash:ResourceAction ; . dash:FailureResult a rdfs:Class ; rdfs:comment "A result representing a validation failure such as an unsupported recursion." ; rdfs:label "Failure result" ; rdfs:subClassOf sh:AbstractResult ; . dash:FailureTestCaseResult a rdfs:Class ; rdfs:comment "Represents a failure of a test case." ; rdfs:label "Failure test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:FunctionTestCase a dash:ShapeClass ; rdfs:comment "A test case that verifies that a given SPARQL expression produces a given, expected result." ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphService a dash:ShapeClass ; rdfs:comment "A service that does not apply to a specific resource (as ResourceService does) but operates on the whole graph. The focusNode variable will be the URI of the current base graph (e.g. <urn:x-evn-master:geo> as a NamedNode." ; rdfs:label "Graph service" ; rdfs:subClassOf dash:Service ; . dash:GraphStoreTestCase a dash:ShapeClass ; rdfs:comment "A test case that can be used to verify that an RDF file could be loaded (from a file) and that the resulting RDF graph is equivalent to a given TTL file." ; rdfs:label "Graph store test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphUpdate a rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:label "Graph update" ; rdfs:subClassOf dash:Suggestion ; . dash:GraphValidationTestCase a dash:ShapeClass ; rdfs:comment "A test case that performs SHACL constraint validation on the whole graph and compares the results with the expected validation results stored with the test case. By default this excludes meta-validation (i.e. the validation of the shape definitions themselves). If that's desired, set dash:validateShapes to true." ; rdfs:label "Graph validation test case" ; rdfs:subClassOf dash:ValidationTestCase ; . dash:HTMLOrStringOrLangString a rdf:List ; rdf:first [ sh:datatype rdf:HTML ; ] ; rdf:rest ( [ sh:datatype xsd:string ; ] [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either rdf:HTML, xsd:string or rdf:langString (in that order of preference)." ; rdfs:label "HTML or string or langString" ; . dash:HTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML encoded text from rdf:HTML literals, rendering as parsed HTML DOM elements. Also displays the language if the HTML has a lang attribute on its root DOM element." ; rdfs:label "HTML viewer" ; . dash:HasValueInConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be a member of a given list of nodes." ; rdfs:label "Has value in constraint component" ; sh:message "At least one of the values must be in {$hasValueIn}" ; sh:parameter dash:HasValueInConstraintComponent-hasValueIn ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . GRAPH $shapesGraph { $hasValueIn rdf:rest*/rdf:first ?value . } } }""" ; ] ; . dash:HasValueInConstraintComponent-hasValueIn a sh:Parameter ; sh:path dash:hasValueIn ; dash:reifiableBy dash:ConstraintReificationShape ; sh:description "At least one of the value nodes must be a member of the given list." ; sh:name "has value in" ; sh:node dash:ListShape ; . dash:HasValueTarget a sh:SPARQLTargetType ; rdfs:comment "A target type for all subjects where a given predicate has a certain object value." ; rdfs:label "Has Value target" ; rdfs:subClassOf sh:Target ; sh:labelTemplate "All subjects where {$predicate} has value {$object}" ; sh:parameter [ a sh:Parameter ; sh:path dash:object ; sh:description "The value that is expected to be present." ; sh:name "object" ; ] ; sh:parameter [ a sh:Parameter ; sh:path dash:predicate ; sh:description "The predicate property." ; sh:name "predicate" ; sh:nodeKind sh:IRI ; ] ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this $predicate $object . }""" ; . dash:HasValueWithClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be an instance of a given class." ; rdfs:label "Has value with class constraint component" ; sh:message "At least one of the values must be an instance of class {$hasValueWithClass}" ; sh:parameter dash:HasValueWithClassConstraintComponent-hasValueWithClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateHasValueWithClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . ?value a ?type . ?type rdfs:subClassOf* $hasValueWithClass . } }""" ; ] ; . dash:HasValueWithClassConstraintComponent-hasValueWithClass a sh:Parameter ; sh:path dash:hasValueWithClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "One of the values of the property path must be an instance of the given class." ; sh:name "has value with class" ; sh:nodeKind sh:IRI ; . dash:HyperlinkViewer a dash:SingleViewer ; rdfs:comment """A Viewer for literals, rendering as a hyperlink to a URL. For literals it assumes the lexical form is the URL. This is often used as default viewer for xsd:anyURI literals. Unsupported for blank nodes.""" ; rdfs:label "Hyperlink viewer" ; . dash:IDRole a dash:PropertyRole ; rdfs:comment "ID properties are short strings or other literals that identify the focus node among siblings. Examples may include social security numbers." ; rdfs:label "ID" ; . dash:IconRole a dash:PropertyRole ; rdfs:comment """Icon properties produce images that are typically small and almost square-shaped, and that may be displayed in the upper left corner of a focus node's display. Values should be xsd:string or xsd:anyURI literals or IRI nodes pointing at URLs. Those URLs should ideally be vector graphics such as .svg files. Instances of the same class often have the same icon, and this icon may be computed using a sh:values rule or as sh:defaultValue. If the value is a relative URL then those should be resolved against the server that delivered the surrounding page.""" ; rdfs:label "Icon" ; . dash:ImageViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI values that are recognized as images by a browser, rendering as an image." ; rdfs:label "Image viewer" ; . dash:IncludedScript a dash:ShapeClass ; rdfs:comment """The code associated with instances of this class will get injected into the generated APIs, as global code snippets. Typically used to declare libraries of utility functions or constants that are (compared to shape scripts) not necessarily associated with specific classes or shapes. Note that the JavaScript code stored in dash:js cannot use the export keyword because the code must also work in external scripts (such as on Node.js). Instead, you need to enumerate the exported symbols via dash:exports.""" ; rdfs:label "Included script" ; rdfs:subClassOf dash:Script ; sh:property tosh:IncludedScript-exports ; . dash:IndexedConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to mark property shapes to be indexed, meaning that each of its value nodes must carry a dash:index from 0 to N." ; rdfs:label "Indexed constraint component" ; sh:parameter dash:IndexedConstraintComponent-indexed ; . dash:IndexedConstraintComponent-indexed a sh:Parameter ; sh:path dash:indexed ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to activate indexing for this property." ; sh:maxCount 1 ; sh:name "indexed" ; . dash:InferencingTestCase a dash:ShapeClass ; rdfs:comment "A test case to verify whether an inferencing engine is producing identical results to those stored as expected results." ; rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; . dash:InlineViewer a dash:MultiViewer ; rdfs:comment "A multi-viewer that renders all values horizontally, in a more compact form that just a single value per row." ; rdfs:label "Inline viewer" ; . dash:InstancesSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of the target class (based on sh:class of the property)." ; rdfs:label "Instances select editor" ; . dash:JSONTableViewer a dash:SingleViewer ; rdfs:comment """A tabular viewer for rdf:JSON literals with a lexical form in the following format: { vars: [ 'col1', 'col2' ], // These are the column keys headerLabels: [ 'Column 1', 'Column 2' ], // Optional, for the column headers bindings: [ // These become the rows { col1: { lex: 'Value2', datatype: '...#string', }, col2: { uri: 'http://.../Instance', label: 'Example Instance', }, }, ... ], } The resulting table will use the headerLabels (if they exist) as column headers, otherwise derive the headers from the variable names. The vars must match the fields in the bindings. The table will contain one row for each binding. Using Active Data Shapes, you can construct such literals dynamically using a sh:values rule, e.g. ex:MyClass-myProperty a sh:PropertyShape ; sh:path ex:myProperty ; sh:values [ dash:js \"\"\" DataViewers.createTableViewerJSON(focusNode.select(` SELECT ?col1 ?col2 WHERE { $this ex:prop1 ?col1 . $this ex:prop2 ?col2 . } `))\"\"\" ] . You may also produce the JSON literal programmatically in JavaScript, or assert the triples by other means.""" ; rdfs:label "JSON table viewer" ; . dash:JSTestCase a dash:ShapeClass ; rdfs:comment "A test case that calls a given SHACL-JS JavaScript function like a sh:JSFunction and compares its result with the dash:expectedResult." ; rdfs:label "SHACL-JS test case" ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; . dash:KeyInfoRole a dash:PropertyRole ; rdfs:comment "The Key info role may be assigned to properties that are likely of special interest to a reader, so that they should appear whenever a summary of a focus node is shown." ; rdfs:label "Key info" ; . dash:LabelRole a dash:PropertyRole ; rdfs:comment "Properties with this role produce strings that may serve as display label for the focus nodes. Labels should be either plain string literals or strings with a language tag. The values should also be single-line." ; rdfs:label "Label" ; . dash:LabelViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI based on the display label of the resource. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "Label viewer" ; . dash:LangStringViewer a dash:SingleViewer ; rdfs:comment "A Viewer for literals with a language tag, rendering as the text plus a language indicator." ; rdfs:label "LangString viewer" ; . dash:ListNodeShape a sh:NodeShape ; rdfs:comment "Defines constraints on what it means for a node to be a node within a well-formed RDF list. Note that this does not check whether the rdf:rest items are also well-formed lists as this would lead to unsupported recursion." ; rdfs:label "List node shape" ; sh:or ( [ sh:hasValue () ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 0 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 0 ; ] ; ] [ sh:not [ sh:hasValue () ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 1 ; sh:minCount 1 ; ] ; ] ) ; . dash:ListShape a sh:NodeShape ; rdfs:comment """Defines constraints on what it means for a node to be a well-formed RDF list. The focus node must either be rdf:nil or not recursive. Furthermore, this shape uses dash:ListNodeShape as a \"helper\" to walk through all members of the whole list (including itself).""" ; rdfs:label "List shape" ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:ValidationTestCase rdf:type rdfs:Class ; rdf:type sh:NodeShape ; . dash:MultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """A multi-function is a function that can return zero or more result objects consisting of one or more result variables. While normal (SPARQL/SHACL) functions can only return a single result node, multi-functions may not only return multiple nodes but even multiple individual variables per solution. A common way of defining multi-functions is by wrapping a SPARQL SELECT query, using dash:SPARQLMultiFunction. However, some MultiFunctions (in TopBraid) may also be implemented natively.""" ; rdfs:label "Multi-function" ; rdfs:subClassOf sh:Parameterizable ; sh:nodeKind sh:IRI ; . dash:MultiViewer a dash:ShapeClass ; rdfs:comment "A viewer for multiple/all values at once." ; rdfs:label "Multi viewer" ; rdfs:subClassOf dash:Viewer ; . dash:NoSuitableEditor a dash:SingleEditor ; rdfs:comment "An \"editor\" that simply informs the user that the values cannot be edited here, but for example through source code editing." ; rdfs:label "No suitable editor" ; . dash:NodeExpressionViewer a dash:SingleViewer ; rdfs:comment "A viewer for SHACL Node Expressions."^^rdf:HTML ; rdfs:label "Node expression viewer" ; . dash:NonRecursiveConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Used to state that a property or path must not point back to itself." ; rdfs:label "Non-recursive constraint component" ; sh:message "Points back at itself (recursively)" ; sh:parameter dash:NonRecursiveConstraintComponent-nonRecursive ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateNonRecursiveProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ($this AS ?value) WHERE { { FILTER (?nonRecursive) } $this $PATH $this . }""" ; ] ; . dash:NonRecursiveConstraintComponent-nonRecursive a sh:Parameter ; sh:path dash:nonRecursive ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description """Used to state that a property or path must not point back to itself. For example, \"a person cannot have itself as parent\" can be expressed by setting dash:nonRecursive=true for a given sh:path. To express that a person cannot have itself among any of its (recursive) parents, use a sh:path with the + operator such as ex:parent+.""" ; sh:maxCount 1 ; sh:name "non-recursive" ; . dash:None a sh:NodeShape ; rdfs:comment "A Shape that is no node can conform to." ; rdfs:label "None" ; sh:in () ; . dash:ParameterConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to verify that all value nodes conform to the given Parameter."@en ; rdfs:label "Parameter constraint component"@en ; sh:parameter dash:ParameterConstraintComponent-parameter ; . dash:ParameterConstraintComponent-parameter a sh:Parameter ; sh:path sh:parameter ; . dash:PrimaryKeyConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "Enforces a constraint that the given property (sh:path) serves as primary key for all resources in the target of the shape. If a property has been declared to be the primary key then each resource must have exactly one value for that property. Furthermore, the URIs of those resources must start with a given string (dash:uriStart), followed by the URL-encoded primary key value. For example if dash:uriStart is \"http://example.org/country-\" and the primary key for an instance is \"de\" then the URI must be \"http://example.org/country-de\". Finally, as a result of the URI policy, there can not be any other resource with the same value under the same primary key policy." ; rdfs:label "Primary key constraint component" ; sh:labelTemplate "The property {?predicate} is the primary key and URIs start with {?uriStart}" ; sh:message "Violation of primary key constraint" ; sh:parameter dash:PrimaryKeyConstraintComponent-uriStart ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validatePrimaryKeyProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this WHERE { FILTER ( # Must have a value for the primary key NOT EXISTS { ?this $PATH ?any } || # Must have no more than one value for the primary key EXISTS { ?this $PATH ?value1 . ?this $PATH ?value2 . FILTER (?value1 != ?value2) . } || # The value of the primary key must align with the derived URI EXISTS { { ?this $PATH ?value . FILTER NOT EXISTS { ?this $PATH ?value2 . FILTER (?value != ?value2) } } BIND (CONCAT($uriStart, ENCODE_FOR_URI(str(?value))) AS ?uri) . FILTER (str(?this) != ?uri) . } ) }""" ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart a sh:Parameter ; sh:path dash:uriStart ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "The start of the URIs of well-formed resources. If specified then the associated property/path serves as \"primary key\" for all target nodes (instances). All such target nodes need to have a URI that starts with the given string, followed by the URI-encoded value of the primary key property." ; sh:maxCount 1 ; sh:name "URI start" ; . dash:PropertyAutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An editor for properties that are either defined as instances of rdf:Property or used as IRI values of sh:path. The component uses auto-complete to find these properties by their rdfs:labels or sh:names." ; rdfs:label "Property auto-complete editor" ; . dash:PropertyLabelViewer a dash:SingleViewer ; rdfs:comment "A viewer for properties that renders a hyperlink using the display label or sh:name, allowing users to either navigate to the rdf:Property resource or the property shape definition. Should be used in conjunction with PropertyAutoCompleteEditor." ; rdfs:label "Property label viewer" ; . dash:PropertyRole a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of roles that a property (shape) may take for its focus nodes." ; rdfs:label "Property role" ; rdfs:subClassOf rdfs:Resource ; . dash:QueryTestCase a dash:ShapeClass ; rdfs:comment "A test case running a given SPARQL SELECT query and comparing its results with those stored as JSON Result Set in the expected result property." ; rdfs:label "Query test case" ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:RDFQueryJSLibrary a sh:JSLibrary ; rdfs:label "rdfQuery JavaScript Library" ; sh:jsLibraryURL "http://datashapes.org/js/rdfquery.js"^^xsd:anyURI ; . dash:ReifiableByConstraintComponent a sh:ConstraintComponent ; rdfs:label "Reifiable-by constraint component" ; sh:labelTemplate "Reifiable by {$reifiableBy}" ; sh:parameter dash:ReifiableByConstraintComponent-reifiableBy ; . dash:ReifiableByConstraintComponent-reifiableBy a sh:Parameter ; sh:path dash:reifiableBy ; sh:class sh:NodeShape ; sh:description "Can be used to specify the node shape that may be applied to reified statements produced by a property shape. The property shape must have a URI resource as its sh:path. The values of this property must be node shapes. User interfaces can use this information to determine which properties to present to users when reified statements are explored or edited. Also, SHACL validators can use it to determine how to validate reified triples. Use dash:None to indicate that no reification should be permitted." ; sh:maxCount 1 ; sh:name "reifiable by" ; sh:nodeKind sh:IRI ; . dash:ResourceAction a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An Action that can be executed for a selected resource. Such Actions show up in context menus once they have been assigned a sh:group." ; rdfs:label "Resource action" ; rdfs:subClassOf dash:Action ; . dash:ResourceService a dash:ShapeClass ; rdfs:comment "A Service that can (and must) be applied to a given resource as focus node. Use dash:resourceService to link a class to the services that apply to its instances." ; rdfs:label "Resource service" ; rdfs:subClassOf dash:Service ; . dash:RichTextEditor a dash:SingleEditor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; rdfs:label "Rich text editor" ; . dash:RootClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component defining the parameter dash:rootClass, which restricts the values to be either the root class itself or one of its subclasses. This is typically used in conjunction with properties that have rdfs:Class as their type." ; rdfs:label "Root class constraint component" ; sh:labelTemplate "Root class {$rootClass}" ; sh:message "Value must be subclass of {$rootClass}" ; sh:parameter dash:RootClassConstraintComponent-rootClass ; sh:validator dash:hasRootClass ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateRootClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:RootClassConstraintComponent-rootClass a sh:Parameter ; sh:path dash:rootClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "The root class." ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLConstructTemplate a rdfs:Class ; rdfs:comment "Encapsulates one or more SPARQL CONSTRUCT queries that can be parameterized. Parameters will become pre-bound variables in the queries." ; rdfs:label "SPARQL CONSTRUCT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLConstructExecutable ; . dash:SPARQLMultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment "A multi-function based on a SPARQL SELECT query. The query gets executed with the arguments pre-bound to the variables declared as parameters. The results of the multi-function are all result bindings from the SPARQL result set." ; rdfs:label "SPARQL multi-function" ; rdfs:subClassOf dash:MultiFunction ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLSelectTemplate a rdfs:Class ; rdfs:comment "Encapsulates a SPARQL SELECT query that can be parameterized. Parameters will become pre-bound variables in the query." ; rdfs:label "SPARQL SELECT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $focusNode, $predicate and $value, as well as the other pre-bound variables for the parameters of the constraint. In many cases, there may be multiple possible suggestions to fix a problem. For example, with sh:maxLength there are many ways to slice a string. In those cases, the system will first iterate through the result variables from a SELECT query (sh:select) and apply these results as pre-bound variables into the UPDATE query.""" ; rdfs:label "SPARQL UPDATE suggestion generator" ; rdfs:subClassOf dash:SuggestionGenerator ; rdfs:subClassOf sh:SPARQLSelectExecutable ; rdfs:subClassOf sh:SPARQLUpdateExecutable ; . dash:Script a dash:ShapeClass ; rdfs:comment "An executable unit implemented in one or more languages such as JavaScript." ; rdfs:label "Script" ; rdfs:subClassOf rdfs:Resource ; . dash:ScriptAPIGenerationRules a sh:PropertyGroup ; rdfs:label "Script API Generation Rules" ; . dash:ScriptAPIShape a sh:NodeShape ; rdfs:comment "Defines the properties that instruct the ADS Script API generator about what prefixes, constants and classes to generate." ; rdfs:label "Script API" ; sh:property dash:ScriptAPIShape-generateClass ; sh:property dash:ScriptAPIShape-generatePrefixClasses ; sh:property dash:ScriptAPIShape-generatePrefixConstants ; sh:targetClass owl:Ontology ; . dash:ScriptAPIShape-generateClass a sh:PropertyShape ; sh:path dash:generateClass ; sh:class sh:NodeShape ; sh:description "The API generator will produce classes for each value of this property and all its subclasses and superclasses." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate class" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixClasses a sh:PropertyShape ; sh:path dash:generatePrefixClasses ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce classes for all RDFS classes or node shapes from the associated namespace." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix classes" ; sh:order "15"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixConstants a sh:PropertyShape ; sh:path dash:generatePrefixConstants ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce constants for class, datatype, shape and property names." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix constants" ; sh:order "10"^^xsd:decimal ; . dash:ScriptConstraint a dash:ShapeClass ; rdfs:comment """The class of constraints that are based on Scripts. Depending on whether dash:onAllValues is set to true, these scripts can access the following pre-assigned variables: - focusNode: the focus node of the constraint (a NamedNode) - if dash:onAllValues is not true: value: the current value node (e.g. a JavaScript string for xsd:string literals, a number for numeric literals or true or false for xsd:boolean literals. All other literals become LiteralNodes, and non-literals become instances of NamedNode) - if dash:onAllValues is true: values: an array of current value nodes, as above. If the expression returns an array then each array member will be mapped to one validation result, following the mapping rules below. For string results, a validation result will use the string as sh:resultMessage. For boolean results, a validation result will be produced if the result is false (true means no violation). For object results, a validation result will be produced using the value of the field \"message\" of the object as result message. If the field \"value\" has a value then this will become the sh:value in the violation. Unless another sh:message has been directly returned, the sh:message of the dash:ScriptConstraint will be used, similar to sh:message at SPARQL Constraints. These sh:messages can access the values {$focusNode}, {$value} etc as template variables.""" ; rdfs:label "Script constraint" ; rdfs:subClassOf dash:Script ; . dash:ScriptConstraintComponent a sh:ConstraintComponent ; rdfs:label "Script constraint component" ; sh:parameter dash:ScriptConstraintComponent-scriptConstraint ; . dash:ScriptConstraintComponent-scriptConstraint a sh:Parameter ; sh:path dash:scriptConstraint ; sh:class dash:ScriptConstraint ; sh:description "The Script constraint(s) to apply." ; sh:name "script constraint" ; . dash:ScriptFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """Script functions can be used from SPARQL queries and will be injected into the generated prefix object (in JavaScript, for ADS scripts). The dash:js will be inserted into a generated JavaScript function and therefore needs to use the return keyword to produce results. These JS snippets can access the parameter values based on the local name of the sh:Parameter's path. For example ex:value can be accessed using value. SPARQL use note: Since these functions may be used from any data graph and any shapes graph, they must not rely on any API apart from what's available in the shapes graph that holds the rdf:type triple of the function itself. In other words, at execution time from SPARQL, the ADS shapes graph will be the home graph of the function's declaration.""" ; rdfs:label "Script function" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Function ; . dash:ScriptSuggestionGenerator a dash:ShapeClass ; rdfs:comment """A Suggestion Generator that is backed by an Active Data Shapes script. The script needs to return a JSON object or an array of JSON objects if it shall generate multiple suggestions. It may also return null to indicate that nothing was suggested. Note that the whole script is evaluated as a (JavaScript) expression, and those will use the last value as result. So simply putting an object at the end of your script should do. Alternatively, define the bulk of the operation as a function and simply call that function in the script. Each response object can have the following fields: { message: \"The human readable message\", // Defaults to the rdfs:label(s) of the suggestion generator add: [ // An array of triples to add, each triple as an array with three nodes [ subject, predicate, object ], [ ... ] ], delete: [ ... like add, for the triples to delete ] } Suggestions with neither added nor deleted triples will be discarded. At execution time, the script operates on the data graph as the active graph, with the following pre-bound variables: - focusNode: the NamedNode that is the sh:focusNode of the validation result - predicate: the NamedNode representing the predicate of the validation result, assuming sh:resultPath is a URI - value: the value node from the validation result's sh:value, cast into the most suitable JS object - the other pre-bound variables for the parameters of the constraint, e.g. in a sh:maxCount constraint it would be maxCount The script will be executed in read-only mode, i.e. it cannot modify the graph. Example with dash:js: ({ message: `Copy labels into ${graph.localName(predicate)}`, add: focusNode.values(rdfs.label).map(label => [ focusNode, predicate, label ] ) })""" ; rdfs:label "Script suggestion generator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:SuggestionGenerator ; . dash:ScriptTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a script. Requires exactly one value for dash:js and will operate on the test case's graph (with imports) as both data and shapes graph. Supports read-only scripts only at this stage.""" ; rdfs:label "Script test case" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:TestCase ; . dash:ScriptValidator a dash:ShapeClass ; rdfs:comment """A SHACL validator based on an Active Data Shapes script. See the comment at dash:ScriptConstraint for the basic evaluation approach. Note that in addition to focusNode and value/values, the script can access pre-bound variables for each declared argument of the constraint component.""" ; rdfs:label "Script validator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Validator ; . dash:Service a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A script that gets exposed as a web service, e.g. /tbl/service/ex/MyService" ; rdfs:label "Service" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ShapeClass a dash:ShapeClass ; dash:hidden true ; rdfs:comment "A class that is also a node shape. This class can be used as rdf:type instead of the combination of rdfs:Class and sh:NodeShape." ; rdfs:label "Shape class" ; rdfs:subClassOf rdfs:Class ; WHERE { }""" ; . dash:validateShapes rdf:type rdf:Property ; rdfs:comment "True to also validate the shapes itself (i.e. parameter declarations)." ; rdfs:comment "An editor for individual value nodes." ; rdfs:label "Single editor" ; rdfs:subClassOf dash:Editor ; . dash:SingleLineConstraintComponent a sh:ConstraintComponent ; rdfs:comment """A constraint component that can be used to declare that all values that are literals must have a lexical form that contains no line breaks ('\\n' or '\\r'). User interfaces may use the dash:singleLine flag to prefer a text field over a (multi-line) text area.""" ; rdfs:label "Single line constraint component" ; sh:message "Must not contain line breaks." ; sh:parameter dash:SingleLineConstraintComponent-singleLine ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSingleLine" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { FILTER (!$singleLine || !isLiteral($value) || (!contains(str($value), '\\n') && !contains(str($value), '\\r'))) }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; . dash:SingleLineConstraintComponent-singleLine a sh:Parameter ; sh:path dash:singleLine ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to state that the lexical form of literal value nodes must not contain any line breaks. False to state that line breaks are explicitly permitted." ; sh:group tosh:StringConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "single line" ; sh:order "30"^^xsd:decimal ; . dash:SingleViewer a dash:ShapeClass ; rdfs:comment "A viewer for a single value." ; rdfs:label "Single viewer" ; rdfs:subClassOf dash:Viewer ; . dash:Stable a dash:APIStatus ; rdfs:comment "Features that have been marked stable are deemed of good quality and can be used until marked deprecated." ; rdfs:label "stable" ; . dash:StemConstraintComponent a sh:ConstraintComponent ; dash:staticConstraint true ; rdfs:comment "A constraint component that can be used to verify that every value node is an IRI and the IRI starts with a given string value."@en ; rdfs:label "Stem constraint component"@en ; sh:labelTemplate "Value needs to have stem {$stem}" ; sh:message "Value does not have stem {$stem}" ; sh:parameter dash:StemConstraintComponent-stem ; sh:validator dash:hasStem ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateStem" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:StemConstraintComponent-stem a sh:Parameter ; sh:path dash:stem ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "If specified then every value node must be an IRI and the IRI must start with the given string value." ; sh:maxCount 1 ; sh:name "stem" ; . dash:StringOrLangString a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string or rdf:langString." ; rdfs:label "String or langString" ; . dash:StringOrLangStringOrHTML a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] [ sh:datatype rdf:HTML ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string, rdf:langString or rdf:HTML (in that order of preference)." ; rdfs:label "string or langString or HTML" ; . dash:SubClassEditor a dash:SingleEditor ; rdfs:comment "An editor for properties that declare a dash:rootClass. The editor allows selecting either the class itself or one of its subclasses." ; rdfs:label "Sub-Class editor" ; . dash:SubSetOfConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to state that the set of value nodes must be a subset of the value of a given property." ; rdfs:label "Sub set of constraint component" ; sh:message "Must be one of the values of {$subSetOf}" ; sh:parameter dash:SubSetOfConstraintComponent-subSetOf ; sh:propertyValidator [ a sh:SPARQLAskValidator ; sh:ask """ASK { $this $subSetOf $value . }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSubSetOf" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:SubSetOfConstraintComponent-subSetOf a sh:Parameter ; sh:path dash:subSetOf ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "Can be used to state that all value nodes must also be values of a specified other property at the same focus node." ; sh:name "sub-set of" ; sh:nodeKind sh:IRI ; . dash:SuccessResult a rdfs:Class ; rdfs:comment "A result representing a successfully validated constraint." ; rdfs:label "Success result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SuccessTestCaseResult a rdfs:Class ; rdfs:comment "Represents a successful run of a test case." ; rdfs:label "Success test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:Suggestion a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of suggestions that modify a graph to \"fix\" the source of a validation result." ; rdfs:label "Suggestion" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionGenerator a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of objects that can generate suggestions (added or deleted triples) for a validation result of a given constraint component." ; rdfs:label "Suggestion generator" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionResult a rdfs:Class ; rdfs:comment "Class of results that have been produced as suggestions, not through SHACL validation. How the actual results are produced is up to implementers. Each instance of this class should have values for sh:focusNode, sh:resultMessage, sh:resultSeverity (suggested default: sh:Info), and dash:suggestion to point at one or more suggestions." ; rdfs:label "Suggestion result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SymmetricConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A contraint component for property shapes to validate that a property is symmetric. For symmetric properties, if A relates to B then B must relate to A." ; rdfs:label "Symmetric constraint component" ; sh:message "Symmetric value expected" ; sh:parameter dash:SymmetricConstraintComponent-symmetric ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateSymmetric" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this ?value { FILTER ($symmetric) . $this $PATH ?value . FILTER NOT EXISTS { ?value $PATH $this . } }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric a sh:Parameter ; sh:path dash:symmetric ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "If set to true then if A relates to B then B must relate to A." ; sh:maxCount 1 ; sh:name "symmetric" ; . dash:TestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class for results produced by running test cases." ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; . dash:TestEnvironment a rdfs:Class ; dash:abstract true ; rdfs:comment "Abstract base class for test environments, holding information on how to set up a test case." ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:TextAreaEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal." ; rdfs:label "Text area editor" ; . dash:TextAreaWithLangEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal and a drop down to select a language." ; rdfs:label "Text area with lang editor" ; . dash:TextFieldEditor a dash:SingleEditor ; rdfs:comment """A simple input field to enter the value of a literal, without the ability to change language or datatype. This is the fallback editor for any literal if no other editors are more suitable.""" ; rdfs:label "Text field editor" ; . dash:TextFieldWithLangEditor a dash:SingleEditor ; rdfs:comment "A single-line input field to enter the value of a literal and a drop down to select language, which is mandatory unless xsd:string is among the permissible datatypes." ; rdfs:label "Text field with lang editor" ; . dash:URIEditor a dash:SingleEditor ; rdfs:comment "An input field to enter the URI of a resource, e.g. rdfs:seeAlso links or images." ; rdfs:label "URI editor" ; . dash:URIViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "URI viewer" ; . dash:UniqueValueForClassConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment "A constraint component that can be used to state that the values of a property must be unique for all instances of a given class (and its subclasses)." ; rdfs:label "Unique value for class constraint component" ; sh:labelTemplate "Values must be unique among all instances of {?uniqueValueForClass}" ; sh:parameter dash:UniqueValueForClassConstraintComponent-uniqueValueForClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateUniqueValueForClass" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Value {?value} must be unique but is also used by {?other}" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Value {?value} must be unique but is also used by {?other}" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ?value ?other WHERE { { $this $PATH ?value . ?other $PATH ?value . FILTER (?other != $this) . } ?other a ?type . ?type rdfs:subClassOf* $uniqueValueForClass . }""" ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass a sh:Parameter ; sh:path dash:uniqueValueForClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "States that the values of the property must be unique for all instances of a given class (and its subclasses)." ; sh:name "unique value for class" ; sh:nodeKind sh:IRI ; . dash:UntrustedHTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML content from untrusted sources. This viewer will sanitize the HTML before rendering. Any a, button, checkbox, form, hidden, input, img, script, select, style and textarea tags and class and style attributes will be removed." ; rdfs:label "Untrusted HTML viewer" ; . dash:ValidationTestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Abstract superclass for test cases concerning SHACL constraint validation. Future versions may add new kinds of validatin test cases, e.g. to validate a single resource only." ; rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; . dash:ValueTableViewer a dash:MultiViewer ; rdfs:comment "A viewer that renders all values of a given property as a table, with one value per row, and the columns defined by the shape that is the sh:node or sh:class of the property." ; rdfs:label "Value table viewer" ; . dash:Viewer a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for viewing value nodes." ; rdfs:label "Viewer" ; rdfs:subClassOf dash:Widget ; . dash:Widget a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Base class of user interface components that can be used to display or edit value nodes." ; rdfs:label "Widget" ; rdfs:subClassOf rdfs:Resource ; . dash:abstract a rdf:Property ; rdfs:comment "Indicates that a class is \"abstract\" and cannot be used in asserted rdf:type triples. Only non-abstract subclasses of abstract classes should be instantiated directly." ; rdfs:domain rdfs:Class ; rdfs:label "abstract" ; rdfs:range xsd:boolean ; . dash:actionGroup a rdf:Property ; rdfs:comment "Links an Action with the ActionGroup that it should be arranged in." ; rdfs:domain dash:Action ; rdfs:label "action group" ; rdfs:range dash:ActionGroup ; . dash:actionIconClass a rdf:Property ; rdfs:comment "The (CSS) class of an Action for display purposes alongside the label." ; rdfs:domain dash:Action ; rdfs:label "action icon class" ; rdfs:range xsd:string ; . dash:addedTriple a rdf:Property ; rdfs:comment "May link a dash:GraphUpdate with one or more triples (represented as instances of rdf:Statement) that should be added to fix the source of the result." ; rdfs:domain dash:GraphUpdate ; rdfs:label "added triple" ; rdfs:range rdf:Statement ; . dash:all a rdfs:Resource ; rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . dash:apiStatus a rdf:Property ; rdfs:comment "Defines how and whether the associated feature is part of an external API. APIs may be implemented as (REST) web services, via GraphQL or ADS Script APIs." ; rdfs:label "API status" ; rdfs:range dash:APIStatus ; . dash:applicableToClass a rdf:Property ; rdfs:comment "Can be used to state that a shape is applicable to instances of a given class. This is a softer statement than \"target class\": a target means that all instances of the class must conform to the shape. Being applicable to simply means that the shape may apply to (some) instances of the class. This information can be used by algorithms or humans." ; rdfs:domain sh:Shape ; rdfs:label "applicable to class" ; rdfs:range rdfs:Class ; . dash:cachable a rdf:Property ; rdfs:comment "If set to true then the results of the SHACL function can be cached in between invocations with the same arguments. In other words, they are stateless and do not depend on triples in any graph, or the current time stamp etc." ; rdfs:domain sh:Function ; rdfs:label "cachable" ; rdfs:range xsd:boolean ; . dash:closedByTypes a rdf:Property ; rdfs:label "closed by types" ; . dash:coExistsWith a rdf:Property ; rdfs:comment "Specifies a property that must have a value whenever the property path has a value, and must have no value whenever the property path has no value." ; rdfs:label "co-exists with" ; rdfs:range rdf:Property ; . dash:composite a rdf:Property ; rdfs:comment "Can be used to indicate that a property/path represented by a property constraint represents a composite relationship. In a composite relationship, the life cycle of a \"child\" object (value of the property/path) depends on the \"parent\" object (focus node). If the parent gets deleted, then the child objects should be deleted, too. Tools may use dash:composite (if set to true) to implement cascading delete operations." ; rdfs:domain sh:PropertyShape ; rdfs:label "composite" ; rdfs:range xsd:boolean ; . dash:defaultLang a rdf:Property ; rdfs:comment "Can be used to annotate a graph (usually the owl:Ontology) with the default language that tools should suggest for new literal values. For example, predominantly
64
Misc bug fixes
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
67
<NME> dash.ttl <BEF> # baseURI: http://datashapes.org/dash # imports: http://topbraid.org/tosh # imports: http://www.w3.org/ns/shacl# # prefix: dash @prefix dash: <http://datashapes.org/dash#> . @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 tosh: <http://topbraid.org/tosh#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/dash> a owl:Ontology ; rdfs:comment "DASH is a SHACL library for frequently needed features and design patterns. The constraint components in this library are 100% standards compliant and will work on any engine that fully supports SHACL." ; rdfs:label "DASH Data Shapes Vocabulary" ; owl:imports <http://topbraid.org/tosh> ; owl:imports sh: ; sh:declare [ sh:namespace "http://datashapes.org/dash#"^^xsd:anyURI ; sh:prefix "dash" ; ] ; sh:declare [ sh:namespace "http://purl.org/dc/terms/"^^xsd:anyURI ; sh:prefix "dcterms" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ; sh:prefix "rdf" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2000/01/rdf-schema#"^^xsd:anyURI ; sh:prefix "rdfs" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2001/XMLSchema#"^^xsd:anyURI ; sh:prefix "xsd" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2002/07/owl#"^^xsd:anyURI ; sh:prefix "owl" ; ] ; sh:declare [ sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ; sh:prefix "skos" ; ] ; . dash:APIStatus a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of possible values for dash:apiStatus." ; rdfs:label "API Status" ; rdfs:subClassOf rdfs:Resource ; . dash:Action a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An executable command triggered by an agent, backed by a Script implementation. Actions may get deactivated using sh:deactivated." ; rdfs:label "Action" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ActionGroup a dash:ShapeClass ; rdfs:comment "A group of ResourceActions, used to arrange items in menus etc. Similar to sh:PropertyGroups, they may have a sh:order and should have labels (in multiple languages if applicable)." ; rdfs:label "Action group" ; rdfs:subClassOf rdfs:Resource ; . dash:ActionTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a dash:Action using provided input parameters. Requires exactly one value for dash:action and will operate on the test case's graph (with imports) as both data and shapes graph. Currently only supports read-only actions, allowing the comparison of actual results with the expected results.""" ; rdfs:label "Action test case" ; rdfs:subClassOf dash:TestCase ; . dash:AllObjects a dash:AllObjectsTarget ; rdfs:comment "A reusable instance of dash:AllObjectsTarget." ; rdfs:label "All objects" ; . dash:AllObjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all objects in the data graph as focus nodes." ; rdfs:label "All objects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allObjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All objects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?anyS ?anyP ?this . }""" ; . dash:AllSubjects a dash:AllSubjectsTarget ; rdfs:comment "A reusable instance of dash:AllSubjectsTarget." ; rdfs:label "All subjects" ; . dash:AllSubjectsTarget a sh:JSTargetType ; a sh:SPARQLTargetType ; rdfs:comment "A target containing all subjects in the data graph as focus nodes." ; rdfs:label "All subjects target" ; rdfs:subClassOf sh:Target ; sh:jsFunctionName "dash_allSubjects" ; sh:jsLibrary dash:DASHJSLibrary ; sh:labelTemplate "All subjects" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this ?anyP ?anyO . }""" ; . dash:AutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An auto-complete field to enter the label of instances of a class. This is the fallback editor for any URI resource if no other editors are more suitable." ; rdfs:label "Auto-complete editor" ; . dash:BlankNodeViewer a dash:SingleViewer ; rdfs:comment "A Viewer for blank nodes, rendering as the label of the blank node." ; rdfs:label "Blank node viewer" ; . dash:BooleanSelectEditor a dash:SingleEditor ; rdfs:comment """An editor for boolean literals, rendering as a select box with values true and false. Also displays the current value (such as \"1\"^^xsd:boolean), but only allows to switch to true or false.""" ; rdfs:label "Boolean select editor" ; . dash:ChangeScript a dash:ShapeClass ; rdfs:comment """Class of ADS scripts that are executed after edits to the data graph were made. These scripts may access the current changes from the graphs with names dataset.addedGraphURI and dataset.deletedGraphURI to learn about which resource values have been added or deleted. For example query them using graph.withDataGraph(dataset.addedGraphURI, ...) or via SPARQL's GRAPH keyword. Change scripts may then perform further changes which would again become visible to other change scripts. Change scripts are executed by their relative sh:order, with a default value of 0. Use lower values to execute before other rules.""" ; rdfs:label "Change script" ; rdfs:subClassOf dash:Script ; . dash:ClosedByTypesConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to declare that focus nodes are \"closed\" based on their rdf:types, meaning that focus nodes may only have values for the properties that are explicitly enumerated via sh:property/sh:path in property constraints at their rdf:types and the superclasses of those. This assumes that the type classes are also shapes." ; rdfs:label "Closed by types constraint component" ; sh:nodeValidator [ a sh:JSValidator ; sh:jsFunctionName "validateClosedByTypesNode" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Property is not among those permitted for any of the types" ; ] ; sh:nodeValidator [ a sh:SPARQLSelectValidator ; sh:message "Property {?path} is not among those permitted for any of the types" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this (?predicate AS ?path) ?value WHERE { FILTER ($closedByTypes) . $this ?predicate ?value . FILTER (?predicate != rdf:type) . FILTER NOT EXISTS { $this rdf:type ?type . ?type rdfs:subClassOf* ?class . GRAPH $shapesGraph { ?class sh:property/sh:path ?predicate . } } }""" ; ] ; sh:parameter dash:ClosedByTypesConstraintComponent-closedByTypes ; . dash:ClosedByTypesConstraintComponent-closedByTypes a sh:Parameter ; sh:path dash:closedByTypes ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to indicate that the focus nodes are closed by their types. A constraint violation is reported for each property value of the focus node where the property is not among those that are explicitly declared via sh:property/sh:path in any of the rdf:types of the focus node (and their superclasses). The property rdf:type is always permitted." ; sh:maxCount 1 ; . dash:CoExistsWithConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that if the property path has any value then the given property must also have a value, and vice versa." ; rdfs:label "Co-exists-with constraint component" ; sh:message "Values must co-exist with values of {$coExistsWith}" ; sh:parameter dash:CoExistsWithConstraintComponent-coExistsWith ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateCoExistsWith" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { { FILTER (EXISTS { $this $PATH ?any } && NOT EXISTS { $this $coExistsWith ?any }) } UNION { FILTER (NOT EXISTS { $this $PATH ?any } && EXISTS { $this $coExistsWith ?any }) } }""" ; ] ; . dash:CoExistsWithConstraintComponent-coExistsWith a sh:Parameter ; sh:path dash:coExistsWith ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "The properties that must co-exist with the surrounding property (path). If the surrounding property path has any value then the given property must also have a value, and vice versa." ; sh:name "co-exists with" ; sh:nodeKind sh:IRI ; . dash:ConstraintReificationShape a sh:NodeShape ; sh:name "expression" ; ] ; . dash:GraphUpdate rdf:type rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:subClassOf sh:Parameterizable ; . dash:DASHJSLibrary a sh:JSLibrary ; rdfs:label "DASH JavaScript library" ; sh:jsLibrary dash:RDFQueryJSLibrary ; sh:jsLibraryURL "http://datashapes.org/js/dash.js"^^xsd:anyURI ; . dash:DateOrDateTime a rdf:List ; rdf:first [ sh:datatype xsd:date ; ] ; rdf:rest ( [ sh:datatype xsd:dateTime ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:date or xsd:dateTime." ; rdfs:label "Date or date time" ; . dash:DatePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:date literals, offering a calendar-like date picker." ; rdfs:label "Date picker editor" ; . dash:DateTimePickerEditor a dash:SingleEditor ; rdfs:comment "An editor for xsd:dateTime literals, offering a calendar-like date picker and a time selector." ; rdfs:label "Date time picker editor" ; . dash:DepictionRole a dash:PropertyRole ; rdfs:comment "Depiction properties provide images representing the focus nodes. Typical examples may be a photo of an animal or the map of a country." ; rdfs:label "Depiction" ; . dash:Deprecated a dash:APIStatus ; rdfs:comment "Features that have been marked deprecated will remain in the API but should no longer be used by new code and may get deleted in the foreseeable future (e.g., with the next major release)." ; rdfs:label "deprecated" ; . dash:DescriptionRole a dash:PropertyRole ; rdfs:comment "Description properties should produce text literals that may be used as an introduction/summary of what a focus node does." ; rdfs:label "Description" ; . dash:DetailsEditor a dash:SingleEditor ; rdfs:comment "An editor for non-literal values, typically displaying a nested form where the values of the linked resource can be edited directly on the \"parent\" form. Implementations that do not support this (yet) could fall back to an auto-complete widget." ; rdfs:label "Details editor" ; . dash:DetailsViewer a dash:SingleViewer ; rdfs:comment "A Viewer for resources that shows the details of the value using its default view shape as a nested form-like display." ; rdfs:label "Details viewer" ; . dash:Editor a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for editing value nodes." ; rdfs:label "Editor" ; rdfs:subClassOf dash:Widget ; . dash:EnumSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for enumerated values (typically based on sh:in lists)." ; rdfs:label "Enum select editor" ; . dash:ExecutionPlatform a rdfs:Class ; rdfs:comment "An platform (such as TopBraid) that may have features needed to execute, for example, SPARQL queries." ; rdfs:label "Execution platform" ; rdfs:subClassOf rdfs:Resource ; . dash:Experimental a dash:APIStatus ; rdfs:comment "Features that are marked experimental can be used by early adopters but there is no guarantee that they will reach stable state." ; rdfs:label "experimental" ; . dash:ExploreAction a dash:ShapeClass ; rdfs:comment "An action typically showing up in an Explore section of a selected resource. Cannot make changes to the data." ; rdfs:label "Explore action" ; rdfs:subClassOf dash:ResourceAction ; . dash:FailureResult a rdfs:Class ; rdfs:comment "A result representing a validation failure such as an unsupported recursion." ; rdfs:label "Failure result" ; rdfs:subClassOf sh:AbstractResult ; . dash:FailureTestCaseResult a rdfs:Class ; rdfs:comment "Represents a failure of a test case." ; rdfs:label "Failure test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:FunctionTestCase a dash:ShapeClass ; rdfs:comment "A test case that verifies that a given SPARQL expression produces a given, expected result." ; rdfs:label "Function test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphService a dash:ShapeClass ; rdfs:comment "A service that does not apply to a specific resource (as ResourceService does) but operates on the whole graph. The focusNode variable will be the URI of the current base graph (e.g. <urn:x-evn-master:geo> as a NamedNode." ; rdfs:label "Graph service" ; rdfs:subClassOf dash:Service ; . dash:GraphStoreTestCase a dash:ShapeClass ; rdfs:comment "A test case that can be used to verify that an RDF file could be loaded (from a file) and that the resulting RDF graph is equivalent to a given TTL file." ; rdfs:label "Graph store test case" ; rdfs:subClassOf dash:TestCase ; . dash:GraphUpdate a rdfs:Class ; rdfs:comment "A suggestion consisting of added and/or deleted triples, represented as rdf:Statements via dash:addedTriple and dash:deletedTriple." ; rdfs:label "Graph update" ; rdfs:subClassOf dash:Suggestion ; . dash:GraphValidationTestCase a dash:ShapeClass ; rdfs:comment "A test case that performs SHACL constraint validation on the whole graph and compares the results with the expected validation results stored with the test case. By default this excludes meta-validation (i.e. the validation of the shape definitions themselves). If that's desired, set dash:validateShapes to true." ; rdfs:label "Graph validation test case" ; rdfs:subClassOf dash:ValidationTestCase ; . dash:HTMLOrStringOrLangString a rdf:List ; rdf:first [ sh:datatype rdf:HTML ; ] ; rdf:rest ( [ sh:datatype xsd:string ; ] [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either rdf:HTML, xsd:string or rdf:langString (in that order of preference)." ; rdfs:label "HTML or string or langString" ; . dash:HTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML encoded text from rdf:HTML literals, rendering as parsed HTML DOM elements. Also displays the language if the HTML has a lang attribute on its root DOM element." ; rdfs:label "HTML viewer" ; . dash:HasValueInConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be a member of a given list of nodes." ; rdfs:label "Has value in constraint component" ; sh:message "At least one of the values must be in {$hasValueIn}" ; sh:parameter dash:HasValueInConstraintComponent-hasValueIn ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . GRAPH $shapesGraph { $hasValueIn rdf:rest*/rdf:first ?value . } } }""" ; ] ; . dash:HasValueInConstraintComponent-hasValueIn a sh:Parameter ; sh:path dash:hasValueIn ; dash:reifiableBy dash:ConstraintReificationShape ; sh:description "At least one of the value nodes must be a member of the given list." ; sh:name "has value in" ; sh:node dash:ListShape ; . dash:HasValueTarget a sh:SPARQLTargetType ; rdfs:comment "A target type for all subjects where a given predicate has a certain object value." ; rdfs:label "Has Value target" ; rdfs:subClassOf sh:Target ; sh:labelTemplate "All subjects where {$predicate} has value {$object}" ; sh:parameter [ a sh:Parameter ; sh:path dash:object ; sh:description "The value that is expected to be present." ; sh:name "object" ; ] ; sh:parameter [ a sh:Parameter ; sh:path dash:predicate ; sh:description "The predicate property." ; sh:name "predicate" ; sh:nodeKind sh:IRI ; ] ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT ?this WHERE { ?this $predicate $object . }""" ; . dash:HasValueWithClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to express a constraint on property shapes so that one of the values of the property path must be an instance of a given class." ; rdfs:label "Has value with class constraint component" ; sh:message "At least one of the values must be an instance of class {$hasValueWithClass}" ; sh:parameter dash:HasValueWithClassConstraintComponent-hasValueWithClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateHasValueWithClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this WHERE { FILTER NOT EXISTS { $this $PATH ?value . ?value a ?type . ?type rdfs:subClassOf* $hasValueWithClass . } }""" ; ] ; . dash:HasValueWithClassConstraintComponent-hasValueWithClass a sh:Parameter ; sh:path dash:hasValueWithClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "One of the values of the property path must be an instance of the given class." ; sh:name "has value with class" ; sh:nodeKind sh:IRI ; . dash:HyperlinkViewer a dash:SingleViewer ; rdfs:comment """A Viewer for literals, rendering as a hyperlink to a URL. For literals it assumes the lexical form is the URL. This is often used as default viewer for xsd:anyURI literals. Unsupported for blank nodes.""" ; rdfs:label "Hyperlink viewer" ; . dash:IDRole a dash:PropertyRole ; rdfs:comment "ID properties are short strings or other literals that identify the focus node among siblings. Examples may include social security numbers." ; rdfs:label "ID" ; . dash:IconRole a dash:PropertyRole ; rdfs:comment """Icon properties produce images that are typically small and almost square-shaped, and that may be displayed in the upper left corner of a focus node's display. Values should be xsd:string or xsd:anyURI literals or IRI nodes pointing at URLs. Those URLs should ideally be vector graphics such as .svg files. Instances of the same class often have the same icon, and this icon may be computed using a sh:values rule or as sh:defaultValue. If the value is a relative URL then those should be resolved against the server that delivered the surrounding page.""" ; rdfs:label "Icon" ; . dash:ImageViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI values that are recognized as images by a browser, rendering as an image." ; rdfs:label "Image viewer" ; . dash:IncludedScript a dash:ShapeClass ; rdfs:comment """The code associated with instances of this class will get injected into the generated APIs, as global code snippets. Typically used to declare libraries of utility functions or constants that are (compared to shape scripts) not necessarily associated with specific classes or shapes. Note that the JavaScript code stored in dash:js cannot use the export keyword because the code must also work in external scripts (such as on Node.js). Instead, you need to enumerate the exported symbols via dash:exports.""" ; rdfs:label "Included script" ; rdfs:subClassOf dash:Script ; sh:property tosh:IncludedScript-exports ; . dash:IndexedConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to mark property shapes to be indexed, meaning that each of its value nodes must carry a dash:index from 0 to N." ; rdfs:label "Indexed constraint component" ; sh:parameter dash:IndexedConstraintComponent-indexed ; . dash:IndexedConstraintComponent-indexed a sh:Parameter ; sh:path dash:indexed ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to activate indexing for this property." ; sh:maxCount 1 ; sh:name "indexed" ; . dash:InferencingTestCase a dash:ShapeClass ; rdfs:comment "A test case to verify whether an inferencing engine is producing identical results to those stored as expected results." ; rdfs:label "Inferencing test case" ; rdfs:subClassOf dash:TestCase ; . dash:InlineViewer a dash:MultiViewer ; rdfs:comment "A multi-viewer that renders all values horizontally, in a more compact form that just a single value per row." ; rdfs:label "Inline viewer" ; . dash:InstancesSelectEditor a dash:SingleEditor ; rdfs:comment "A drop-down editor for all instances of the target class (based on sh:class of the property)." ; rdfs:label "Instances select editor" ; . dash:JSONTableViewer a dash:SingleViewer ; rdfs:comment """A tabular viewer for rdf:JSON literals with a lexical form in the following format: { vars: [ 'col1', 'col2' ], // These are the column keys headerLabels: [ 'Column 1', 'Column 2' ], // Optional, for the column headers bindings: [ // These become the rows { col1: { lex: 'Value2', datatype: '...#string', }, col2: { uri: 'http://.../Instance', label: 'Example Instance', }, }, ... ], } The resulting table will use the headerLabels (if they exist) as column headers, otherwise derive the headers from the variable names. The vars must match the fields in the bindings. The table will contain one row for each binding. Using Active Data Shapes, you can construct such literals dynamically using a sh:values rule, e.g. ex:MyClass-myProperty a sh:PropertyShape ; sh:path ex:myProperty ; sh:values [ dash:js \"\"\" DataViewers.createTableViewerJSON(focusNode.select(` SELECT ?col1 ?col2 WHERE { $this ex:prop1 ?col1 . $this ex:prop2 ?col2 . } `))\"\"\" ] . You may also produce the JSON literal programmatically in JavaScript, or assert the triples by other means.""" ; rdfs:label "JSON table viewer" ; . dash:JSTestCase a dash:ShapeClass ; rdfs:comment "A test case that calls a given SHACL-JS JavaScript function like a sh:JSFunction and compares its result with the dash:expectedResult." ; rdfs:label "SHACL-JS test case" ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:JSFunction ; . dash:KeyInfoRole a dash:PropertyRole ; rdfs:comment "The Key info role may be assigned to properties that are likely of special interest to a reader, so that they should appear whenever a summary of a focus node is shown." ; rdfs:label "Key info" ; . dash:LabelRole a dash:PropertyRole ; rdfs:comment "Properties with this role produce strings that may serve as display label for the focus nodes. Labels should be either plain string literals or strings with a language tag. The values should also be single-line." ; rdfs:label "Label" ; . dash:LabelViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI based on the display label of the resource. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "Label viewer" ; . dash:LangStringViewer a dash:SingleViewer ; rdfs:comment "A Viewer for literals with a language tag, rendering as the text plus a language indicator." ; rdfs:label "LangString viewer" ; . dash:ListNodeShape a sh:NodeShape ; rdfs:comment "Defines constraints on what it means for a node to be a node within a well-formed RDF list. Note that this does not check whether the rdf:rest items are also well-formed lists as this would lead to unsupported recursion." ; rdfs:label "List node shape" ; sh:or ( [ sh:hasValue () ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 0 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 0 ; ] ; ] [ sh:not [ sh:hasValue () ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:first ; sh:maxCount 1 ; sh:minCount 1 ; ] ; sh:property [ a sh:PropertyShape ; sh:path rdf:rest ; sh:maxCount 1 ; sh:minCount 1 ; ] ; ] ) ; . dash:ListShape a sh:NodeShape ; rdfs:comment """Defines constraints on what it means for a node to be a well-formed RDF list. The focus node must either be rdf:nil or not recursive. Furthermore, this shape uses dash:ListNodeShape as a \"helper\" to walk through all members of the whole list (including itself).""" ; rdfs:label "List shape" ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:ValidationTestCase rdf:type rdfs:Class ; rdf:type sh:NodeShape ; . dash:MultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """A multi-function is a function that can return zero or more result objects consisting of one or more result variables. While normal (SPARQL/SHACL) functions can only return a single result node, multi-functions may not only return multiple nodes but even multiple individual variables per solution. A common way of defining multi-functions is by wrapping a SPARQL SELECT query, using dash:SPARQLMultiFunction. However, some MultiFunctions (in TopBraid) may also be implemented natively.""" ; rdfs:label "Multi-function" ; rdfs:subClassOf sh:Parameterizable ; sh:nodeKind sh:IRI ; . dash:MultiViewer a dash:ShapeClass ; rdfs:comment "A viewer for multiple/all values at once." ; rdfs:label "Multi viewer" ; rdfs:subClassOf dash:Viewer ; . dash:NoSuitableEditor a dash:SingleEditor ; rdfs:comment "An \"editor\" that simply informs the user that the values cannot be edited here, but for example through source code editing." ; rdfs:label "No suitable editor" ; . dash:NodeExpressionViewer a dash:SingleViewer ; rdfs:comment "A viewer for SHACL Node Expressions."^^rdf:HTML ; rdfs:label "Node expression viewer" ; . dash:NonRecursiveConstraintComponent a sh:ConstraintComponent ; rdfs:comment "Used to state that a property or path must not point back to itself." ; rdfs:label "Non-recursive constraint component" ; sh:message "Points back at itself (recursively)" ; sh:parameter dash:NonRecursiveConstraintComponent-nonRecursive ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateNonRecursiveProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ($this AS ?value) WHERE { { FILTER (?nonRecursive) } $this $PATH $this . }""" ; ] ; . dash:NonRecursiveConstraintComponent-nonRecursive a sh:Parameter ; sh:path dash:nonRecursive ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description """Used to state that a property or path must not point back to itself. For example, \"a person cannot have itself as parent\" can be expressed by setting dash:nonRecursive=true for a given sh:path. To express that a person cannot have itself among any of its (recursive) parents, use a sh:path with the + operator such as ex:parent+.""" ; sh:maxCount 1 ; sh:name "non-recursive" ; . dash:None a sh:NodeShape ; rdfs:comment "A Shape that is no node can conform to." ; rdfs:label "None" ; sh:in () ; . dash:ParameterConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component that can be used to verify that all value nodes conform to the given Parameter."@en ; rdfs:label "Parameter constraint component"@en ; sh:parameter dash:ParameterConstraintComponent-parameter ; . dash:ParameterConstraintComponent-parameter a sh:Parameter ; sh:path sh:parameter ; . dash:PrimaryKeyConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "Enforces a constraint that the given property (sh:path) serves as primary key for all resources in the target of the shape. If a property has been declared to be the primary key then each resource must have exactly one value for that property. Furthermore, the URIs of those resources must start with a given string (dash:uriStart), followed by the URL-encoded primary key value. For example if dash:uriStart is \"http://example.org/country-\" and the primary key for an instance is \"de\" then the URI must be \"http://example.org/country-de\". Finally, as a result of the URI policy, there can not be any other resource with the same value under the same primary key policy." ; rdfs:label "Primary key constraint component" ; sh:labelTemplate "The property {?predicate} is the primary key and URIs start with {?uriStart}" ; sh:message "Violation of primary key constraint" ; sh:parameter dash:PrimaryKeyConstraintComponent-uriStart ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validatePrimaryKeyProperty" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this WHERE { FILTER ( # Must have a value for the primary key NOT EXISTS { ?this $PATH ?any } || # Must have no more than one value for the primary key EXISTS { ?this $PATH ?value1 . ?this $PATH ?value2 . FILTER (?value1 != ?value2) . } || # The value of the primary key must align with the derived URI EXISTS { { ?this $PATH ?value . FILTER NOT EXISTS { ?this $PATH ?value2 . FILTER (?value != ?value2) } } BIND (CONCAT($uriStart, ENCODE_FOR_URI(str(?value))) AS ?uri) . FILTER (str(?this) != ?uri) . } ) }""" ; ] ; . dash:PrimaryKeyConstraintComponent-uriStart a sh:Parameter ; sh:path dash:uriStart ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "The start of the URIs of well-formed resources. If specified then the associated property/path serves as \"primary key\" for all target nodes (instances). All such target nodes need to have a URI that starts with the given string, followed by the URI-encoded value of the primary key property." ; sh:maxCount 1 ; sh:name "URI start" ; . dash:PropertyAutoCompleteEditor a dash:SingleEditor ; rdfs:comment "An editor for properties that are either defined as instances of rdf:Property or used as IRI values of sh:path. The component uses auto-complete to find these properties by their rdfs:labels or sh:names." ; rdfs:label "Property auto-complete editor" ; . dash:PropertyLabelViewer a dash:SingleViewer ; rdfs:comment "A viewer for properties that renders a hyperlink using the display label or sh:name, allowing users to either navigate to the rdf:Property resource or the property shape definition. Should be used in conjunction with PropertyAutoCompleteEditor." ; rdfs:label "Property label viewer" ; . dash:PropertyRole a rdfs:Class ; a sh:NodeShape ; rdfs:comment "The class of roles that a property (shape) may take for its focus nodes." ; rdfs:label "Property role" ; rdfs:subClassOf rdfs:Resource ; . dash:QueryTestCase a dash:ShapeClass ; rdfs:comment "A test case running a given SPARQL SELECT query and comparing its results with those stored as JSON Result Set in the expected result property." ; rdfs:label "Query test case" ; rdfs:subClassOf dash:TestCase ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:RDFQueryJSLibrary a sh:JSLibrary ; rdfs:label "rdfQuery JavaScript Library" ; sh:jsLibraryURL "http://datashapes.org/js/rdfquery.js"^^xsd:anyURI ; . dash:ReifiableByConstraintComponent a sh:ConstraintComponent ; rdfs:label "Reifiable-by constraint component" ; sh:labelTemplate "Reifiable by {$reifiableBy}" ; sh:parameter dash:ReifiableByConstraintComponent-reifiableBy ; . dash:ReifiableByConstraintComponent-reifiableBy a sh:Parameter ; sh:path dash:reifiableBy ; sh:class sh:NodeShape ; sh:description "Can be used to specify the node shape that may be applied to reified statements produced by a property shape. The property shape must have a URI resource as its sh:path. The values of this property must be node shapes. User interfaces can use this information to determine which properties to present to users when reified statements are explored or edited. Also, SHACL validators can use it to determine how to validate reified triples. Use dash:None to indicate that no reification should be permitted." ; sh:maxCount 1 ; sh:name "reifiable by" ; sh:nodeKind sh:IRI ; . dash:ResourceAction a dash:ShapeClass ; dash:abstract true ; rdfs:comment "An Action that can be executed for a selected resource. Such Actions show up in context menus once they have been assigned a sh:group." ; rdfs:label "Resource action" ; rdfs:subClassOf dash:Action ; . dash:ResourceService a dash:ShapeClass ; rdfs:comment "A Service that can (and must) be applied to a given resource as focus node. Use dash:resourceService to link a class to the services that apply to its instances." ; rdfs:label "Resource service" ; rdfs:subClassOf dash:Service ; . dash:RichTextEditor a dash:SingleEditor ; rdfs:comment "A rich text editor to enter the lexical value of a literal and a drop down to select language. The selected language is stored in the HTML lang attribute of the root node in the HTML DOM tree." ; rdfs:label "Rich text editor" ; . dash:RootClassConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A constraint component defining the parameter dash:rootClass, which restricts the values to be either the root class itself or one of its subclasses. This is typically used in conjunction with properties that have rdfs:Class as their type." ; rdfs:label "Root class constraint component" ; sh:labelTemplate "Root class {$rootClass}" ; sh:message "Value must be subclass of {$rootClass}" ; sh:parameter dash:RootClassConstraintComponent-rootClass ; sh:validator dash:hasRootClass ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateRootClass" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:RootClassConstraintComponent-rootClass a sh:Parameter ; sh:path dash:rootClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "The root class." ; sh:name "root class" ; sh:nodeKind sh:IRI ; . dash:SPARQLConstructTemplate a rdfs:Class ; rdfs:comment "Encapsulates one or more SPARQL CONSTRUCT queries that can be parameterized. Parameters will become pre-bound variables in the queries." ; rdfs:label "SPARQL CONSTRUCT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLConstructExecutable ; . dash:SPARQLMultiFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment "A multi-function based on a SPARQL SELECT query. The query gets executed with the arguments pre-bound to the variables declared as parameters. The results of the multi-function are all result bindings from the SPARQL result set." ; rdfs:label "SPARQL multi-function" ; rdfs:subClassOf dash:MultiFunction ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLSelectTemplate a rdfs:Class ; rdfs:comment "Encapsulates a SPARQL SELECT query that can be parameterized. Parameters will become pre-bound variables in the query." ; rdfs:label "SPARQL SELECT template" ; rdfs:subClassOf sh:Parameterizable ; rdfs:subClassOf sh:SPARQLSelectExecutable ; . dash:SPARQLUpdateSuggestionGenerator a rdfs:Class ; rdfs:comment """A SuggestionGenerator based on a SPARQL UPDATE query (sh:update), producing an instance of dash:GraphUpdate. The INSERTs become dash:addedTriple and the DELETEs become dash:deletedTriple. The WHERE clause operates on the data graph with the pre-bound variables $focusNode, $predicate and $value, as well as the other pre-bound variables for the parameters of the constraint. In many cases, there may be multiple possible suggestions to fix a problem. For example, with sh:maxLength there are many ways to slice a string. In those cases, the system will first iterate through the result variables from a SELECT query (sh:select) and apply these results as pre-bound variables into the UPDATE query.""" ; rdfs:label "SPARQL UPDATE suggestion generator" ; rdfs:subClassOf dash:SuggestionGenerator ; rdfs:subClassOf sh:SPARQLSelectExecutable ; rdfs:subClassOf sh:SPARQLUpdateExecutable ; . dash:Script a dash:ShapeClass ; rdfs:comment "An executable unit implemented in one or more languages such as JavaScript." ; rdfs:label "Script" ; rdfs:subClassOf rdfs:Resource ; . dash:ScriptAPIGenerationRules a sh:PropertyGroup ; rdfs:label "Script API Generation Rules" ; . dash:ScriptAPIShape a sh:NodeShape ; rdfs:comment "Defines the properties that instruct the ADS Script API generator about what prefixes, constants and classes to generate." ; rdfs:label "Script API" ; sh:property dash:ScriptAPIShape-generateClass ; sh:property dash:ScriptAPIShape-generatePrefixClasses ; sh:property dash:ScriptAPIShape-generatePrefixConstants ; sh:targetClass owl:Ontology ; . dash:ScriptAPIShape-generateClass a sh:PropertyShape ; sh:path dash:generateClass ; sh:class sh:NodeShape ; sh:description "The API generator will produce classes for each value of this property and all its subclasses and superclasses." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate class" ; sh:nodeKind sh:IRI ; sh:order "0"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixClasses a sh:PropertyShape ; sh:path dash:generatePrefixClasses ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce classes for all RDFS classes or node shapes from the associated namespace." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix classes" ; sh:order "15"^^xsd:decimal ; . dash:ScriptAPIShape-generatePrefixConstants a sh:PropertyShape ; sh:path dash:generatePrefixConstants ; sh:datatype xsd:string ; sh:description "If a prefix (such as \"edg\") is listed here then the API generator will produce constants for class, datatype, shape and property names." ; sh:group dash:ScriptAPIGenerationRules ; sh:name "generate prefix constants" ; sh:order "10"^^xsd:decimal ; . dash:ScriptConstraint a dash:ShapeClass ; rdfs:comment """The class of constraints that are based on Scripts. Depending on whether dash:onAllValues is set to true, these scripts can access the following pre-assigned variables: - focusNode: the focus node of the constraint (a NamedNode) - if dash:onAllValues is not true: value: the current value node (e.g. a JavaScript string for xsd:string literals, a number for numeric literals or true or false for xsd:boolean literals. All other literals become LiteralNodes, and non-literals become instances of NamedNode) - if dash:onAllValues is true: values: an array of current value nodes, as above. If the expression returns an array then each array member will be mapped to one validation result, following the mapping rules below. For string results, a validation result will use the string as sh:resultMessage. For boolean results, a validation result will be produced if the result is false (true means no violation). For object results, a validation result will be produced using the value of the field \"message\" of the object as result message. If the field \"value\" has a value then this will become the sh:value in the violation. Unless another sh:message has been directly returned, the sh:message of the dash:ScriptConstraint will be used, similar to sh:message at SPARQL Constraints. These sh:messages can access the values {$focusNode}, {$value} etc as template variables.""" ; rdfs:label "Script constraint" ; rdfs:subClassOf dash:Script ; . dash:ScriptConstraintComponent a sh:ConstraintComponent ; rdfs:label "Script constraint component" ; sh:parameter dash:ScriptConstraintComponent-scriptConstraint ; . dash:ScriptConstraintComponent-scriptConstraint a sh:Parameter ; sh:path dash:scriptConstraint ; sh:class dash:ScriptConstraint ; sh:description "The Script constraint(s) to apply." ; sh:name "script constraint" ; . dash:ScriptFunction a rdfs:Class ; a sh:NodeShape ; rdfs:comment """Script functions can be used from SPARQL queries and will be injected into the generated prefix object (in JavaScript, for ADS scripts). The dash:js will be inserted into a generated JavaScript function and therefore needs to use the return keyword to produce results. These JS snippets can access the parameter values based on the local name of the sh:Parameter's path. For example ex:value can be accessed using value. SPARQL use note: Since these functions may be used from any data graph and any shapes graph, they must not rely on any API apart from what's available in the shapes graph that holds the rdf:type triple of the function itself. In other words, at execution time from SPARQL, the ADS shapes graph will be the home graph of the function's declaration.""" ; rdfs:label "Script function" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Function ; . dash:ScriptSuggestionGenerator a dash:ShapeClass ; rdfs:comment """A Suggestion Generator that is backed by an Active Data Shapes script. The script needs to return a JSON object or an array of JSON objects if it shall generate multiple suggestions. It may also return null to indicate that nothing was suggested. Note that the whole script is evaluated as a (JavaScript) expression, and those will use the last value as result. So simply putting an object at the end of your script should do. Alternatively, define the bulk of the operation as a function and simply call that function in the script. Each response object can have the following fields: { message: \"The human readable message\", // Defaults to the rdfs:label(s) of the suggestion generator add: [ // An array of triples to add, each triple as an array with three nodes [ subject, predicate, object ], [ ... ] ], delete: [ ... like add, for the triples to delete ] } Suggestions with neither added nor deleted triples will be discarded. At execution time, the script operates on the data graph as the active graph, with the following pre-bound variables: - focusNode: the NamedNode that is the sh:focusNode of the validation result - predicate: the NamedNode representing the predicate of the validation result, assuming sh:resultPath is a URI - value: the value node from the validation result's sh:value, cast into the most suitable JS object - the other pre-bound variables for the parameters of the constraint, e.g. in a sh:maxCount constraint it would be maxCount The script will be executed in read-only mode, i.e. it cannot modify the graph. Example with dash:js: ({ message: `Copy labels into ${graph.localName(predicate)}`, add: focusNode.values(rdfs.label).map(label => [ focusNode, predicate, label ] ) })""" ; rdfs:label "Script suggestion generator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:SuggestionGenerator ; . dash:ScriptTestCase a dash:ShapeClass ; rdfs:comment """A test case that evaluates a script. Requires exactly one value for dash:js and will operate on the test case's graph (with imports) as both data and shapes graph. Supports read-only scripts only at this stage.""" ; rdfs:label "Script test case" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf dash:TestCase ; . dash:ScriptValidator a dash:ShapeClass ; rdfs:comment """A SHACL validator based on an Active Data Shapes script. See the comment at dash:ScriptConstraint for the basic evaluation approach. Note that in addition to focusNode and value/values, the script can access pre-bound variables for each declared argument of the constraint component.""" ; rdfs:label "Script validator" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Validator ; . dash:Service a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A script that gets exposed as a web service, e.g. /tbl/service/ex/MyService" ; rdfs:label "Service" ; rdfs:subClassOf dash:Script ; rdfs:subClassOf sh:Parameterizable ; . dash:ShapeClass a dash:ShapeClass ; dash:hidden true ; rdfs:comment "A class that is also a node shape. This class can be used as rdf:type instead of the combination of rdfs:Class and sh:NodeShape." ; rdfs:label "Shape class" ; rdfs:subClassOf rdfs:Class ; WHERE { }""" ; . dash:validateShapes rdf:type rdf:Property ; rdfs:comment "True to also validate the shapes itself (i.e. parameter declarations)." ; rdfs:comment "An editor for individual value nodes." ; rdfs:label "Single editor" ; rdfs:subClassOf dash:Editor ; . dash:SingleLineConstraintComponent a sh:ConstraintComponent ; rdfs:comment """A constraint component that can be used to declare that all values that are literals must have a lexical form that contains no line breaks ('\\n' or '\\r'). User interfaces may use the dash:singleLine flag to prefer a text field over a (multi-line) text area.""" ; rdfs:label "Single line constraint component" ; sh:message "Must not contain line breaks." ; sh:parameter dash:SingleLineConstraintComponent-singleLine ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSingleLine" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:ask """ASK { FILTER (!$singleLine || !isLiteral($value) || (!contains(str($value), '\\n') && !contains(str($value), '\\r'))) }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; . dash:SingleLineConstraintComponent-singleLine a sh:Parameter ; sh:path dash:singleLine ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "True to state that the lexical form of literal value nodes must not contain any line breaks. False to state that line breaks are explicitly permitted." ; sh:group tosh:StringConstraintsPropertyGroup ; sh:maxCount 1 ; sh:name "single line" ; sh:order "30"^^xsd:decimal ; . dash:SingleViewer a dash:ShapeClass ; rdfs:comment "A viewer for a single value." ; rdfs:label "Single viewer" ; rdfs:subClassOf dash:Viewer ; . dash:Stable a dash:APIStatus ; rdfs:comment "Features that have been marked stable are deemed of good quality and can be used until marked deprecated." ; rdfs:label "stable" ; . dash:StemConstraintComponent a sh:ConstraintComponent ; dash:staticConstraint true ; rdfs:comment "A constraint component that can be used to verify that every value node is an IRI and the IRI starts with a given string value."@en ; rdfs:label "Stem constraint component"@en ; sh:labelTemplate "Value needs to have stem {$stem}" ; sh:message "Value does not have stem {$stem}" ; sh:parameter dash:StemConstraintComponent-stem ; sh:validator dash:hasStem ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateStem" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:StemConstraintComponent-stem a sh:Parameter ; sh:path dash:stem ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:string ; sh:description "If specified then every value node must be an IRI and the IRI must start with the given string value." ; sh:maxCount 1 ; sh:name "stem" ; . dash:StringOrLangString a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string or rdf:langString." ; rdfs:label "String or langString" ; . dash:StringOrLangStringOrHTML a rdf:List ; rdf:first [ sh:datatype xsd:string ; ] ; rdf:rest ( [ sh:datatype rdf:langString ; ] [ sh:datatype rdf:HTML ; ] ) ; rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string, rdf:langString or rdf:HTML (in that order of preference)." ; rdfs:label "string or langString or HTML" ; . dash:SubClassEditor a dash:SingleEditor ; rdfs:comment "An editor for properties that declare a dash:rootClass. The editor allows selecting either the class itself or one of its subclasses." ; rdfs:label "Sub-Class editor" ; . dash:SubSetOfConstraintComponent a sh:ConstraintComponent ; dash:localConstraint true ; rdfs:comment "A constraint component that can be used to state that the set of value nodes must be a subset of the value of a given property." ; rdfs:label "Sub set of constraint component" ; sh:message "Must be one of the values of {$subSetOf}" ; sh:parameter dash:SubSetOfConstraintComponent-subSetOf ; sh:propertyValidator [ a sh:SPARQLAskValidator ; sh:ask """ASK { $this $subSetOf $value . }""" ; sh:prefixes <http://datashapes.org/dash> ; ] ; sh:validator [ a sh:JSValidator ; sh:jsFunctionName "validateSubSetOf" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; . dash:SubSetOfConstraintComponent-subSetOf a sh:Parameter ; sh:path dash:subSetOf ; dash:editor dash:PropertyAutoCompleteEditor ; dash:reifiableBy dash:ConstraintReificationShape ; dash:viewer dash:PropertyLabelViewer ; sh:description "Can be used to state that all value nodes must also be values of a specified other property at the same focus node." ; sh:name "sub-set of" ; sh:nodeKind sh:IRI ; . dash:SuccessResult a rdfs:Class ; rdfs:comment "A result representing a successfully validated constraint." ; rdfs:label "Success result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SuccessTestCaseResult a rdfs:Class ; rdfs:comment "Represents a successful run of a test case." ; rdfs:label "Success test case result" ; rdfs:subClassOf dash:TestCaseResult ; . dash:Suggestion a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of suggestions that modify a graph to \"fix\" the source of a validation result." ; rdfs:label "Suggestion" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionGenerator a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class of objects that can generate suggestions (added or deleted triples) for a validation result of a given constraint component." ; rdfs:label "Suggestion generator" ; rdfs:subClassOf rdfs:Resource ; . dash:SuggestionResult a rdfs:Class ; rdfs:comment "Class of results that have been produced as suggestions, not through SHACL validation. How the actual results are produced is up to implementers. Each instance of this class should have values for sh:focusNode, sh:resultMessage, sh:resultSeverity (suggested default: sh:Info), and dash:suggestion to point at one or more suggestions." ; rdfs:label "Suggestion result" ; rdfs:subClassOf sh:AbstractResult ; . dash:SymmetricConstraintComponent a sh:ConstraintComponent ; rdfs:comment "A contraint component for property shapes to validate that a property is symmetric. For symmetric properties, if A relates to B then B must relate to A." ; rdfs:label "Symmetric constraint component" ; sh:message "Symmetric value expected" ; sh:parameter dash:SymmetricConstraintComponent-symmetric ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateSymmetric" ; sh:jsLibrary dash:DASHJSLibrary ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT $this ?value { FILTER ($symmetric) . $this $PATH ?value . FILTER NOT EXISTS { ?value $PATH $this . } }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric a sh:Parameter ; sh:path dash:symmetric ; dash:reifiableBy dash:ConstraintReificationShape ; sh:datatype xsd:boolean ; sh:description "If set to true then if A relates to B then B must relate to A." ; sh:maxCount 1 ; sh:name "symmetric" ; . dash:TestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "A test case to verify that a (SHACL-based) feature works as expected." ; rdfs:label "Test case" ; rdfs:subClassOf rdfs:Resource ; . dash:TestCaseResult a rdfs:Class ; dash:abstract true ; rdfs:comment "Base class for results produced by running test cases." ; rdfs:label "Test case result" ; rdfs:subClassOf sh:AbstractResult ; . dash:TestEnvironment a rdfs:Class ; dash:abstract true ; rdfs:comment "Abstract base class for test environments, holding information on how to set up a test case." ; rdfs:label "Test environment" ; rdfs:subClassOf rdfs:Resource ; . dash:TextAreaEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal." ; rdfs:label "Text area editor" ; . dash:TextAreaWithLangEditor a dash:SingleEditor ; rdfs:comment "A multi-line text area to enter the value of a literal and a drop down to select a language." ; rdfs:label "Text area with lang editor" ; . dash:TextFieldEditor a dash:SingleEditor ; rdfs:comment """A simple input field to enter the value of a literal, without the ability to change language or datatype. This is the fallback editor for any literal if no other editors are more suitable.""" ; rdfs:label "Text field editor" ; . dash:TextFieldWithLangEditor a dash:SingleEditor ; rdfs:comment "A single-line input field to enter the value of a literal and a drop down to select language, which is mandatory unless xsd:string is among the permissible datatypes." ; rdfs:label "Text field with lang editor" ; . dash:URIEditor a dash:SingleEditor ; rdfs:comment "An input field to enter the URI of a resource, e.g. rdfs:seeAlso links or images." ; rdfs:label "URI editor" ; . dash:URIViewer a dash:SingleViewer ; rdfs:comment "A Viewer for URI resources, rendering as a hyperlink to that URI. Also includes other ways of interacting with the URI such as opening a nested summary display." ; rdfs:label "URI viewer" ; . dash:UniqueValueForClassConstraintComponent a sh:ConstraintComponent ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; rdfs:comment "A constraint component that can be used to state that the values of a property must be unique for all instances of a given class (and its subclasses)." ; rdfs:label "Unique value for class constraint component" ; sh:labelTemplate "Values must be unique among all instances of {?uniqueValueForClass}" ; sh:parameter dash:UniqueValueForClassConstraintComponent-uniqueValueForClass ; sh:propertyValidator [ a sh:JSValidator ; sh:jsFunctionName "validateUniqueValueForClass" ; sh:jsLibrary dash:DASHJSLibrary ; sh:message "Value {?value} must be unique but is also used by {?other}" ; ] ; sh:propertyValidator [ a sh:SPARQLSelectValidator ; sh:message "Value {?value} must be unique but is also used by {?other}" ; sh:prefixes <http://datashapes.org/dash> ; sh:select """SELECT DISTINCT $this ?value ?other WHERE { { $this $PATH ?value . ?other $PATH ?value . FILTER (?other != $this) . } ?other a ?type . ?type rdfs:subClassOf* $uniqueValueForClass . }""" ; ] ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass a sh:Parameter ; sh:path dash:uniqueValueForClass ; dash:reifiableBy dash:ConstraintReificationShape ; sh:class rdfs:Class ; sh:description "States that the values of the property must be unique for all instances of a given class (and its subclasses)." ; sh:name "unique value for class" ; sh:nodeKind sh:IRI ; . dash:UntrustedHTMLViewer a dash:SingleViewer ; rdfs:comment "A Viewer for HTML content from untrusted sources. This viewer will sanitize the HTML before rendering. Any a, button, checkbox, form, hidden, input, img, script, select, style and textarea tags and class and style attributes will be removed." ; rdfs:label "Untrusted HTML viewer" ; . dash:ValidationTestCase a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Abstract superclass for test cases concerning SHACL constraint validation. Future versions may add new kinds of validatin test cases, e.g. to validate a single resource only." ; rdfs:label "Validation test case" ; rdfs:subClassOf dash:TestCase ; . dash:ValueTableViewer a dash:MultiViewer ; rdfs:comment "A viewer that renders all values of a given property as a table, with one value per row, and the columns defined by the shape that is the sh:node or sh:class of the property." ; rdfs:label "Value table viewer" ; . dash:Viewer a dash:ShapeClass ; dash:abstract true ; rdfs:comment "The class of widgets for viewing value nodes." ; rdfs:label "Viewer" ; rdfs:subClassOf dash:Widget ; . dash:Widget a dash:ShapeClass ; dash:abstract true ; rdfs:comment "Base class of user interface components that can be used to display or edit value nodes." ; rdfs:label "Widget" ; rdfs:subClassOf rdfs:Resource ; . dash:abstract a rdf:Property ; rdfs:comment "Indicates that a class is \"abstract\" and cannot be used in asserted rdf:type triples. Only non-abstract subclasses of abstract classes should be instantiated directly." ; rdfs:domain rdfs:Class ; rdfs:label "abstract" ; rdfs:range xsd:boolean ; . dash:actionGroup a rdf:Property ; rdfs:comment "Links an Action with the ActionGroup that it should be arranged in." ; rdfs:domain dash:Action ; rdfs:label "action group" ; rdfs:range dash:ActionGroup ; . dash:actionIconClass a rdf:Property ; rdfs:comment "The (CSS) class of an Action for display purposes alongside the label." ; rdfs:domain dash:Action ; rdfs:label "action icon class" ; rdfs:range xsd:string ; . dash:addedTriple a rdf:Property ; rdfs:comment "May link a dash:GraphUpdate with one or more triples (represented as instances of rdf:Statement) that should be added to fix the source of the result." ; rdfs:domain dash:GraphUpdate ; rdfs:label "added triple" ; rdfs:range rdf:Statement ; . dash:all a rdfs:Resource ; rdfs:comment "Represents all users/roles, for example as a possible value of the default view for role property." ; rdfs:label "all" ; . dash:apiStatus a rdf:Property ; rdfs:comment "Defines how and whether the associated feature is part of an external API. APIs may be implemented as (REST) web services, via GraphQL or ADS Script APIs." ; rdfs:label "API status" ; rdfs:range dash:APIStatus ; . dash:applicableToClass a rdf:Property ; rdfs:comment "Can be used to state that a shape is applicable to instances of a given class. This is a softer statement than \"target class\": a target means that all instances of the class must conform to the shape. Being applicable to simply means that the shape may apply to (some) instances of the class. This information can be used by algorithms or humans." ; rdfs:domain sh:Shape ; rdfs:label "applicable to class" ; rdfs:range rdfs:Class ; . dash:cachable a rdf:Property ; rdfs:comment "If set to true then the results of the SHACL function can be cached in between invocations with the same arguments. In other words, they are stateless and do not depend on triples in any graph, or the current time stamp etc." ; rdfs:domain sh:Function ; rdfs:label "cachable" ; rdfs:range xsd:boolean ; . dash:closedByTypes a rdf:Property ; rdfs:label "closed by types" ; . dash:coExistsWith a rdf:Property ; rdfs:comment "Specifies a property that must have a value whenever the property path has a value, and must have no value whenever the property path has no value." ; rdfs:label "co-exists with" ; rdfs:range rdf:Property ; . dash:composite a rdf:Property ; rdfs:comment "Can be used to indicate that a property/path represented by a property constraint represents a composite relationship. In a composite relationship, the life cycle of a \"child\" object (value of the property/path) depends on the \"parent\" object (focus node). If the parent gets deleted, then the child objects should be deleted, too. Tools may use dash:composite (if set to true) to implement cascading delete operations." ; rdfs:domain sh:PropertyShape ; rdfs:label "composite" ; rdfs:range xsd:boolean ; . dash:defaultLang a rdf:Property ; rdfs:comment "Can be used to annotate a graph (usually the owl:Ontology) with the default language that tools should suggest for new literal values. For example, predominantly
64
Misc bug fixes
0
.ttl
ttl
apache-2.0
TopQuadrant/shacl
68
<NME> personexample.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/complex/personexample.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/complex/personexample.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/complex/personexample.test> rdf:type owl:Ontology ; rdfs:label "Test of personexample" ; owl:imports <http://datashapes.org/dash> ; owl:versionInfo "Created with TopBraid Composer" ; . ex:Alice rdf:type ex:Person ; ex:ssn "987-65-432A" ; . ex:Bob rdf:type ex:Person ; ex:ssn "123-45-6789" ; ex:ssn "124-35-6789" ; . ex:Calvin rdf:type ex:Person ; ex:birthDate "1999-09-09"^^xsd:date ; ex:worksFor ex:UntypedCompany ; . 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:Alice ; sh:resultPath ex:ssn ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:PatternConstraintComponent ; sh:sourceShape _:b1 ; sh:value "987-65-432A" ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Bob ; sh:resultPath ex:ssn ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; sh:sourceShape _:b1 ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Calvin ; sh:resultPath ex:birthDate ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClosedConstraintComponent ; sh:value "1999-09-09"^^xsd:date ; sh:sourceShape ex:PersonShape ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Calvin ; sh:resultPath ex:worksFor ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClassConstraintComponent ; sh:sourceShape [] ; sh:value ex:UntypedCompany ; ] ; ] ; . ex:PersonShape rdf:type sh:NodeShape ; sh:closed "true"^^xsd:boolean ; sh:ignoredProperties ( rdf:type ) ; sh:property [ sh:path ex:ssn ; sh:datatype xsd:string ; sh:maxCount 1 ; sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; ] ; sh:property [ sh:path ex:worksFor ; sh:class ex:Company ; sh:nodeKind sh:IRI ; ] ; sh:property [ sh:path [ sh:inversePath ex:worksFor ; ] ; sh:name "employee" ; ] ; sh:targetClass ex:Person ; . <MSG> Merge pull request #49 from ashleysommer/patch-1 fix personexample.test.ttl <DFF> @@ -67,7 +67,7 @@ ex:GraphValidationTestCase sh:resultPath ex:worksFor ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClassConstraintComponent ; - sh:sourceShape [] ; + sh:sourceShape _:b2 ; sh:value ex:UntypedCompany ; ] ; ] ; @@ -78,17 +78,8 @@ ex:PersonShape sh:ignoredProperties ( rdf:type ) ; - sh:property [ - sh:path ex:ssn ; - sh:datatype xsd:string ; - sh:maxCount 1 ; - sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; - ] ; - sh:property [ - sh:path ex:worksFor ; - sh:class ex:Company ; - sh:nodeKind sh:IRI ; - ] ; + sh:property _:b1 ; + sh:property _:b2 ; sh:property [ sh:path [ sh:inversePath ex:worksFor ; @@ -97,3 +88,16 @@ ex:PersonShape ] ; sh:targetClass ex:Person ; . +_:b1 + sh:path ex:ssn ; + sh:datatype xsd:string ; + sh:maxCount 1 ; + sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; + sh:message "SSN must be 3 digits - 2 digits - 4 digits." +. + +_:b2 + sh:path ex:worksFor ; + sh:class ex:Company ; + sh:nodeKind sh:IRI +.
16
Merge pull request #49 from ashleysommer/patch-1
12
.ttl
test
apache-2.0
TopQuadrant/shacl
69
<NME> personexample.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/complex/personexample.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/complex/personexample.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/complex/personexample.test> rdf:type owl:Ontology ; rdfs:label "Test of personexample" ; owl:imports <http://datashapes.org/dash> ; owl:versionInfo "Created with TopBraid Composer" ; . ex:Alice rdf:type ex:Person ; ex:ssn "987-65-432A" ; . ex:Bob rdf:type ex:Person ; ex:ssn "123-45-6789" ; ex:ssn "124-35-6789" ; . ex:Calvin rdf:type ex:Person ; ex:birthDate "1999-09-09"^^xsd:date ; ex:worksFor ex:UntypedCompany ; . 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:Alice ; sh:resultPath ex:ssn ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:PatternConstraintComponent ; sh:sourceShape _:b1 ; sh:value "987-65-432A" ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Bob ; sh:resultPath ex:ssn ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; sh:sourceShape _:b1 ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Calvin ; sh:resultPath ex:birthDate ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClosedConstraintComponent ; sh:value "1999-09-09"^^xsd:date ; sh:sourceShape ex:PersonShape ; ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:Calvin ; sh:resultPath ex:worksFor ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClassConstraintComponent ; sh:sourceShape [] ; sh:value ex:UntypedCompany ; ] ; ] ; . ex:PersonShape rdf:type sh:NodeShape ; sh:closed "true"^^xsd:boolean ; sh:ignoredProperties ( rdf:type ) ; sh:property [ sh:path ex:ssn ; sh:datatype xsd:string ; sh:maxCount 1 ; sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; ] ; sh:property [ sh:path ex:worksFor ; sh:class ex:Company ; sh:nodeKind sh:IRI ; ] ; sh:property [ sh:path [ sh:inversePath ex:worksFor ; ] ; sh:name "employee" ; ] ; sh:targetClass ex:Person ; . <MSG> Merge pull request #49 from ashleysommer/patch-1 fix personexample.test.ttl <DFF> @@ -67,7 +67,7 @@ ex:GraphValidationTestCase sh:resultPath ex:worksFor ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:ClassConstraintComponent ; - sh:sourceShape [] ; + sh:sourceShape _:b2 ; sh:value ex:UntypedCompany ; ] ; ] ; @@ -78,17 +78,8 @@ ex:PersonShape sh:ignoredProperties ( rdf:type ) ; - sh:property [ - sh:path ex:ssn ; - sh:datatype xsd:string ; - sh:maxCount 1 ; - sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; - ] ; - sh:property [ - sh:path ex:worksFor ; - sh:class ex:Company ; - sh:nodeKind sh:IRI ; - ] ; + sh:property _:b1 ; + sh:property _:b2 ; sh:property [ sh:path [ sh:inversePath ex:worksFor ; @@ -97,3 +88,16 @@ ex:PersonShape ] ; sh:targetClass ex:Person ; . +_:b1 + sh:path ex:ssn ; + sh:datatype xsd:string ; + sh:maxCount 1 ; + sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; + sh:message "SSN must be 3 digits - 2 digits - 4 digits." +. + +_:b2 + sh:path ex:worksFor ; + sh:class ex:Company ; + sh:nodeKind sh:IRI +.
16
Merge pull request #49 from ashleysommer/patch-1
12
.ttl
test
apache-2.0
TopQuadrant/shacl
70
<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 NativeScope = ResourceFactory.createResource(NS + "NativeScope"); public final static Resource OrConstraint = ResourceFactory.createResource(NS + "OrConstraint"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); 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> Generalized focus node to also work for literals, added experimental sh:NodeConstraint support <DFF> @@ -59,6 +59,8 @@ public class SH { public final static Resource NativeScope = ResourceFactory.createResource(NS + "NativeScope"); + public final static Resource NodeConstraintTemplate = ResourceFactory.createResource(NS + "NodeConstraintTemplate"); + public final static Resource OrConstraint = ResourceFactory.createResource(NS + "OrConstraint"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint");
2
Generalized focus node to also work for literals, added experimental sh:NodeConstraint support
0
.java
java
apache-2.0
TopQuadrant/shacl
71
<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 NativeScope = ResourceFactory.createResource(NS + "NativeScope"); public final static Resource OrConstraint = ResourceFactory.createResource(NS + "OrConstraint"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); 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> Generalized focus node to also work for literals, added experimental sh:NodeConstraint support <DFF> @@ -59,6 +59,8 @@ public class SH { public final static Resource NativeScope = ResourceFactory.createResource(NS + "NativeScope"); + public final static Resource NodeConstraintTemplate = ResourceFactory.createResource(NS + "NodeConstraintTemplate"); + public final static Resource OrConstraint = ResourceFactory.createResource(NS + "OrConstraint"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint");
2
Generalized focus node to also work for literals, added experimental sh:NodeConstraint support
0
.java
java
apache-2.0
TopQuadrant/shacl
72
<NME> hasValue-001.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/node/hasValue-001.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/node/hasValue-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/node/hasValue-001.test> rdf:type owl:Ontology ; rdfs:label "Test of sh:hasValue at node shape 001" ; owl:imports <http://datashapes.org/dash> ; owl:versionInfo "Created with TopBraid Composer" ; . 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 "Invalid String" ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:HasValueConstraintComponent ; sh:sourceShape ex:TestShape ; sh:value "Invalid String" ; ] ; ] ; . ex:TestShape rdf:type sh:NodeShape ; rdfs:label "Test shape" ; sh:hasValue "Test" ; sh:targetNode "Invalid String" ; sh:targetNode "Test" ; . <MSG> Updated a test case and consequential logic <DFF> @@ -27,7 +27,6 @@ ex:GraphValidationTestCase sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:HasValueConstraintComponent ; sh:sourceShape ex:TestShape ; - sh:value "Invalid String" ; ] ; ] ; .
0
Updated a test case and consequential logic
1
.ttl
test
apache-2.0
TopQuadrant/shacl
73
<NME> hasValue-001.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/core/node/hasValue-001.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/core/node/hasValue-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/node/hasValue-001.test> rdf:type owl:Ontology ; rdfs:label "Test of sh:hasValue at node shape 001" ; owl:imports <http://datashapes.org/dash> ; owl:versionInfo "Created with TopBraid Composer" ; . 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 "Invalid String" ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:HasValueConstraintComponent ; sh:sourceShape ex:TestShape ; sh:value "Invalid String" ; ] ; ] ; . ex:TestShape rdf:type sh:NodeShape ; rdfs:label "Test shape" ; sh:hasValue "Test" ; sh:targetNode "Invalid String" ; sh:targetNode "Test" ; . <MSG> Updated a test case and consequential logic <DFF> @@ -27,7 +27,6 @@ ex:GraphValidationTestCase sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:HasValueConstraintComponent ; sh:sourceShape ex:TestShape ; - sh:value "Invalid String" ; ] ; ] ; .
0
Updated a test case and consequential logic
1
.ttl
test
apache-2.0
TopQuadrant/shacl
74
<NME> RuleExample.java <BEF> ADDFILE <MSG> Merge pull request #89 from fekaputra/master SHACL-AF rule example <DFF> @@ -0,0 +1,31 @@ +package org.topbraid.shacl; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.util.FileUtils; +import org.topbraid.jenax.util.JenaUtil; +import org.topbraid.shacl.rules.RuleUtil; +import org.topbraid.shacl.util.ModelPrinter; + +public class RuleExample { + + /** + * Loads an example SHACL-AF (rules) file and execute it against the data. + */ + public static void main(String[] args) throws Exception { + + // Load the main data model that contains rule(s) + Model dataModel = JenaUtil.createMemoryModel(); + dataModel.read(RuleExample.class.getResourceAsStream("sh/tests/rules/triple/rectangle.test.ttl"), "urn:dummy", + FileUtils.langTurtle); + + // Perform the rule calculation, using the data model + // also as the rule model - you may have them separated + Model result = RuleUtil.executeRules(dataModel, dataModel, null, null); + + // you may want to add the original data, to make sense of the rule results + result.add(dataModel); + + // Print rule calculation results + System.out.println(ModelPrinter.get().print(result)); + } +}
31
Merge pull request #89 from fekaputra/master
0
.java
java
apache-2.0
TopQuadrant/shacl
75
<NME> RuleExample.java <BEF> ADDFILE <MSG> Merge pull request #89 from fekaputra/master SHACL-AF rule example <DFF> @@ -0,0 +1,31 @@ +package org.topbraid.shacl; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.util.FileUtils; +import org.topbraid.jenax.util.JenaUtil; +import org.topbraid.shacl.rules.RuleUtil; +import org.topbraid.shacl.util.ModelPrinter; + +public class RuleExample { + + /** + * Loads an example SHACL-AF (rules) file and execute it against the data. + */ + public static void main(String[] args) throws Exception { + + // Load the main data model that contains rule(s) + Model dataModel = JenaUtil.createMemoryModel(); + dataModel.read(RuleExample.class.getResourceAsStream("sh/tests/rules/triple/rectangle.test.ttl"), "urn:dummy", + FileUtils.langTurtle); + + // Perform the rule calculation, using the data model + // also as the rule model - you may have them separated + Model result = RuleUtil.executeRules(dataModel, dataModel, null, null); + + // you may want to add the original data, to make sense of the rule results + result.add(dataModel); + + // Print rule calculation results + System.out.println(ModelPrinter.get().print(result)); + } +}
31
Merge pull request #89 from fekaputra/master
0
.java
java
apache-2.0
TopQuadrant/shacl
76
<NME> ValidationResult.java <BEF> ADDFILE <MSG> #72: Added ValidationResult convenience layer (untested) <DFF> @@ -0,0 +1,32 @@ +package org.topbraid.shacl.validation; + +import java.util.Collection; + +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Resource; + +/** + * A validation result, as produced by the validation engine. + * + * @author Holger Knublauch + */ +public interface ValidationResult { + + RDFNode getFocusNode(); + + String getMessage(); + + Collection<RDFNode> getMessages(); + + Resource getPath(); + + Resource getSeverity(); + + Resource getSourceConstraint(); + + Resource getSourceConstraintComponent(); + + Resource getSourceShape(); + + RDFNode getValue(); +}
32
#72: Added ValidationResult convenience layer (untested)
0
.java
java
apache-2.0
TopQuadrant/shacl
77
<NME> ValidationResult.java <BEF> ADDFILE <MSG> #72: Added ValidationResult convenience layer (untested) <DFF> @@ -0,0 +1,32 @@ +package org.topbraid.shacl.validation; + +import java.util.Collection; + +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Resource; + +/** + * A validation result, as produced by the validation engine. + * + * @author Holger Knublauch + */ +public interface ValidationResult { + + RDFNode getFocusNode(); + + String getMessage(); + + Collection<RDFNode> getMessages(); + + Resource getPath(); + + Resource getSeverity(); + + Resource getSourceConstraint(); + + Resource getSourceConstraintComponent(); + + Resource getSourceShape(); + + RDFNode getValue(); +}
32
#72: Added ValidationResult convenience layer (untested)
0
.java
java
apache-2.0
TopQuadrant/shacl
78
<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> ``` ### Release Process #### Choose next versions. This is optional - the maven release plugin will ask for these otherwise: `export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"` for suitable x/y/z settings. The maven release plugin will move the version from SNAPSHOT to the relase version, and tag the githib repository. It will also move to the next SNAPSHOT version after building the release. 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 pluing calls maven recursively and `-Darguments=` is maven recursively passing down arguments to subprocess) If you have only one key, set this to the empty string: export KEY="" #### Dry run It is advisable to dry run the release: ``` mvn release:clean release:prepare $VER -DdryRun=true $KEY ``` #### Check Look in `target/` 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 $VER $KEY` `mvn release:perform $VER $KEY` #### If it goes wrong: `mvn release:rollback` `mvn release:clean` #### 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. #### Clearup Check where any intermediate files are left over. 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 checking completes. * If all is good, click "release" at the top. 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> Edit release process description <DFF> @@ -2,6 +2,8 @@ This page describes processes for the SHACL API Project. +---- + ## Local Build To build the latest snapshot code for your local system: @@ -25,6 +27,7 @@ repository. Check the pom.xml for the correct version string. </dependency> ``` +---- ## Release @@ -54,41 +57,37 @@ repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`). </server> ``` -### Release Process - -#### Choose next versions. - -This is optional - the maven release plugin will ask for these otherwise: - -`export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"` - -for suitable x/y/z settings. +### Setup Release Process -The maven release plugin will move the version from SNAPSHOT to the relase -version, and tag the githib repository. It will also move to the next -SNAPSHOT version after building the release. +The maven release plugin will move the version from SNAPSHOT to the +release version, and tag the github repository. It will also move to +the next SNAPSHOT version after building the release +(autoVersionSubmodules is set true). 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 pluing calls maven +(Note the slightly odd value here; the release plugin calls maven recursively and `-Darguments=` is maven recursively passing -down arguments to subprocess) +down arguments to the subprocess.) If you have only one key, set this to the empty string: +``` export KEY="" +``` -#### Dry run +or omit `$KEY`. -It is advisable to dry run the release: +### Dry run +It is advisable to dry run the release: ``` -mvn release:clean release:prepare $VER -DdryRun=true $KEY +mvn release:clean release:prepare -DdryRun=true $KEY ``` -#### Check +### Check Look in `target/` @@ -96,31 +95,31 @@ You should see various files built. It still says "SNAPSHOT" because the dry run does not change the version in POM. -#### Do the release +### Do the release This has two steps: -`mvn release:clean release:prepare $VER $KEY` -`mvn release:perform $VER $KEY` +`mvn release:clean release:prepare` +`mvn release:perform $KEY` -#### If it goes wrong: +### If it goes wrong: `mvn release:rollback` `mvn release:clean` -#### Release to central +### 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.... +* 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. -#### Clearup +### Clearup Check where any intermediate files are left over.
24
Edit release process description
25
.md
md
apache-2.0
TopQuadrant/shacl
79
<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> ``` ### Release Process #### Choose next versions. This is optional - the maven release plugin will ask for these otherwise: `export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"` for suitable x/y/z settings. The maven release plugin will move the version from SNAPSHOT to the relase version, and tag the githib repository. It will also move to the next SNAPSHOT version after building the release. 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 pluing calls maven recursively and `-Darguments=` is maven recursively passing down arguments to subprocess) If you have only one key, set this to the empty string: export KEY="" #### Dry run It is advisable to dry run the release: ``` mvn release:clean release:prepare $VER -DdryRun=true $KEY ``` #### Check Look in `target/` 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 $VER $KEY` `mvn release:perform $VER $KEY` #### If it goes wrong: `mvn release:rollback` `mvn release:clean` #### 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. #### Clearup Check where any intermediate files are left over. 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 checking completes. * If all is good, click "release" at the top. 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> Edit release process description <DFF> @@ -2,6 +2,8 @@ This page describes processes for the SHACL API Project. +---- + ## Local Build To build the latest snapshot code for your local system: @@ -25,6 +27,7 @@ repository. Check the pom.xml for the correct version string. </dependency> ``` +---- ## Release @@ -54,41 +57,37 @@ repository in your personal `settings.xml` (e.g. `$HOME/.m2/settings.xml`). </server> ``` -### Release Process - -#### Choose next versions. - -This is optional - the maven release plugin will ask for these otherwise: - -`export VER="-DreleaseVersion=x.y.z -DdevelopmentVersion=x.next.z-SNAPSHOT -Dtag=shacl-x.y.z"` - -for suitable x/y/z settings. +### Setup Release Process -The maven release plugin will move the version from SNAPSHOT to the relase -version, and tag the githib repository. It will also move to the next -SNAPSHOT version after building the release. +The maven release plugin will move the version from SNAPSHOT to the +release version, and tag the github repository. It will also move to +the next SNAPSHOT version after building the release +(autoVersionSubmodules is set true). 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 pluing calls maven +(Note the slightly odd value here; the release plugin calls maven recursively and `-Darguments=` is maven recursively passing -down arguments to subprocess) +down arguments to the subprocess.) If you have only one key, set this to the empty string: +``` export KEY="" +``` -#### Dry run +or omit `$KEY`. -It is advisable to dry run the release: +### Dry run +It is advisable to dry run the release: ``` -mvn release:clean release:prepare $VER -DdryRun=true $KEY +mvn release:clean release:prepare -DdryRun=true $KEY ``` -#### Check +### Check Look in `target/` @@ -96,31 +95,31 @@ You should see various files built. It still says "SNAPSHOT" because the dry run does not change the version in POM. -#### Do the release +### Do the release This has two steps: -`mvn release:clean release:prepare $VER $KEY` -`mvn release:perform $VER $KEY` +`mvn release:clean release:prepare` +`mvn release:perform $KEY` -#### If it goes wrong: +### If it goes wrong: `mvn release:rollback` `mvn release:clean` -#### Release to central +### 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.... +* 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. -#### Clearup +### Clearup Check where any intermediate files are left over.
24
Edit release process description
25
.md
md
apache-2.0
TopQuadrant/shacl
80
<NME> LICENSE <BEF> The TopBraid SHACL API is currently distributed under the GNU Affero General Public License https://gnu.org/licenses/agpl.html <MSG> Updated license <DFF> @@ -1,3 +1,661 @@ -The TopBraid SHACL API is currently distributed under the GNU Affero General Public License + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 - https://gnu.org/licenses/agpl.html + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<http://www.gnu.org/licenses/>. \ No newline at end of file
660
Updated license
2
LICENSE
apache-2.0
TopQuadrant/shacl
81
<NME> LICENSE <BEF> The TopBraid SHACL API is currently distributed under the GNU Affero General Public License https://gnu.org/licenses/agpl.html <MSG> Updated license <DFF> @@ -1,3 +1,661 @@ -The TopBraid SHACL API is currently distributed under the GNU Affero General Public License + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 - https://gnu.org/licenses/agpl.html + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<http://www.gnu.org/licenses/>. \ No newline at end of file
660
Updated license
2
LICENSE
apache-2.0
TopQuadrant/shacl
82
<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; import org.apache.jena.vocabulary.RDF; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to perform SHACL validation. * * @author Holger Knublauch */ public class ValidationUtil { 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); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); 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> #72: Added ValidationReport interface and a default implementation, added equals/hashCode to ResourceValidationResult and added a comment to ValidationUtil; also updated version to start 1.3.0 cycle <DFF> @@ -36,6 +36,14 @@ 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 {
8
#72: Added ValidationReport interface and a default implementation, added equals/hashCode to ResourceValidationResult and added a comment to ValidationUtil; also updated version to start 1.3.0 cycle
0
.java
java
apache-2.0
TopQuadrant/shacl
83
<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; import org.apache.jena.vocabulary.RDF; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.shacl.arq.SHACLFunctions; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.engine.ShapesGraphFactory; import org.topbraid.shacl.util.SHACLSystemModel; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.vocabulary.TOSH; /** * Convenience methods to perform SHACL validation. * * @author Holger Knublauch */ public class ValidationUtil { 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); // Make sure all sh:Functions are registered SHACLFunctions.registerFunctions(shapesModel); // Create Dataset that contains both the data model and the shapes model // (here, using a temporary URI for the shapes graph) URI shapesGraphURI = SHACLUtil.createRandomShapesGraphURI(); 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> #72: Added ValidationReport interface and a default implementation, added equals/hashCode to ResourceValidationResult and added a comment to ValidationUtil; also updated version to start 1.3.0 cycle <DFF> @@ -36,6 +36,14 @@ 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 {
8
#72: Added ValidationReport interface and a default implementation, added equals/hashCode to ResourceValidationResult and added a comment to ValidationUtil; also updated version to start 1.3.0 cycle
0
.java
java
apache-2.0
TopQuadrant/shacl
84
<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> Merge pull request #74 from Locke/closed-message 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
Merge pull request #74 from Locke/closed-message
1
.java
java
apache-2.0
TopQuadrant/shacl
85
<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> Merge pull request #74 from Locke/closed-message 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
Merge pull request #74 from Locke/closed-message
1
.java
java
apache-2.0
TopQuadrant/shacl
86
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). 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. * [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 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> Update README.md <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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.
1
Update README.md
1
.md
md
apache-2.0
TopQuadrant/shacl
87
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). 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. * [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 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> Update README.md <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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.
1
Update README.md
1
.md
md
apache-2.0
TopQuadrant/shacl
88
<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> Merge pull request #77 from sparna-git/resultsSeverity 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
Merge pull request #77 from sparna-git/resultsSeverity
0
.java
java
apache-2.0
TopQuadrant/shacl
89
<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> Merge pull request #77 from sparna-git/resultsSeverity 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
Merge pull request #77 from sparna-git/resultsSeverity
0
.java
java
apache-2.0
TopQuadrant/shacl
90
<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 xsd: <http://www.w3.org/2001/XMLSchema#> . dash: tosh:systemNamespace "true"^^xsd:boolean ; . dash:ClosedByTypesConstraintComponent-closedByTypes sh:group tosh:OtherConstraintPropertyGroup ; 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 ; sh:property tosh:Resource-label ; . dash:ActionTestCase sh:property tosh:ActionTestCase-action ; sh:property tosh:ActionTestCase-expectedResult ; sh:property tosh:ActionTestCase-focusNode ; sh:property tosh:ActionTestCase-variables ; . dash:ChangeScript sh:property tosh:ChangeScript-deactivated ; sh:property tosh:ChangeScript-order ; . dash:ClosedByTypesConstraintComponent-closedByTypes sh:group tosh:ValidationPropertyGroup ; . dash:CoExistsWithConstraintComponent-coExistsWith sh:group tosh:PropertyPairConstraintsPropertyGroup ; dash:SymmetricConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add symmetric value." ; sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:property tosh:FunctionTestCase-expectedResult ; sh:property tosh:FunctionTestCase-expression ; . dash:GraphStoreTestCase sh:property tosh:GraphStoreTestCase-expectedResult ; ] ; . <http://spinrdf.org/sp#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://spinrdf.org/spin#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://spinrdf.org/spl#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://topbraid.org/tosh> rdf:type owl:Ontology ; rdfs:comment """A collection of SHACL features that are used whenever SHACL graphs are used within TopBraid Suite products. This includes things like suggested PropertyGroups and Shapes that control the layout of forms. Some of these may be of general use outside of TopBraid too. This namespace also includes the function tosh:hasShape, which can be used to implement some advanced constraint components using SPARQL only.""" ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; sh:prefix "afn" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; sh:prefix "spif" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; sh:prefix "tosh" ; ] ; . tosh: tosh:systemNamespace "true"^^xsd:boolean ; . tosh:AboutPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "This Shape" ; sh:order 0 ; . tosh:CardinalityConstraintPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "Number of Values" ; sh:order 2 ; . tosh:ComplexConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:editGroupDescription "Most edit fields in this section currently require Turtle source code, esp to enter blank node expressions. To reference existing shapes via their URI, enter them as <URI>." ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Complex Constraint Expressions" ; sh:order 9 ; . tosh:ConstraintMetadataPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "Constraint Metadata" ; . tosh:DeleteTripleSuggestionGenerator rdf:type dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion that would delete the offending value in the validation result from the focus node." ; rdfs:label "Delete triple suggestion generator" ; sh:message "Delete the invalid statement" ; sh:order "20"^^xsd:decimal ; . dash:ScriptFunction sh:property tosh:ScriptFunction-canWrite ; . dash:ScriptTestCase }""" ; . tosh:DisplayPropertyGroup rdf:type sh:PropertyGroup ; rdfs:comment "A group for properties that are primarily for display purposes (names, ordering etc)." ; rdfs:label "Display Settings" ; sh:order 1 ; . tosh:InferencesPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Inferences" ; sh:order "11"^^xsd:decimal ; . tosh:MemberShapeConstraintComponent rdf:type 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 [ rdf:type sh:SPARQLSelectValidator ; sh:message "List member {?member} does not have the shape {$memberShape}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """INSERT { $value $predicate $focusNode . } WHERE { }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:targetClass sh:PropertyShape ; . tosh:MemberShapeConstraintComponent-memberShape rdf:type 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:OtherConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Other Constraints" ; sh:order 10 ; . tosh:PrimaryKeyPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Primary Key" ; sh:order 6.5 ; . tosh:PropertyGroupShape rdf:type sh:NodeShape ; rdfs:label "Property group shape" ; sh:property [ sh:path sh:order ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass sh:targetClass sh:PropertyGroup ; . tosh:PropertyPairConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Relationship to Other Properties" ; sh:order 6 ; . tosh:PropertyShapeShape rdf:type sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ rdf:type sh:PropertyShape ; sh:path sh:values ; tosh:editWidget swa:SourceCodeEditor ; tosh:viewWidget <http://topbraid.org/tosh.ui#ValuesExpressionDiagramViewer> ; 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 ; ] ; sh:property [ sh:path tosh:editWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectEditorClass that shall be used to edit values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; dash:generatePrefixConstants "rdf" ; dash:generatePrefixConstants "rdfs" ; dash:generatePrefixConstants "sh" ; dash:generatePrefixConstants "xsd" ; ] ; sh:property [ sh:path tosh:searchWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectFacetClass that shall be used to search for values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ a sh:PrefixDeclaration ; ] ; sh:property [ sh:path tosh:viewWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectViewerClass that shall be used to view values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; sh:property [ sh:path sh:defaultValue ; tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:description "The default value to be used for this property at new instances." ; sh:group tosh:ValueTypeConstraintPropertyGroup ; ] ; sh:property [ . tosh:Action-actionGroup a sh:PropertyShape ; sh:path dash:actionGroup ; sh:name "description" ; sh:order 2 ; ] ; sh:property [ sh:path sh:group ; sh:description "The sh:PropertyGroup that the property belongs to." ; a sh:PropertyShape ; sh:path sh:deactivated ; sh:name "group" ; sh:order 10 ; ] ; sh:property [ sh:path sh:name ; tosh:editWidget swa:TextFieldEditorWithLang ; 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 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:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Relationship" ; sh:order 8 ; . tosh:ReplaceWithDefaultValueSuggestionGenerator rdf:type 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: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 }""" ; . tosh:SetToDefaultValueSuggestionGenerator rdf:type 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: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 ; }""" ; . tosh:ShapeInGraphConstraintComponent rdf:type 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." ; rdfs:label "Shape in graph constraint component" ; tosh:Class-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of sh:NodeShape. * @returns {sh_NodeShape} */ sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:validator [ rdf:type sh:SPARQLAskValidator ; sh:ask """ASK { GRAPH $graph { FILTER tosh:hasShape($value, $shapeInGraph) */ /** ] ; . tosh:ShapeShape rdf:type sh:NodeShape ; rdfs:label "Shape of shapes" ; sh:property tosh:ShapeShape-deactivated ; sh:property tosh:ShapeShape-severity ; sh:targetClass sh:Shape ; . tosh:ShapeShape-deactivated rdf:type sh:PropertyShape ; sh:path sh:deactivated ; sh:description "Can be used to deactivate the whole constraint." ; sh:group tosh:AboutPropertyGroup ; tosh:Class-abstract a sh:PropertyShape ; sh:order "1"^^xsd:decimal ; . tosh:ShapeShape-severity rdf:type sh:PropertyShape ; sh:path sh:severity ; tosh:editWidget swa:InstancesSelectEditor ; sh:class sh:Severity ; . tosh:Class-classIcon a sh:PropertyShape ; sh:path tosh:classIcon ; sh:order "2"^^xsd:decimal ; . tosh:StringBasedConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Constraints for Strings and Text" ; sh:order 7 ; . tosh:SystemNamespaceShape rdf:type 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 [ rdf:type sh:SPARQLConstraint ; sh:message "Not a IRI from a system namespace" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this sh:maxCount 1 ; sh:name "constructor" ; sh:order "20"^^xsd:decimal ; . tosh:Class-disjointWith a sh:PropertyShape ; sh:path owl:disjointWith ; ] ; . tosh:TeamworkPlatform rdf:type 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:TopBraidPlatform rdf:type dash:ExecutionPlatform ; rdfs:comment "The platform consisting of TopBraid." ; rdfs:label "TopBraid platform" ; . tosh:UseDeclaredDatatypeConstraintComponent rdf:type sh:ConstraintComponent ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change datatype of the invalid value to the specified sh:datatype" ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """DELETE { 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 ; . sh:name "use declared datatype" ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Datatype must match the declared datatype {?datatype}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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:targetClass sh:PropertyShape ; . tosh:ValueRangeConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Min/Max Values" ; sh:order 5 ; . tosh:ValueTypeConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:editGroupDescription "Hint: Use \"or\" under Complex Constraints to represent choices between multiple value types." ; rdfs:comment "A property group for constraint parameters that restrict the value types of values." ; rdfs:label "Type of Values" ; sh:order 3 ; . tosh:countShapesWithMatchResult rdf:type 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." ; rdfs:label "count shapes with match result" ; sh:parameter [ 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:editGroupDescription rdf:type rdf:Property ; rdfs:comment "A description of the property group when in \"edit\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "edit group description" ; rdfs:range xsd:string ; . tosh:editWidget rdf:type rdf:Property ; rdfs:label "edit widget" ; rdfs:range swa:ObjectEditorClass ; . tosh:graph rdf:type rdf:Property ; rdfs:comment "The graph that the shape is validated in." ; rdfs:label "graph" ; . tosh:hasDatatype rdf:type sh:SPARQLAskValidator ; rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; rdfs:label "has datatype" ; sh:ask """ sh:name "property validators" ; sh:order "1"^^xsd:decimal ; . tosh:ConstraintComponent-staticConstraint sh:prefixes <http://topbraid.org/tosh> ; . tosh:hasShape rdf:type sh:Function ; rdfs:comment """A built-in function of the TopBraid SHACL implementation. Can be used to validate a given (focus) node against a given shape, returning <code>true</code> if the node is valid. . 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:returnType xsd:boolean ; . tosh:isInTargetOf rdf:type sh:Function ; rdfs:comment "Checks whether a given node is in the target of a given shape." ; rdfs:label "is in target of" ; sh:parameter [ 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:open rdf:type rdf:Property ; rdfs:comment "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:domain sh:PropertyGroup ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable rdf:type rdf:Property ; rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; rdfs:domain sh:PropertyGroup ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . tosh:searchWidget rdf:type rdf:Property ; rdfs:label "search widget" ; rdfs:range swa:ObjectFacetClass ; . tosh:shaclExists rdf:type sh:Function ; rdfs:comment "Checks whether the current query graph has SHACL activated, i.e. imports the triples typically found in the SHACL namespace. This is currently relying on an approximation, only certain triples, and is natively implemented for TopBraid. Future versions may expose the actual logic as a SPARQL query." ; rdfs:label "SHACL exists" ; sh:returnType xsd:boolean ; . tosh:shapeInGraph rdf:type rdf:Property ; rdfs:comment "The shape that the value nodes must have." ; rdfs:label "shape in graph" ; . tosh:systemNamespace rdf:type rdf:Property ; rdfs:comment "Can be used to mark namespace resources (subjects) to count as \"system namespace\" that should be filtered by tosh:SystemNamespaceShape. Search for the usage of this predicate for examples. Anyone can add their own namespaces to their graphs." ; rdfs:label "system namespace" ; rdfs:range xsd:boolean ; . tosh:validatorForContext rdf:type sh:SPARQLFunction ; rdfs:comment "Gets a suitable validator for a given context, following the resolution rules from the spec." ; rdfs:label "validator for context" ; sh:parameter [ 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:valuesWithShapeCount rdf:type sh:SPARQLFunction ; rdfs:comment "Counts the number of values from a given subject (?arg1) / predicate (?arg2) combination that do not produce any error-level constraint violations for a given shape (?arg3) in a given shapes graph (?arg4). The function produces an error if one of the shapes validated to a fatal error." ; rdfs:label "values with shape count" ; sh:parameter [ 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 """ ; . tosh:viewGadget rdf:type rdf:Property ; rdfs:comment """Can link a property shape with a UI gadget that shall be used to render property values on forms (in viewing mode). In contrast to tosh:viewWidget which is about individual values only, a gadget is expected to take full control, i.e. it needs to make all necessary decisions to render the values appropriately. The gadget is parameterized with the focus node and the path. This property is currently only supported at property groups and then applies to all properties in that group.""" ; tosh:GraphStoreTestCase-expectedResult rdfs:range rdfs:Resource ; . tosh:viewGroupDescription rdf:type rdf:Property ; rdfs:comment "A description of the property group when in \"view\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "view group description" ; rdfs:range xsd:string ; . tosh:viewWidget rdf:type rdf:Property ; rdfs:label "view widget" ; rdfs:range swa:ObjectViewerClass ; . rdf: tosh:systemNamespace "true"^^xsd:boolean ; . rdfs: tosh:systemNamespace "true"^^xsd:boolean ; . xsd: tosh:systemNamespace "true"^^xsd:boolean ; . owl: tosh:systemNamespace "true"^^xsd:boolean ; . sh: tosh:systemNamespace "true"^^xsd:boolean ; . sh:AndConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ?failure ($this AS ?value) 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 ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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 dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Set type of {$value} to {$class}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?class 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" ; . dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change the datatype of the invalid value to {$datatype}" ; sh:order -2 ; sh:prefixes <http://topbraid.org/tosh> ; 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 ; }""" ; ] ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Convert the invalid date/time value into a date value" ; sh:order -1 ; sh:prefixes <http://topbraid.org/tosh> ; /** * 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)) { sh:order 1 ; . sh:DisjointConstraintComponent-disjoint sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 1 ; . sh:EqualsConstraintComponent-equals sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 0 ; . sh:HasValueConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add {$hasValue} to the existing values" ; sh:update """INSERT { $focusNode $predicate $hasValue . /** * 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. sh:property [ sh:path sh:hasValue ; tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; ] ; . sh:HasValueConstraintComponent-hasValue reached = new Set(); } if(!reached.has(this.uri)) { dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace invalid value with {$newObject}" ; sh:order 2 ; sh:prefixes <http://topbraid.org/tosh> ; 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 ; ] ; . sh:LessThanConstraintComponent-lessThan sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 2 ; . sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 3 ; . sh:MaxCountConstraintComponent-maxCount sh:group tosh:CardinalityConstraintPropertyGroup ; sh:order "1"^^xsd:decimal ; . sh:MaxExclusiveConstraintComponent-maxExclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 3 ; . sh:MaxInclusiveConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace the invalid value with {$maxInclusive}" ; sh:update """DELETE { $subject $predicate $object . ] ; ] ; ] ; ] ; ] ; . tosh:NodeShape-node . sh:MaxInclusiveConstraintComponent-maxInclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 2 ; . sh:nodeKind sh:BlankNodeOrIRI ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Prune string to only {$maxLength} characters" ; sh:order 1 ; sh:prefixes <http://topbraid.org/tosh> ; 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:MinExclusiveConstraintComponent-minExclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 0 ; . sh:MinInclusiveConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace the invalid value with {$minInclusive}" ; sh:update """DELETE { $subject $predicate $object . 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:MinInclusiveConstraintComponent-minInclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 1 ; . sh:property sh:NodeKindConstraintComponent-nodeKind ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; . sh:NodeConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ($this AS $value) ?failure . tosh:OWLAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "OWL Axioms" ; sh:order "17"^^xsd:decimal ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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:NotConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ($this AS ?value) ?failure 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 ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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 ; . sh:OrConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Focus node has none of the shapes from the 'or' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ sh:nodeKind sh:BlankNodeOrIRI ; sh:order "0"^^xsd:decimal ; . tosh:Property-range a sh:PropertyShape ; sh:path rdfs:range ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Value has none of the shapes from the 'or' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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 . sh:XoneConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Focus node has {?count} of the shapes from the 'exactly one' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Value node has {?count} of the shapes from the 'exactly one' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ ] ; . 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:order 13 ; . sh:count rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:count are node expressions that produce an xsd:integer counting all values of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "count"@en ; . sh:desc rdf:type rdf:Property ; rdfs:comment "For sh:orderBy node expressions, sh:desc can be set to true to indicate descending order (defaulting to ascending)."@en ; rdfs:isDefinedBy sh: ; rdfs:label "desc"@en ; . sh:distinct rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:distinct are node expressions that drop any duplicate values from the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "distinct"@en ; . sh:groupConcat rdf:type 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:limit rdf:type 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 ; rdfs:isDefinedBy sh: ; rdfs:label "limit"@en ; rdfs:range xsd:integer ; . sh:max rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:max are node expressions that produce the maximum value of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "max"@en ; . sh:min rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:min are node expressions that produce the minimum value of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "min"@en ; . sh:minus rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:minus are node expressions that produce all values of the associated node expression sh:nodes except those that are returned by the sh:minus expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "minus"@en ; . sh:offset rdf:type rdf:Property ; rdfs:comment "Resources with values N for sh:offset are node expressions that produce only all values of the associated node expression sh:nodes after the first N values have been skipped."@en ; rdfs:isDefinedBy sh: ; rdfs:label "offset"@en ; rdfs:range xsd:integer ; . sh:orderBy rdf:type rdf:Property ; rdfs:comment "Resources with a value for sh:orderBy are node expressions that produce all values of the associated node expression sh:nodes ordered by the given node expression (applied to each result value). Use sh:desc=true for descending order."@en ; rdfs:isDefinedBy sh: ; rdfs:label "orderBy"@en ; . sh:separator rdf:type rdf:Property ; rdfs:comment "For sh:concat node expressions, sh:separator can represent a separator string such as \", \" to be placed in between results."@en ; rdfs:isDefinedBy sh: ; rdfs:label "separator"@en ; . sh:sum rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:sum are node expressions that produce the sum of all values of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "sum"@en ; . sh:values rdf:type 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 ; rdfs:isDefinedBy sh: ; rdfs:label "values"@en ; . 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 "Use declared datatype constraint component" ; sh:parameter [ a sh:Parameter ; sh:path tosh:useDeclaredDatatype
157
Periodic alignment with TopBraid code base, also: Vaidate now returns exit code 1 on violations (#56)
129
.ttl
ttl
apache-2.0
TopQuadrant/shacl
91
<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 xsd: <http://www.w3.org/2001/XMLSchema#> . dash: tosh:systemNamespace "true"^^xsd:boolean ; . dash:ClosedByTypesConstraintComponent-closedByTypes sh:group tosh:OtherConstraintPropertyGroup ; 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 ; sh:property tosh:Resource-label ; . dash:ActionTestCase sh:property tosh:ActionTestCase-action ; sh:property tosh:ActionTestCase-expectedResult ; sh:property tosh:ActionTestCase-focusNode ; sh:property tosh:ActionTestCase-variables ; . dash:ChangeScript sh:property tosh:ChangeScript-deactivated ; sh:property tosh:ChangeScript-order ; . dash:ClosedByTypesConstraintComponent-closedByTypes sh:group tosh:ValidationPropertyGroup ; . dash:CoExistsWithConstraintComponent-coExistsWith sh:group tosh:PropertyPairConstraintsPropertyGroup ; dash:SymmetricConstraintComponent dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add symmetric value." ; sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:property tosh:FunctionTestCase-expectedResult ; sh:property tosh:FunctionTestCase-expression ; . dash:GraphStoreTestCase sh:property tosh:GraphStoreTestCase-expectedResult ; ] ; . <http://spinrdf.org/sp#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://spinrdf.org/spin#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://spinrdf.org/spl#> tosh:systemNamespace "true"^^xsd:boolean ; . <http://topbraid.org/tosh> rdf:type owl:Ontology ; rdfs:comment """A collection of SHACL features that are used whenever SHACL graphs are used within TopBraid Suite products. This includes things like suggested PropertyGroups and Shapes that control the layout of forms. Some of these may be of general use outside of TopBraid too. This namespace also includes the function tosh:hasShape, which can be used to implement some advanced constraint components using SPARQL only.""" ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://jena.hpl.hp.com/ARQ/function#"^^xsd:anyURI ; sh:prefix "afn" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://spinrdf.org/spif#"^^xsd:anyURI ; sh:prefix "spif" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; ] ; sh:declare [ rdf:type sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/tosh#"^^xsd:anyURI ; sh:prefix "tosh" ; ] ; . tosh: tosh:systemNamespace "true"^^xsd:boolean ; . tosh:AboutPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "This Shape" ; sh:order 0 ; . tosh:CardinalityConstraintPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "Number of Values" ; sh:order 2 ; . tosh:ComplexConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:editGroupDescription "Most edit fields in this section currently require Turtle source code, esp to enter blank node expressions. To reference existing shapes via their URI, enter them as <URI>." ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Complex Constraint Expressions" ; sh:order 9 ; . tosh:ConstraintMetadataPropertyGroup rdf:type sh:PropertyGroup ; rdfs:label "Constraint Metadata" ; . tosh:DeleteTripleSuggestionGenerator rdf:type dash:SPARQLUpdateSuggestionGenerator ; rdfs:comment "Produces a suggestion that would delete the offending value in the validation result from the focus node." ; rdfs:label "Delete triple suggestion generator" ; sh:message "Delete the invalid statement" ; sh:order "20"^^xsd:decimal ; . dash:ScriptFunction sh:property tosh:ScriptFunction-canWrite ; . dash:ScriptTestCase }""" ; . tosh:DisplayPropertyGroup rdf:type sh:PropertyGroup ; rdfs:comment "A group for properties that are primarily for display purposes (names, ordering etc)." ; rdfs:label "Display Settings" ; sh:order 1 ; . tosh:InferencesPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Inferences" ; sh:order "11"^^xsd:decimal ; . tosh:MemberShapeConstraintComponent rdf:type 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 [ rdf:type sh:SPARQLSelectValidator ; sh:message "List member {?member} does not have the shape {$memberShape}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ sh:order "0"^^xsd:decimal ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """INSERT { $value $predicate $focusNode . } WHERE { }""" ; ] ; . dash:SymmetricConstraintComponent-symmetric sh:targetClass sh:PropertyShape ; . tosh:MemberShapeConstraintComponent-memberShape rdf:type 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:OtherConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Other Constraints" ; sh:order 10 ; . tosh:PrimaryKeyPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Primary Key" ; sh:order 6.5 ; . tosh:PropertyGroupShape rdf:type sh:NodeShape ; rdfs:label "Property group shape" ; sh:property [ sh:path sh:order ; . dash:UniqueValueForClassConstraintComponent-uniqueValueForClass sh:targetClass sh:PropertyGroup ; . tosh:PropertyPairConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Relationship to Other Properties" ; sh:order 6 ; . tosh:PropertyShapeShape rdf:type sh:NodeShape ; rdfs:label "Property shape shape" ; sh:property [ rdf:type sh:PropertyShape ; sh:path sh:values ; tosh:editWidget swa:SourceCodeEditor ; tosh:viewWidget <http://topbraid.org/tosh.ui#ValuesExpressionDiagramViewer> ; 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 ; ] ; sh:property [ sh:path tosh:editWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectEditorClass that shall be used to edit values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; dash:generatePrefixConstants "rdf" ; dash:generatePrefixConstants "rdfs" ; dash:generatePrefixConstants "sh" ; dash:generatePrefixConstants "xsd" ; ] ; sh:property [ sh:path tosh:searchWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectFacetClass that shall be used to search for values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; rdfs:label "TopBraid Data Shapes Library" ; owl:imports <http://datashapes.org/dash> ; sh:declare [ a sh:PrefixDeclaration ; ] ; sh:property [ sh:path tosh:viewWidget ; tosh:editWidget <http://topbraid.org/swaeditor#WidgetDropDownEditor> ; tosh:viewWidget swa:ResourceInUIGraphViewer ; sh:description "The swa:ObjectViewerClass that shall be used to view values of this predicate." ; sh:group tosh:DisplayPropertyGroup ; ] ; sh:declare [ a sh:PrefixDeclaration ; sh:namespace "http://topbraid.org/sparqlmotionfunctions#"^^xsd:anyURI ; sh:prefix "smf" ; sh:property [ sh:path sh:defaultValue ; tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:description "The default value to be used for this property at new instances." ; sh:group tosh:ValueTypeConstraintPropertyGroup ; ] ; sh:property [ . tosh:Action-actionGroup a sh:PropertyShape ; sh:path dash:actionGroup ; sh:name "description" ; sh:order 2 ; ] ; sh:property [ sh:path sh:group ; sh:description "The sh:PropertyGroup that the property belongs to." ; a sh:PropertyShape ; sh:path sh:deactivated ; sh:name "group" ; sh:order 10 ; ] ; sh:property [ sh:path sh:name ; tosh:editWidget swa:TextFieldEditorWithLang ; 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 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:targetClass sh:PropertyShape ; . tosh:RelationshipPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Relationship" ; sh:order 8 ; . tosh:ReplaceWithDefaultValueSuggestionGenerator rdf:type 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: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 }""" ; . tosh:SetToDefaultValueSuggestionGenerator rdf:type 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: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 ; }""" ; . tosh:ShapeInGraphConstraintComponent rdf:type 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." ; rdfs:label "Shape in graph constraint component" ; tosh:Class-ShapeScript a dash:ShapeScript ; dash:js """ /** * Returns this class as an instance of sh:NodeShape. * @returns {sh_NodeShape} */ sh:nodeKind sh:BlankNodeOrIRI ; ] ; sh:validator [ rdf:type sh:SPARQLAskValidator ; sh:ask """ASK { GRAPH $graph { FILTER tosh:hasShape($value, $shapeInGraph) */ /** ] ; . tosh:ShapeShape rdf:type sh:NodeShape ; rdfs:label "Shape of shapes" ; sh:property tosh:ShapeShape-deactivated ; sh:property tosh:ShapeShape-severity ; sh:targetClass sh:Shape ; . tosh:ShapeShape-deactivated rdf:type sh:PropertyShape ; sh:path sh:deactivated ; sh:description "Can be used to deactivate the whole constraint." ; sh:group tosh:AboutPropertyGroup ; tosh:Class-abstract a sh:PropertyShape ; sh:order "1"^^xsd:decimal ; . tosh:ShapeShape-severity rdf:type sh:PropertyShape ; sh:path sh:severity ; tosh:editWidget swa:InstancesSelectEditor ; sh:class sh:Severity ; . tosh:Class-classIcon a sh:PropertyShape ; sh:path tosh:classIcon ; sh:order "2"^^xsd:decimal ; . tosh:StringBasedConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Constraints for Strings and Text" ; sh:order 7 ; . tosh:SystemNamespaceShape rdf:type 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 [ rdf:type sh:SPARQLConstraint ; sh:message "Not a IRI from a system namespace" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT $this sh:maxCount 1 ; sh:name "constructor" ; sh:order "20"^^xsd:decimal ; . tosh:Class-disjointWith a sh:PropertyShape ; sh:path owl:disjointWith ; ] ; . tosh:TeamworkPlatform rdf:type 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:TopBraidPlatform rdf:type dash:ExecutionPlatform ; rdfs:comment "The platform consisting of TopBraid." ; rdfs:label "TopBraid platform" ; . tosh:UseDeclaredDatatypeConstraintComponent rdf:type sh:ConstraintComponent ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change datatype of the invalid value to the specified sh:datatype" ; sh:prefixes <http://topbraid.org/tosh> ; sh:update """DELETE { 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 ; . sh:name "use declared datatype" ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Datatype must match the declared datatype {?datatype}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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:targetClass sh:PropertyShape ; . tosh:ValueRangeConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:openable "true"^^xsd:boolean ; rdfs:label "Min/Max Values" ; sh:order 5 ; . tosh:ValueTypeConstraintPropertyGroup rdf:type sh:PropertyGroup ; tosh:editGroupDescription "Hint: Use \"or\" under Complex Constraints to represent choices between multiple value types." ; rdfs:comment "A property group for constraint parameters that restrict the value types of values." ; rdfs:label "Type of Values" ; sh:order 3 ; . tosh:countShapesWithMatchResult rdf:type 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." ; rdfs:label "count shapes with match result" ; sh:parameter [ 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:editGroupDescription rdf:type rdf:Property ; rdfs:comment "A description of the property group when in \"edit\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "edit group description" ; rdfs:range xsd:string ; . tosh:editWidget rdf:type rdf:Property ; rdfs:label "edit widget" ; rdfs:range swa:ObjectEditorClass ; . tosh:graph rdf:type rdf:Property ; rdfs:comment "The graph that the shape is validated in." ; rdfs:label "graph" ; . tosh:hasDatatype rdf:type sh:SPARQLAskValidator ; rdfs:comment "Checks whether a given node ($value) is a literal with a given datatype ($datatype), and that the literal is well-formed." ; rdfs:label "has datatype" ; sh:ask """ sh:name "property validators" ; sh:order "1"^^xsd:decimal ; . tosh:ConstraintComponent-staticConstraint sh:prefixes <http://topbraid.org/tosh> ; . tosh:hasShape rdf:type sh:Function ; rdfs:comment """A built-in function of the TopBraid SHACL implementation. Can be used to validate a given (focus) node against a given shape, returning <code>true</code> if the node is valid. . 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:returnType xsd:boolean ; . tosh:isInTargetOf rdf:type sh:Function ; rdfs:comment "Checks whether a given node is in the target of a given shape." ; rdfs:label "is in target of" ; sh:parameter [ 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:open rdf:type rdf:Property ; rdfs:comment "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:domain sh:PropertyGroup ; rdfs:label "open" ; rdfs:range xsd:boolean ; . tosh:openable rdf:type rdf:Property ; rdfs:comment "If set to true, then the corresponding form section shall be openable/closable (and show up closed)." ; rdfs:domain sh:PropertyGroup ; rdfs:label "openable" ; rdfs:range xsd:boolean ; . tosh:searchWidget rdf:type rdf:Property ; rdfs:label "search widget" ; rdfs:range swa:ObjectFacetClass ; . tosh:shaclExists rdf:type sh:Function ; rdfs:comment "Checks whether the current query graph has SHACL activated, i.e. imports the triples typically found in the SHACL namespace. This is currently relying on an approximation, only certain triples, and is natively implemented for TopBraid. Future versions may expose the actual logic as a SPARQL query." ; rdfs:label "SHACL exists" ; sh:returnType xsd:boolean ; . tosh:shapeInGraph rdf:type rdf:Property ; rdfs:comment "The shape that the value nodes must have." ; rdfs:label "shape in graph" ; . tosh:systemNamespace rdf:type rdf:Property ; rdfs:comment "Can be used to mark namespace resources (subjects) to count as \"system namespace\" that should be filtered by tosh:SystemNamespaceShape. Search for the usage of this predicate for examples. Anyone can add their own namespaces to their graphs." ; rdfs:label "system namespace" ; rdfs:range xsd:boolean ; . tosh:validatorForContext rdf:type sh:SPARQLFunction ; rdfs:comment "Gets a suitable validator for a given context, following the resolution rules from the spec." ; rdfs:label "validator for context" ; sh:parameter [ 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:valuesWithShapeCount rdf:type sh:SPARQLFunction ; rdfs:comment "Counts the number of values from a given subject (?arg1) / predicate (?arg2) combination that do not produce any error-level constraint violations for a given shape (?arg3) in a given shapes graph (?arg4). The function produces an error if one of the shapes validated to a fatal error." ; rdfs:label "values with shape count" ; sh:parameter [ 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 """ ; . tosh:viewGadget rdf:type rdf:Property ; rdfs:comment """Can link a property shape with a UI gadget that shall be used to render property values on forms (in viewing mode). In contrast to tosh:viewWidget which is about individual values only, a gadget is expected to take full control, i.e. it needs to make all necessary decisions to render the values appropriately. The gadget is parameterized with the focus node and the path. This property is currently only supported at property groups and then applies to all properties in that group.""" ; tosh:GraphStoreTestCase-expectedResult rdfs:range rdfs:Resource ; . tosh:viewGroupDescription rdf:type rdf:Property ; rdfs:comment "A description of the property group when in \"view\" mode." ; rdfs:domain sh:PropertyGroup ; rdfs:label "view group description" ; rdfs:range xsd:string ; . tosh:viewWidget rdf:type rdf:Property ; rdfs:label "view widget" ; rdfs:range swa:ObjectViewerClass ; . rdf: tosh:systemNamespace "true"^^xsd:boolean ; . rdfs: tosh:systemNamespace "true"^^xsd:boolean ; . xsd: tosh:systemNamespace "true"^^xsd:boolean ; . owl: tosh:systemNamespace "true"^^xsd:boolean ; . sh: tosh:systemNamespace "true"^^xsd:boolean ; . sh:AndConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ?failure ($this AS ?value) 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 ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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 dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Set type of {$value} to {$class}" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """SELECT ?class 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" ; . dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Change the datatype of the invalid value to {$datatype}" ; sh:order -2 ; sh:prefixes <http://topbraid.org/tosh> ; 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 ; }""" ; ] ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Convert the invalid date/time value into a date value" ; sh:order -1 ; sh:prefixes <http://topbraid.org/tosh> ; /** * 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)) { sh:order 1 ; . sh:DisjointConstraintComponent-disjoint sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 1 ; . sh:EqualsConstraintComponent-equals sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 0 ; . sh:HasValueConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Add {$hasValue} to the existing values" ; sh:update """INSERT { $focusNode $predicate $hasValue . /** * 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. sh:property [ sh:path sh:hasValue ; tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; ] ; . sh:HasValueConstraintComponent-hasValue reached = new Set(); } if(!reached.has(this.uri)) { dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace invalid value with {$newObject}" ; sh:order 2 ; sh:prefixes <http://topbraid.org/tosh> ; 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 ; ] ; . sh:LessThanConstraintComponent-lessThan sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 2 ; . sh:LessThanOrEqualsConstraintComponent-lessThanOrEquals sh:deactivated "true"^^xsd:boolean ; sh:group tosh:PropertyPairConstraintPropertyGroup ; sh:order 3 ; . sh:MaxCountConstraintComponent-maxCount sh:group tosh:CardinalityConstraintPropertyGroup ; sh:order "1"^^xsd:decimal ; . sh:MaxExclusiveConstraintComponent-maxExclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 3 ; . sh:MaxInclusiveConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace the invalid value with {$maxInclusive}" ; sh:update """DELETE { $subject $predicate $object . ] ; ] ; ] ; ] ; ] ; . tosh:NodeShape-node . sh:MaxInclusiveConstraintComponent-maxInclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 2 ; . sh:nodeKind sh:BlankNodeOrIRI ; dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ; dash:propertySuggestionGenerator tosh:ReplaceWithDefaultValueSuggestionGenerator ; dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Prune string to only {$maxLength} characters" ; sh:order 1 ; sh:prefixes <http://topbraid.org/tosh> ; 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:MinExclusiveConstraintComponent-minExclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 0 ; . sh:MinInclusiveConstraintComponent dash:propertySuggestionGenerator [ rdf:type dash:SPARQLUpdateSuggestionGenerator ; sh:message "Replace the invalid value with {$minInclusive}" ; sh:update """DELETE { $subject $predicate $object . 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:MinInclusiveConstraintComponent-minInclusive tosh:editWidget <http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ; tosh:useDeclaredDatatype "true"^^xsd:boolean ; sh:group tosh:ValueRangeConstraintPropertyGroup ; sh:order 1 ; . sh:property sh:NodeKindConstraintComponent-nodeKind ; sh:property sh:PatternConstraintComponent-flags ; sh:property sh:PatternConstraintComponent-pattern ; . sh:NodeConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ($this AS $value) ?failure . tosh:OWLAxiomsPropertyGroup a sh:PropertyGroup ; rdfs:label "OWL Axioms" ; sh:order "17"^^xsd:decimal ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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:NotConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT $this ($this AS ?value) ?failure 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 ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ SELECT DISTINCT $this ?value ?failure 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 ; . sh:OrConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Focus node has none of the shapes from the 'or' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ sh:nodeKind sh:BlankNodeOrIRI ; sh:order "0"^^xsd:decimal ; . tosh:Property-range a sh:PropertyShape ; sh:path rdfs:range ; """ ; ] ; sh:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Value has none of the shapes from the 'or' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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 . sh:XoneConstraintComponent sh:nodeValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Focus node has {?count} of the shapes from the 'exactly one' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ 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:propertyValidator [ rdf:type sh:SPARQLSelectValidator ; sh:message "Value node has {?count} of the shapes from the 'exactly one' list" ; sh:prefixes <http://topbraid.org/tosh> ; sh:select """ ] ; . 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:order 13 ; . sh:count rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:count are node expressions that produce an xsd:integer counting all values of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "count"@en ; . sh:desc rdf:type rdf:Property ; rdfs:comment "For sh:orderBy node expressions, sh:desc can be set to true to indicate descending order (defaulting to ascending)."@en ; rdfs:isDefinedBy sh: ; rdfs:label "desc"@en ; . sh:distinct rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:distinct are node expressions that drop any duplicate values from the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "distinct"@en ; . sh:groupConcat rdf:type 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:limit rdf:type 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 ; rdfs:isDefinedBy sh: ; rdfs:label "limit"@en ; rdfs:range xsd:integer ; . sh:max rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:max are node expressions that produce the maximum value of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "max"@en ; . sh:min rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:min are node expressions that produce the minimum value of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "min"@en ; . sh:minus rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:minus are node expressions that produce all values of the associated node expression sh:nodes except those that are returned by the sh:minus expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "minus"@en ; . sh:offset rdf:type rdf:Property ; rdfs:comment "Resources with values N for sh:offset are node expressions that produce only all values of the associated node expression sh:nodes after the first N values have been skipped."@en ; rdfs:isDefinedBy sh: ; rdfs:label "offset"@en ; rdfs:range xsd:integer ; . sh:orderBy rdf:type rdf:Property ; rdfs:comment "Resources with a value for sh:orderBy are node expressions that produce all values of the associated node expression sh:nodes ordered by the given node expression (applied to each result value). Use sh:desc=true for descending order."@en ; rdfs:isDefinedBy sh: ; rdfs:label "orderBy"@en ; . sh:separator rdf:type rdf:Property ; rdfs:comment "For sh:concat node expressions, sh:separator can represent a separator string such as \", \" to be placed in between results."@en ; rdfs:isDefinedBy sh: ; rdfs:label "separator"@en ; . sh:sum rdf:type rdf:Property ; rdfs:comment "Resources with values for sh:sum are node expressions that produce the sum of all values of the associated node expression."@en ; rdfs:isDefinedBy sh: ; rdfs:label "sum"@en ; . sh:values rdf:type 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 ; rdfs:isDefinedBy sh: ; rdfs:label "values"@en ; . 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 "Use declared datatype constraint component" ; sh:parameter [ a sh:Parameter ; sh:path tosh:useDeclaredDatatype
157
Periodic alignment with TopBraid code base, also: Vaidate now returns exit code 1 on violations (#56)
129
.ttl
ttl
apache-2.0
TopQuadrant/shacl
92
<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 java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.query.Dataset; import org.apache.jena.query.QuerySolution; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; 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.rdf.model.StmtIterator; import org.apache.jena.sparql.path.P_Inverse; import org.apache.jena.sparql.path.P_Link; import org.apache.jena.sparql.path.Path; import org.apache.jena.sparql.path.eval.PathEval; import org.apache.jena.sparql.util.Context; 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.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; /** * A ValidationEngine uses a given shapes graph (represented via an instance of ShapesGraph) * and performs SHACL validation on a given Dataset. * * Instances of this class should be created via the ValidatorFactory. * * @author Holger Knublauch */ 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 results.addAll(JenaUtil.getAllInstances(targetClass.inModel(dataModel))); } results.addAll(shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()); for(Resource sof : JenaUtil.getResourceProperties(shape, SH.targetSubjectsOf)) { for(Statement s : dataModel.listStatements(null, JenaUtil.asProperty(sof), (RDFNode)null).toList()) { 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> Fix on sh:targetNode <DFF> @@ -164,7 +164,9 @@ public class ValidationEngine { results.addAll(JenaUtil.getAllInstances(targetClass.inModel(dataModel))); } - results.addAll(shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()); + for(RDFNode targetNode : shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()) { + results.add(targetNode.inModel(dataModel)); + } for(Resource sof : JenaUtil.getResourceProperties(shape, SH.targetSubjectsOf)) { for(Statement s : dataModel.listStatements(null, JenaUtil.asProperty(sof), (RDFNode)null).toList()) {
3
Fix on sh:targetNode
1
.java
java
apache-2.0
TopQuadrant/shacl
93
<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 java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.query.Dataset; import org.apache.jena.query.QuerySolution; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; 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.rdf.model.StmtIterator; import org.apache.jena.sparql.path.P_Inverse; import org.apache.jena.sparql.path.P_Link; import org.apache.jena.sparql.path.Path; import org.apache.jena.sparql.path.eval.PathEval; import org.apache.jena.sparql.util.Context; 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.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; /** * A ValidationEngine uses a given shapes graph (represented via an instance of ShapesGraph) * and performs SHACL validation on a given Dataset. * * Instances of this class should be created via the ValidatorFactory. * * @author Holger Knublauch */ 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 results.addAll(JenaUtil.getAllInstances(targetClass.inModel(dataModel))); } results.addAll(shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()); for(Resource sof : JenaUtil.getResourceProperties(shape, SH.targetSubjectsOf)) { for(Statement s : dataModel.listStatements(null, JenaUtil.asProperty(sof), (RDFNode)null).toList()) { 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> Fix on sh:targetNode <DFF> @@ -164,7 +164,9 @@ public class ValidationEngine { results.addAll(JenaUtil.getAllInstances(targetClass.inModel(dataModel))); } - results.addAll(shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()); + for(RDFNode targetNode : shape.getModel().listObjectsOfProperty(shape, SH.targetNode).toList()) { + results.add(targetNode.inModel(dataModel)); + } for(Resource sof : JenaUtil.getResourceProperties(shape, SH.targetSubjectsOf)) { for(Statement s : dataModel.listStatements(null, JenaUtil.asProperty(sof), (RDFNode)null).toList()) {
3
Fix on sh:targetNode
1
.java
java
apache-2.0
TopQuadrant/shacl
94
<NME> DiffGraph.java <BEF> ADDFILE <MSG> DiffGraph updates <DFF> @@ -0,0 +1,211 @@ +package org.topbraid.jenax.util; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.jena.graph.Graph; +import org.apache.jena.graph.Node; +import org.apache.jena.graph.Triple; +import org.apache.jena.graph.impl.GraphMatcher; +import org.apache.jena.graph.impl.GraphWithPerform; +import org.apache.jena.mem.GraphMem; +import org.apache.jena.shared.PrefixMapping; +import org.apache.jena.shared.impl.PrefixMappingImpl; +import org.apache.jena.util.iterator.ExtendedIterator; + + +// TODO: note this graph does not correctly implement GraphWithPerform and event notification contracts +/** + * A WrappedGraph that filters out deleted triples or adds added triples, without + * modifying the underlying base graph. + * + * Similar to BufferingGraph in TopBraid, but with minimal code dependencies + * and simpler contracts that are just right for use in SPARQLMotion. + * + * @author Holger Knublauch + */ +public class DiffGraph extends TransparentWrappedGraph { + + /** + * This graph has additional triples that are not in the delegate. + */ + private GraphWithPerform addedGraph = new GraphMem(); + + /** + * This Set has triples that are in the delegate but are excluded + * from the filtered graph. + */ + protected Set<Triple> deletedTriples = new HashSet<Triple>(); + + private PrefixMapping pm; + + + public DiffGraph(Graph base) { + super(base); + } + + + @Override + public void add(Triple t) { + performAdd(t); + } + + + @Override + public void delete(Triple t) { + performDelete(t); + } + + + public Graph getAddedGraph() { + return addedGraph; + } + + + @Override + public boolean contains(Node s, Node p, Node o) { + return contains(Triple.create(s, p, o)); + } + + + @Override + public boolean contains(Triple t) { + if(addedGraph.contains(t)) { + return true; + } + else { + ExtendedIterator<Triple> it = base.find(t); + while(it.hasNext()) { + Triple n = it.next(); + if(!deletedTriples.contains(n)) { + it.close(); + return true; + } + } + return false; + } + } + + + // TODO: If the delegate does not use equals for add and delete + // but sameValueAs then this code is incorrect. + // Specifically we should be able to show bugs with TDB which does + // something different from either equals or sameValueAs. + private boolean containsByEquals(Graph g,Triple t) { + ExtendedIterator<Triple> it = g.find(t); + try { + while (it.hasNext()) { + if (t.equals(it.next())) + return true; + } + } + finally { + it.close(); + } + return false; + } + + + @Override + public ExtendedIterator<Triple> find(Node s, Node p, Node o) { + + // First get the underlying base query (without any buffered triples) + ExtendedIterator<Triple> base = super.find(s, p, o); + + // If deleted triples exist then continue with a filtered iterator + if(deletedTriples.size() > 0) { + // base without deleted triples. + base = base.filterDrop(deletedTriples::contains); + } + + // If added triples exist then chain the two together + // this iterator supports remove and removes correctly for this graph + ExtendedIterator<Triple> added = addedGraph.find(s, p, o); + if(added.hasNext()) { + return base.andThen(added); // base and added are guaranteed disjoint + } + else { + return base; + } + } + + + @Override + public ExtendedIterator<Triple> find(Triple m) { + return find(m.getMatchSubject(), m.getMatchPredicate(), m.getMatchObject()); + } + + + public Set<Triple> getDeletedTriples() { + return deletedTriples; + } + + + @Override + public PrefixMapping getPrefixMapping() { + if (pm == null) { + // copy delegate's prefix mapping. + pm = new PrefixMappingImpl().setNsPrefixes(base.getPrefixMapping()); + } + return pm; + } + + + @Override + public boolean isEmpty() { + if (!addedGraph.isEmpty()) { + return false; + } + if (deletedTriples.isEmpty()) { + return base.isEmpty(); + } + return find(Triple.ANY).hasNext(); + } + + + @Override + public boolean isIsomorphicWith(Graph g) { + return g != null && GraphMatcher.equals(this, g); + } + + + @Override + public void performAdd(Triple t) { + if (deletedTriples.contains(t)) { + deletedTriples.remove(t); + getEventManager().notifyAddTriple(this, t); + } + else if (containsByEquals(addedGraph,t) || containsByEquals(base, t) ) { + // notify even unsuccessful adds - see javadoc for graphlistener + getEventManager().notifyAddTriple(this, t); + } + else { + // addedGraph does notification for us. + addedGraph.add(t); + } + } + + + @Override + public void performDelete(Triple t) { + if( containsByEquals(addedGraph,t) ) { + // addedGraph does notification for us. + addedGraph.delete(t); + } + else if ( containsByEquals(base, t) ) { + deletedTriples.add(t); + getEventManager().notifyDeleteTriple(this, t); + } + else { + // notify even unsuccessful deletes - see javadoc for graphlistener + getEventManager().notifyDeleteTriple(this, t); + return; + } + } + + + @Override + public int size() { + return super.size() - deletedTriples.size() + addedGraph.size(); + } +}
211
DiffGraph updates
0
.java
java
apache-2.0
TopQuadrant/shacl
95
<NME> DiffGraph.java <BEF> ADDFILE <MSG> DiffGraph updates <DFF> @@ -0,0 +1,211 @@ +package org.topbraid.jenax.util; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.jena.graph.Graph; +import org.apache.jena.graph.Node; +import org.apache.jena.graph.Triple; +import org.apache.jena.graph.impl.GraphMatcher; +import org.apache.jena.graph.impl.GraphWithPerform; +import org.apache.jena.mem.GraphMem; +import org.apache.jena.shared.PrefixMapping; +import org.apache.jena.shared.impl.PrefixMappingImpl; +import org.apache.jena.util.iterator.ExtendedIterator; + + +// TODO: note this graph does not correctly implement GraphWithPerform and event notification contracts +/** + * A WrappedGraph that filters out deleted triples or adds added triples, without + * modifying the underlying base graph. + * + * Similar to BufferingGraph in TopBraid, but with minimal code dependencies + * and simpler contracts that are just right for use in SPARQLMotion. + * + * @author Holger Knublauch + */ +public class DiffGraph extends TransparentWrappedGraph { + + /** + * This graph has additional triples that are not in the delegate. + */ + private GraphWithPerform addedGraph = new GraphMem(); + + /** + * This Set has triples that are in the delegate but are excluded + * from the filtered graph. + */ + protected Set<Triple> deletedTriples = new HashSet<Triple>(); + + private PrefixMapping pm; + + + public DiffGraph(Graph base) { + super(base); + } + + + @Override + public void add(Triple t) { + performAdd(t); + } + + + @Override + public void delete(Triple t) { + performDelete(t); + } + + + public Graph getAddedGraph() { + return addedGraph; + } + + + @Override + public boolean contains(Node s, Node p, Node o) { + return contains(Triple.create(s, p, o)); + } + + + @Override + public boolean contains(Triple t) { + if(addedGraph.contains(t)) { + return true; + } + else { + ExtendedIterator<Triple> it = base.find(t); + while(it.hasNext()) { + Triple n = it.next(); + if(!deletedTriples.contains(n)) { + it.close(); + return true; + } + } + return false; + } + } + + + // TODO: If the delegate does not use equals for add and delete + // but sameValueAs then this code is incorrect. + // Specifically we should be able to show bugs with TDB which does + // something different from either equals or sameValueAs. + private boolean containsByEquals(Graph g,Triple t) { + ExtendedIterator<Triple> it = g.find(t); + try { + while (it.hasNext()) { + if (t.equals(it.next())) + return true; + } + } + finally { + it.close(); + } + return false; + } + + + @Override + public ExtendedIterator<Triple> find(Node s, Node p, Node o) { + + // First get the underlying base query (without any buffered triples) + ExtendedIterator<Triple> base = super.find(s, p, o); + + // If deleted triples exist then continue with a filtered iterator + if(deletedTriples.size() > 0) { + // base without deleted triples. + base = base.filterDrop(deletedTriples::contains); + } + + // If added triples exist then chain the two together + // this iterator supports remove and removes correctly for this graph + ExtendedIterator<Triple> added = addedGraph.find(s, p, o); + if(added.hasNext()) { + return base.andThen(added); // base and added are guaranteed disjoint + } + else { + return base; + } + } + + + @Override + public ExtendedIterator<Triple> find(Triple m) { + return find(m.getMatchSubject(), m.getMatchPredicate(), m.getMatchObject()); + } + + + public Set<Triple> getDeletedTriples() { + return deletedTriples; + } + + + @Override + public PrefixMapping getPrefixMapping() { + if (pm == null) { + // copy delegate's prefix mapping. + pm = new PrefixMappingImpl().setNsPrefixes(base.getPrefixMapping()); + } + return pm; + } + + + @Override + public boolean isEmpty() { + if (!addedGraph.isEmpty()) { + return false; + } + if (deletedTriples.isEmpty()) { + return base.isEmpty(); + } + return find(Triple.ANY).hasNext(); + } + + + @Override + public boolean isIsomorphicWith(Graph g) { + return g != null && GraphMatcher.equals(this, g); + } + + + @Override + public void performAdd(Triple t) { + if (deletedTriples.contains(t)) { + deletedTriples.remove(t); + getEventManager().notifyAddTriple(this, t); + } + else if (containsByEquals(addedGraph,t) || containsByEquals(base, t) ) { + // notify even unsuccessful adds - see javadoc for graphlistener + getEventManager().notifyAddTriple(this, t); + } + else { + // addedGraph does notification for us. + addedGraph.add(t); + } + } + + + @Override + public void performDelete(Triple t) { + if( containsByEquals(addedGraph,t) ) { + // addedGraph does notification for us. + addedGraph.delete(t); + } + else if ( containsByEquals(base, t) ) { + deletedTriples.add(t); + getEventManager().notifyDeleteTriple(this, t); + } + else { + // notify even unsuccessful deletes - see javadoc for graphlistener + getEventManager().notifyDeleteTriple(this, t); + return; + } + } + + + @Override + public int size() { + return super.size() - deletedTriples.size() + addedGraph.size(); + } +}
211
DiffGraph updates
0
.java
java
apache-2.0
TopQuadrant/shacl
96
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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 go 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 classes ModelConstraintValidator and ResourceConstraintValidator in the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) 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> Updated README.md <DFF> @@ -8,14 +8,15 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). +The same code is used in the TopBraid products (currently aligned with TopBraid 5.3). 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 go 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 classes ModelConstraintValidator and ResourceConstraintValidator in -the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) +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)
5
Updated README.md
4
.md
md
apache-2.0
TopQuadrant/shacl
97
<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 developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). 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 go 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 classes ModelConstraintValidator and ResourceConstraintValidator in the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) 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> Updated README.md <DFF> @@ -8,14 +8,15 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). +The same code is used in the TopBraid products (currently aligned with TopBraid 5.3). 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 go 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 classes ModelConstraintValidator and ResourceConstraintValidator in -the package org.topbraid.shacl.constraints. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) +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)
5
Updated README.md
4
.md
md
apache-2.0
TopQuadrant/shacl
98
<NME> sparql-001.test.ttl <BEF> ADDFILE <MSG> Fixed an issue with sh:sparql constraints <DFF> @@ -0,0 +1,69 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/constraint/sparql-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/constraint/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/constraint/sparql-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparql-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer" ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource1 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + sh:value "Invalid resource 1" ; + ] ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource2 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + sh:value "Invalid label 1" ; + ] ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource2 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + 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:Shape ; + rdfs:label "Test shape" ; + sh:sparql [ + sh:message "Cannot have a label" ; + 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 ; +.
69
Fixed an issue with sh:sparql constraints
0
.ttl
test
apache-2.0
TopQuadrant/shacl
99
<NME> sparql-001.test.ttl <BEF> ADDFILE <MSG> Fixed an issue with sh:sparql constraints <DFF> @@ -0,0 +1,69 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/constraint/sparql-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/constraint/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/constraint/sparql-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparql-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer" ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource1 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + sh:value "Invalid resource 1" ; + ] ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource2 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + sh:value "Invalid label 1" ; + ] ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidResource2 ; + sh:path rdfs:label ; + sh:severity sh:Violation ; + 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:Shape ; + rdfs:label "Test shape" ; + sh:sparql [ + sh:message "Cannot have a label" ; + 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 ; +.
69
Fixed an issue with sh:sparql constraints
0
.ttl
test
apache-2.0
TopQuadrant/shacl