فهرست منبع

Fun with SPARQL

Joeri Exelmans 2 سال پیش
والد
کامیت
6c5b286688

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 6 - 1800
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/description/artifacts/my_drawio.oml


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 12 - 172
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/description/artifacts/my_xopp.oml


+ 16 - 0
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/description/artifacts/my_xopp_to_drawio.oml

@@ -0,0 +1,16 @@
+// Hardcoded example of a traceability model that relates one XOPP-text-node to one Drawio-cell
+description <http://ua.be/sdo2l/description/artifacts/my_xopp_to_drawio#> as my_xopp_to_drawio {
+	extends <http://ua.be/sdo2l/description/artifacts/my_drawio#> as my_drawio
+	extends <http://ua.be/sdo2l/description/artifacts/my_xopp#> as my_xopp
+	
+	uses <http://ua.be/sdo2l/vocabulary/formalisms/traceability_model#> as traceability_model
+	uses <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#> as object_diagram
+	
+	ci model : traceability_model:TraceabilityModel
+	
+	ri link : traceability_model:TraceabilityLink [
+		from my_xopp:p0l0e1
+		to my_drawio:p0_cell_CvR4PfVCJDiI6bvIUUvl-2
+		object_diagram:inModel model
+	]
+}

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

@@ -4,4 +4,5 @@ description bundle <http://ua.be/sdo2l/description/bundle#> as ^bundle {
 	includes <http://ua.be/sdo2l/description/artifacts/my_drawio#>
 	includes <http://ua.be/sdo2l/description/artifacts/my_pm#>
 	includes <http://ua.be/sdo2l/description/artifacts/my_xopp#>
+	includes <http://ua.be/sdo2l/description/artifacts/my_xopp_to_drawio#>
 }

+ 2 - 2
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/cs_as.oml

@@ -4,8 +4,8 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/cs_as#> as cs_as {
 	extends <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#> as object_diagram
 	
 	relation entity CS_AS_Link :> traceability_model:TraceabilityLink [
-		from object_diagram:element
-		to object_diagram:element
+		from object_diagram:Object
+		to object_diagram:Object
 		forward parsedAs
 		reverse renderedAs
 		functional // Assuming that CS contains at least the same amount of the information as AS, there is only one way to parse something

+ 1 - 1
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/drawio.oml

@@ -6,7 +6,7 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/drawio#> as drawio {
 	extends <http://ua.be/sdo2l/vocabulary/formalisms/dict#> as dict
 	extends <http://www.w3.org/2001/XMLSchema#> as xsd
 
-	aspect element :> object_diagram:element []
+	aspect element :> object_diagram:Object []
 	
 	// Cells and Pages have a GUID generated by drawio.
 	aspect elementWithDrawioId :> element [

+ 7 - 9
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/object_diagram.oml

@@ -2,10 +2,8 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#> as object_
 	
 	extends <http://www.w3.org/2000/01/rdf-schema#> as rdfs
 
-	aspect element []
-	
-	concept Object :> element []
-	
+	aspect Object []
+		
 	// Compromise:
 	//  - use attributes only for scalar properties
 	//  - if we want to have a reference to an object as an attribute, use a link instead
@@ -13,23 +11,23 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#> as object_
 	// Supertype of all scalar properties that we consider to be a 'field' of an object
 	// An object can have any number of fields, hence this property is not functional
 	scalar property hasField [
-		domain element
+		domain Object
 		range rdfs:Literal // e.g., string, float, boolean, ...
 	]
 
 	// A link is also an object, meaning:
 	//   - it can have attributes
 	//   - it can be the source/target of another link
-	relation entity Link :> element [
-		from element
-		to element
+	relation entity Link :> Object [
+		from Object
+		to Object
 	]
 		
 	concept Model []
 	
 	relation entity HasObject [
 		from Model
-		to element
+		to Object
 		forward hasObject
 		reverse inModel
 		inverse functional // every Object can be part of at most one model

+ 2 - 2
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/pm.oml

@@ -35,9 +35,9 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/pm#> as pm {
 		functional
 	]
 
-	aspect element :> object_diagram:element []
+	aspect element :> object_diagram:Object []
 	
-	concept Activity :> element, Named [
+	concept Activity :> element, object_diagram:Object, Named [
 		// must have at least one of the following port types:
 		restricts some relation hasPort to CtrlInputPort
 		restricts some relation hasPort to CtrlOutputPort

+ 2 - 2
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/traceability_model.oml

@@ -3,8 +3,8 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/traceability_model#> as tra
 		
 	// A traceability link is just a link :)
 	relation entity TraceabilityLink :> object_diagram:Link [
-		from object_diagram:element
-		to object_diagram:element
+		from object_diagram:Object
+		to object_diagram:Object
 		asymmetric
 		irreflexive
 	]

+ 1 - 1
examples/oml/SystemDesignOntology2Layers/src/oml/ua.be/sdo2l/vocabulary/formalisms/xopp.oml

@@ -5,7 +5,7 @@ vocabulary <http://ua.be/sdo2l/vocabulary/formalisms/xopp#> as xopp {
 	extends <http://ua.be/sdo2l/vocabulary/formalisms/dict#> as dict
 	extends <http://www.w3.org/2001/XMLSchema#> as xsd
 
-	aspect element :> object_diagram:element []
+	aspect element :> object_diagram:Object []
 	
 	aspect LayerElement :> element [
 		restricts relation inLayer to exactly 1

+ 8 - 0
examples/oml/SystemDesignOntology2Layers/src/sparql/GetObjects.sparql

@@ -0,0 +1,8 @@
+# Just get all the "objects"
+
+PREFIX object_diagram: <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#>
+
+SELECT ?object
+WHERE {
+	?object a object_diagram:Object .
+} 

+ 12 - 0
examples/oml/SystemDesignOntology2Layers/src/sparql/GetTypesWithoutSubType.sparql

@@ -0,0 +1,12 @@
+prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX owl:  <http://www.w3.org/2002/07/owl#>
+
+SELECT ?type
+WHERE {
+	?type rdf:type owl:Class
+	NOT EXISTS {
+		?subtype rdfs:subClassOf ?type
+		FILTER(?subtype != ?type)
+	}
+}

+ 35 - 9
examples/oml/SystemDesignOntology2Layers/src/sparql/WhatIsCell.sparql

@@ -1,22 +1,48 @@
-# This query shows how we can ask for any drawio cell the different types of AS elements that it represents
+# This query shows how we can ask any incoming/outgoing traceability links of a drawio cell, and what those links point to
 
 PREFIX object_diagram: <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#>
 PREFIX drawio: <http://ua.be/sdo2l/vocabulary/formalisms/drawio#>
 PREFIX cs_as: <http://ua.be/sdo2l/vocabulary/formalisms/cs_as#>
-PREFIX rdf: <http://www.w3.org/2000/01/rdf-schema#>
+prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX oml: <http://opencaesar.io/oml#>
 PREFIX purl: <http://purl.org/dc/elements/1.1/>
+PREFIX trac: <http://ua.be/sdo2l/vocabulary/formalisms/traceability_model#>
+PREFIX owl:  <http://www.w3.org/2002/07/owl#>
 
-SELECT DISTINCT ?cell ?as_element ?as_type
+SELECT DISTINCT ?cell ?rel_type ?as_element ?as_type 
 WHERE {
-	?cell drawio:hasDrawioId "CvR4PfVCJDiI6bvIUUvl-6" .
-	?cell cs_as:parsedAs ?as_element .
+	?cell drawio:hasDrawioId "CvR4PfVCJDiI6bvIUUvl-2" .
+	
+	# Get all incoming and outgoing traceability links for "?cell":
+	{
+		?rel a trac:TraceabilityLink .
+		?rel oml:hasSource ?cell .
+		?rel oml:hasTarget ?as_element .
+	} UNION {
+		?rel a trac:TraceabilityLink .
+		?rel oml:hasTarget ?cell .
+		?rel oml:hasSource ?as_element .
+	}
+	
+	?rel a ?rel_type .
+	?rel_type rdfs:subClassOf trac:TraceabilityLink .
+	
+	# Only interested here in the most concrete type of the traceability link:
+	NOT EXISTS {
+		?more_concrete_type rdfs:subClassOf ?rel_type .
+		?rel a ?more_concrete_type .
+		FILTER(?more_concrete_type != ?rel_type) # needed because every type is its own subclass
+	}
 	
 	?as_element a ?as_type .
-	?as_type rdf:subClassOf object_diagram:element . # restrict types to objects
+	?as_type rdfs:subClassOf object_diagram:Object . # restrict types to objects
 	
-	# only get concrete types:
+	# Only get concrete types:
 	NOT EXISTS {
-		?as_type purl:type oml:Aspect .
+		?another_more_concrete_type rdfs:subClassOf ?as_type .
+		?as_element a ?another_more_concrete_type
+		FILTER(?another_more_concrete_type != ?as_type)
+		#?as_type purl:type oml:Aspect .
 	}
-} 
+}