浏览代码

Updating the model with the shacl and sparql files for the wheel
weighting requirement.

Lucas Albertins 2 年之前
父节点
当前提交
cb5e80ef40

+ 4 - 4
examples/oml/SystemDesignOntology2Layers/src/oml/ua.com.be/sdo2l/description/structuralModels.oml

@@ -46,7 +46,7 @@ description <http://ua.com.be/sdo2l/description/structuralModels#> as components
 	ci wheel2-massAttribute : comp:Attribute [
 		base:hasIdentifier "w2-mass"
 		base:hasCanonicalName "w2-mass att"
-		vim4:hasDoubleNumber "3"^^xsd:double
+		vim4:hasDoubleNumber "2.1"^^xsd:double
 		vim4:characterizes wheel2-component
 		vim4:unit iso-80000-4.1:kilogram
 	]
@@ -59,7 +59,7 @@ description <http://ua.com.be/sdo2l/description/structuralModels#> as components
 	ci wheel3-massAttribute : comp:Attribute [
 		base:hasIdentifier "w3-mass"
 		base:hasCanonicalName "w3-mass att"
-		vim4:hasDoubleNumber "1"^^xsd:double
+		vim4:hasDoubleNumber "1.9"^^xsd:double
 		vim4:characterizes wheel3-component
 		vim4:unit iso-80000-4.1:kilogram
 	]
@@ -72,7 +72,7 @@ description <http://ua.com.be/sdo2l/description/structuralModels#> as components
 	ci wheel4-massAttribute : comp:Attribute [
 		base:hasIdentifier "w4-mass"
 		base:hasCanonicalName "w4-mass att"
-		vim4:hasDoubleNumber "3"^^xsd:double
+		vim4:hasDoubleNumber "2"^^xsd:double
 		vim4:characterizes wheel4-component
 		vim4:unit iso-80000-4.1:kilogram
 	]
@@ -81,7 +81,7 @@ description <http://ua.com.be/sdo2l/description/structuralModels#> as components
 		base:contains wheel1-component
 		base:contains wheel2-component
 		base:contains wheel3-component
-		base:contains wheel4-component
+	//	base:contains wheel4-component
 	]
 	
 	ref ci car-structural-model [

+ 1 - 0
examples/oml/SystemDesignOntology2Layers/src/oml/ua.com.be/sdo2l/description/traces.oml

@@ -29,6 +29,7 @@ description <http://ua.com.be/sdo2l/description/traces#> as traces {
 		traces:isFollowedBy endev-req-elicitation
 		traces:starts wf:requirement-elicitation-act
 	]
+	
 	ci endev-req-elicitation : traces:EndingEvent [
 		traces:provides requirements:reqlist-car-system
 		traces:isFollowedBy staev-arch-design

+ 62 - 3
examples/oml/SystemDesignOntology2Layers/src/shacl/shacl.ttl

@@ -3,6 +3,7 @@
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 @prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix vim4: <http://bipm.org/jcgm/vim4#> .
 
 @prefix comp: <http://ua.com.be/sdo2l/vocabulary/component#> .
 @prefix base: <http://ua.com.be/sdo2l/vocabulary/base#> .
@@ -25,6 +26,10 @@ comp-shapes:
 	sh:declare [
 		sh:prefix "rdf" ;
 		sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ;
+	] ;
+	sh:declare [
+		sh:prefix "vim4" ;
+		sh:namespace "http://bipm.org/jcgm/vim4#"^^xsd:anyURI ;
 	] .
 	
 comp-shapes:Car_contains_4_Wheels_shacl
@@ -34,7 +39,61 @@ comp-shapes:Car_contains_4_Wheels_shacl
 		sh:path base:contains ;
 		sh:class comp:WheelComponent ;
 		sh:nodeKind sh:IRI ;
-		sh:minCount 3 ;
-		sh:maxCount 3 ;
+		sh:minCount 4 ;
+		sh:maxCount 4 ;
 	] ;
-	sh:closed false .
+	sh:property [
+    	sh:path base:contains ;
+    	sh:severity sh:Warning ;
+    	sh:sparql [
+      	a sh:SPARQLConstraint ;
+      	sh:message "Wheel mass difference from the average should be less than 5%" ;
+      	sh:prefixes [ 
+      		sh:declare [
+				sh:prefix "comp" ;
+				sh:namespace "http://ua.com.be/sdo2l/vocabulary/component#"^^xsd:anyURI ;
+				] ] ,
+	 		[ sh:declare [
+				sh:prefix "base" ;
+				sh:namespace "http://ua.com.be/sdo2l/vocabulary/base#"^^xsd:anyURI ;
+			] ]  ,
+			[ sh:declare [
+				sh:prefix "rdf" ;
+				sh:namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#"^^xsd:anyURI ;
+			] ] ,
+			[ sh:declare [
+				sh:prefix "vim4" ;
+				sh:namespace "http://bipm.org/jcgm/vim4#"^^xsd:anyURI ;
+			] ];
+      	sh:select """
+       		SELECT $this ?wheel ?attMass ?avg
+			WHERE {
+				$this rdf:type comp:CarComponent .
+				?wheel rdf:type comp:WheelComponent .
+				$this $PATH ?wheel .
+				?attribute rdf:type comp:Attribute .
+				?attribute vim4:characterizes ?wheel .
+				?attribute base:hasIdentifier ?attID .
+			    FILTER regex(?attID, "w[0-9]-mass") .
+				?attribute vim4:hasDoubleNumber ?attMass .
+				{
+				SELECT $this (avg(?attMass2) as ?avg)
+				WHERE {
+					$this rdf:type comp:CarComponent .
+					?wheel2 rdf:type comp:WheelComponent .
+					$this $PATH ?wheel2 .
+					?attribute2 rdf:type comp:Attribute .
+					?attribute2 vim4:characterizes ?wheel2 .
+					?attribute2 base:hasIdentifier ?attID2 .
+			    	FILTER regex(?attID2, "w[0-9]-mass") .
+					?attribute2 vim4:hasDoubleNumber ?attMass2 .
+				}
+				GROUP BY $this
+				}
+			}
+			HAVING (abs(?attMass-?avg) >= (?avg*0.05) )
+        	"""
+    	]
+  	] ;
+	sh:closed false .
+

+ 0 - 7
examples/oml/SystemDesignOntology2Layers/src/sparql/query.sparql

@@ -1,7 +0,0 @@
-PREFIX base:   <http://ua.com.be/sdo2l/vocabulary/base#>
-
-SELECT ?x ?y
-
-WHERE {
-	?x base:contains ?y
-}

+ 33 - 0
examples/oml/SystemDesignOntology2Layers/src/sparql/query.ttl

@@ -0,0 +1,33 @@
+PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX vim4: <http://bipm.org/jcgm/vim4#>
+PREFIX comp: <http://ua.com.be/sdo2l/vocabulary/component#>
+PREFIX base: <http://ua.com.be/sdo2l/vocabulary/base#>
+
+
+SELECT ?car ?wheel ?attMass ?avg
+WHERE {
+	?car rdf:type comp:CarComponent .
+	?wheel rdf:type comp:WheelComponent .
+	?car base:contains ?wheel .
+	?attribute rdf:type comp:Attribute .
+	?attribute vim4:characterizes ?wheel .
+	?attribute base:hasIdentifier ?attID .
+    FILTER regex(?attID, "w[0-9]-mass") .
+	?attribute vim4:hasDoubleNumber ?attMass .
+	{
+	SELECT ?car2 (avg(?attMass2) as ?avg)
+	WHERE {
+		?car2 rdf:type comp:CarComponent .
+		?wheel2 rdf:type comp:WheelComponent .
+		?car2 base:contains ?wheel2 .
+		?attribute2 rdf:type comp:Attribute .
+		?attribute2 vim4:characterizes ?wheel2 .
+		?attribute2 base:hasIdentifier ?attID2 .
+    	FILTER regex(?attID2, "w[0-9]-mass") .
+		?attribute2 vim4:hasDoubleNumber ?attMass2 .
+	}
+	GROUP BY ?car2
+	}
+}
+HAVING (abs(?attMass-?avg) >= (?avg*0.05) )
+