From 9b8172d8e58d054fd4727af16630ece99f9cfca2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 1 Mar 2022 21:19:35 +0100 Subject: [PATCH] #25 validate that type driven types have a type --- code/shapes.ttl | 113 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 3 deletions(-) diff --git a/code/shapes.ttl b/code/shapes.ttl index 6ac3e36f5..a38ab361b 100644 --- a/code/shapes.ttl +++ b/code/shapes.ttl @@ -31,8 +31,9 @@ ex:PropertySet a sh:SPARQLTarget; } """ . - -ex:QuantitySet a sh:SPARQLTarget; + + +ex:TypeDrivenPropertyOrQuantitySet a sh:SPARQLTarget; sh:select """ PREFIX ex: PREFIX rdf: @@ -44,11 +45,36 @@ ex:QuantitySet a sh:SPARQLTarget; ?this xmi:type "uml:Class" . { + ?stereo a custom:PSET_TYPEDRIVENOVERRIDE . + ?stereo ex:base_Class ?this . + } UNION { + ?stereo a custom:PSET_TYPEDRIVENONLY . + ?stereo ex:base_Class ?this . + } UNION { ?stereo a custom:QTO_TYPEDRIVENONLY . ?stereo ex:base_Class ?this . } UNION { ?stereo a custom:QTO_TYPEDRIVENOVERRIDE . ?stereo ex:base_Class ?this . + } + } + """ + . + + +ex:QuantitySet a sh:SPARQLTarget; + sh:select """ + PREFIX ex: + PREFIX rdf: + PREFIX xmi: + PREFIX custom: + + SELECT ?this + WHERE { + ?this xmi:type "uml:Class" . + + { + } UNION { ?stereo a custom:QTO_OCCURRENCEDRIVEN . ?stereo ex:base_Class ?this . @@ -438,7 +464,83 @@ ex:hasCorrespondingUmlConcept a sh:SPARQLTarget; """ . - + +ex:hasApplicableObjectWithType a sh:SPARQLConstraint ; + sh:message "The Property|Quantity Set [{?stereoName}] '{?psetName}' should be associated to an element with corresponding IfcObjectType, not {?applicableEntity}" ; + sh:select """ + PREFIX ex: + PREFIX rdf: + PREFIX xmi: + PREFIX custom: + + SELECT ?this ?psetName ?stereoName ?applicableEntity + WHERE { + ?this ex:name ?psetName . + ?stereo ex:base_Class ?this . + ?stereo a ?stereoUrl . + + { + ?stereo a custom:PSET_TYPEDRIVENOVERRIDE . + } UNION { + ?stereo a custom:PSET_PERFORMANCEDRIVEN . + } UNION { + ?stereo a custom:PSET_OCCURRENCEDRIVEN . + } UNION { + ?stereo a custom:PSET_TYPEDRIVENONLY . + } UNION { + ?stereo a custom:QTO_TYPEDRIVENONLY . + } UNION { + ?stereo a custom:QTO_TYPEDRIVENOVERRIDE . + } UNION { + ?stereo a custom:QTO_OCCURRENCEDRIVEN . + } + + BIND(REPLACE(str(?stereoUrl), ".+/", "") AS ?stereoName) + + ?assoc xmi:type "uml:AssociationClass" . + ?assoc ex:containedIn ?package . + ?package ex:name ?packageName . + + ?end1 a ex:memberEnd . + ?end1 ex:containedIn ?assoc . + ?end1 xmi:idref ?prop1 . + ?type1 ex:containedIn ?prop1 . + ?type1 xmi:idref ?this . + + ?end2 a ex:memberEnd . + ?end2 ex:containedIn ?assoc . + ?end2 xmi:idref ?prop2 . + ?type2 ex:containedIn ?prop2 . + ?type2 xmi:idref ?applicability . + + FILTER(?end1 != ?end2) . + FILTER(?packageName = "PropertySetsforObjects" || ?packageName = "QuantitySetsforObjects") . + + ?applicability ex:name ?applicabilityName . + + BIND(if( + regex(?applicabilityName, "\\\\."), + REPLACE(?applicabilityName, "(Type)Enum\\\\..+", ""), + ?applicabilityName + ) AS ?applicableEntity) + + FILTER NOT EXISTS { + ?assoc2 xmi:type "uml:AssociationClass" . + ?assoc2 ex:containedIn ?package2 . + ?package2 ex:name "ObjectTyping" . + + ?end22 a ex:memberEnd . + ?end22 ex:containedIn ?assoc2 . + ?end22 xmi:idref ?prop22 . + ?type22 ex:containedIn ?prop22 . + ?type22 xmi:idref ?typingApplicability . + ?typingApplicability ex:name ?applicableEntity . + } + } + """ + . + + ex:hasIfcObjectOrPredefinedType a sh:SPARQLTarget; sh:message "The association '{?assocName}' in package '{?packageName}' establishes an invalid relationship to '{?applicableName}'" ; sh:select """ @@ -801,3 +903,8 @@ ex:ParametrizationForConceptUsageDocumentation a sh:NodeShape ; sh:target ex:ConceptUsageDocumentation; sh:sparql ex:hasCorrespondingUmlConcept . + +ex:ObjectTypeAssociationForTypeDrivenPropSets a sh:NodeShape ; + sh:target ex:TypeDrivenPropertyOrQuantitySet; + sh:sparql ex:hasApplicableObjectWithType + . \ No newline at end of file