diff --git a/dqgen/resources/query_templates/instance_additions.rq b/dqgen/resources/query_templates/instance_additions.rq index db8cf31..919283b 100644 --- a/dqgen/resources/query_templates/instance_additions.rq +++ b/dqgen/resources/query_templates/instance_additions.rq @@ -36,7 +36,11 @@ PREFIX sd: PREFIX sh: PREFIX xhv: # identify added instances +{% if cls == "owl:ObjectProperty" or cls == "owl:DatatypeProperty" %} +SELECT distinct ?class ?instance ?prefLabel ?prefLabelLang ?domain ?range ?minCardinality ?maxCardinality ("{{type_of_action}}" as ?actionType) +{% else %} SELECT distinct ?class ?instance ?prefLabel ?prefLabelLang ("{{type_of_action}}" as ?actionType) +{% endif %} WHERE { GRAPH ?versionHistoryGraph { # parameters @@ -143,5 +147,39 @@ WHERE { ?instance ?p [] . } } +{% if cls == "owl:ObjectProperty" %} + # and we get some domain, range and cardinality information from SHACL shapes if available + OPTIONAL { + GRAPH ?newVersionGraph { + { + ?nodeShape shacl:property ?propertyShape ; + shacl:targetClass ?domain . + ?propertyShape shacl:path ?instance ; + shacl:class ?range . + } + UNION + { + ?nodeShape shacl:property ?propertyShape ; + shacl:targetClass ?domain . + ?propertyShape shacl:path ?instance ; + shacl:node/shacl:property/shacl:hasValue ?range . + } + OPTIONAL { ?propertyShape shacl:minCount ?minCardinality } + OPTIONAL { ?propertyShape shacl:maxCount ?maxCardinality } + } + } +{% elif cls == "owl:DatatypeProperty" %} + # and we get some domain, range and cardinality information from SHACL shapes if available + OPTIONAL { + GRAPH ?newVersionGraph { + ?nodeShape shacl:property ?propertyShape ; + shacl:targetClass ?domain . + ?propertyShape shacl:path ?instance ; + shacl:datatype ?range . + OPTIONAL { ?propertyShape shacl:minCount ?minCardinality } + OPTIONAL { ?propertyShape shacl:maxCount ?maxCardinality } + } + } +{% endif %} } ORDER BY ?instance