Преглед изворни кода

Add 'PT', 'versioned' and 'acyclic' ontologies. Fix bug in 'statechart' ontology.

Joeri Exelmans пре 3 година
родитељ
комит
e168cdef75

+ 1 - 1
examples/oml/CDF/src/oml/flandersmake.be/cdf/description/my_pm.oml

@@ -28,7 +28,7 @@ description <http://flandersmake.be/cdf/description/my_pm#> as my_pm {
 	
 	
 	ci model : pm:Model [
-		immutable:hasUUID "pm1"
+		immutable:hasUUID "pm1" // this will turn 'model' also in an immutable thing
 		object_diagram:hasObject start
 		object_diagram:hasObject activity
 		object_diagram:hasObject ctrlIn

+ 19 - 0
examples/oml/CDF/src/oml/flandersmake.be/cdf/description/my_pm2.oml

@@ -1,11 +1,14 @@
 description <http://flandersmake.be/cdf/description/my_pm2#> as my_pm2 {
 	
 	extends <http://flandersmake.be/cdf/description/my_ftg#> as my_ftg
+	extends <http://flandersmake.be/cdf/description/my_pm#> as my_pm
 	
 	uses <http://flandersmake.be/cdf/vocabulary/pm#> as pm
 	uses <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_diagram
 	uses <http://flandersmake.be/cdf/vocabulary/immutable#> as immutable
 
+	uses <http://flandersmake.be/cdf/vocabulary/versioned#> as versioned
+
 	ci start : pm:Start [
 		pm:ctrlTo ctrlIn
 	]
@@ -20,6 +23,20 @@ description <http://flandersmake.be/cdf/description/my_pm2#> as my_pm2 {
 		pm:hasName "c_in"
 	]
 	ci ctrlOut : pm:CtrlOutputPort [
+		pm:hasName "c_out"
+		pm:ctrlTo ctrlIn2
+	]
+	
+	ci activity2 : pm:Activity [
+		pm:hasName "activity2"
+		pm:hasPort ctrlIn2
+		pm:hasPort ctrlOut2
+		pm:isTransformation my_ftg:t1
+	]
+	ci ctrlIn2 : pm:CtrlInputPort [
+		pm:hasName "c_in"
+	]
+	ci ctrlOut2 : pm:CtrlOutputPort [
 		pm:hasName "c_out"
 		pm:ctrlTo final
 	]
@@ -29,6 +46,8 @@ description <http://flandersmake.be/cdf/description/my_pm2#> as my_pm2 {
 	
 	ci model : pm:Model [
 		immutable:hasUUID "pm2"
+		versioned:hasParent my_pm:model
+		
 		object_diagram:hasObject start
 		object_diagram:hasObject activity
 		object_diagram:hasObject ctrlIn

+ 16 - 0
examples/oml/CDF/src/oml/flandersmake.be/cdf/description/my_statechart.oml

@@ -28,4 +28,20 @@ description <http://flandersmake.be/cdf/description/my_statechart#> as my_statec
 		object_diagram:hasObject default
 		object_diagram:hasObject t
 	]
+	
+	
+	// Illegal: parent-cycle
+	ci s1 : statechart:AndState [
+		statechart:hasName "s1"
+		statechart:hasParent s2
+		
+	]
+	ci s2 : statechart:AndState [
+		statechart:hasName "s2"
+		statechart:hasParent s3
+	]
+	ci s3 : statechart:AndState [
+		statechart:hasName "s3"
+		// statechart:hasParent s1 // ILLEGAL
+	]
 }

+ 32 - 0
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/acyclic.oml

@@ -0,0 +1,32 @@
+vocabulary <http://flandersmake.be/cdf/vocabulary/acyclic#> as acyclic {
+	
+	aspect element []
+	
+	relation entity Acyclic [
+		from element
+		to element
+		forward acyclicForward
+		irreflexive
+		asymmetric
+	]
+	
+	relation entity derivedTransitiveRelation [
+		from element
+		to element
+		forward transitiveForward
+		irreflexive
+		asymmetric
+		
+		// transitive // Currently ignored by reasoner. See workaround below.
+	]
+	
+	
+	rule DeriveTransitiveRelation [
+		acyclicForward(A, B) -> transitiveForward(A, B)
+	]
+	
+	// Workaround:
+	rule MakeTransitive [
+		transitiveForward(A, B) ^ transitiveForward(B, C) -> transitiveForward(A, C)
+	]
+}

+ 4 - 1
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/bundle.oml

@@ -1,7 +1,10 @@
 vocabulary bundle <http://flandersmake.be/cdf/vocabulary/bundle#> as ^bundle {
+	includes <http://flandersmake.be/cdf/vocabulary/acyclic#>
+	includes <http://flandersmake.be/cdf/vocabulary/class_diagram#>	
 	includes <http://flandersmake.be/cdf/vocabulary/ftg#>
 	includes <http://flandersmake.be/cdf/vocabulary/immutable#>
 	includes <http://flandersmake.be/cdf/vocabulary/object_diagram#>
-	includes <http://flandersmake.be/cdf/vocabulary/statechart#>
 	includes <http://flandersmake.be/cdf/vocabulary/pm#>
+	includes <http://flandersmake.be/cdf/vocabulary/pt#>
+	includes <http://flandersmake.be/cdf/vocabulary/statechart#>
 }

+ 32 - 10
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/class_diagram.oml

@@ -1,37 +1,59 @@
+// Currently unused
+// This is an attempt at showing how an instance of a Class Diagram itself can be seen as an object diagram.
+// We could implement a conformance check between such instance and another object diagram, for instance in SHACL.
+// Then, could we create an instance of 'class_diagram' that conforms to itself? I'm not entirely sure.
+// All of this is out-of-scope for CDF.
 vocabulary <http://flandersmake.be/cdf/vocabulary/class_diagram#> as class_diagram {
 
 	extends <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_diagram
 	extends <http://www.w3.org/2001/XMLSchema#> as xsd
 	
-	aspect node :> object_diagram:Object [
+	// objects that have a name
+	aspect element :> object_diagram:Object [
 		restricts scalar property hasName to exactly 1
 	]
 	
-	scalar property hasName [
-		domain node
+	scalar property hasName :> object_diagram:hasField [
+		domain element
 		range xsd:string
 		functional
 	]
 	
-	concept Class :> node []
-			
-	relation entity HasAttribute :> object_diagram:Link, node [
-		from Class
-		to Class
+	aspect classlike :> element []
+	
+	// A class is an object, with one field (its name):
+	concept Class :> classlike []
+	
+	relation entity HasAttribute :> object_diagram:Link, element [
+		from classlike
+		to Attribute
 		forward hasAttribute
 		reverse isAttributeOf
 		asymmetric
 		irreflexive
 	]
 	
-	relation entity Association :> object_diagram:Link, node [
+	// An attribute is an object, with two fields (name, type)
+	concept Attribute :> element [
+		restricts scalar property hasType to exactly 1
+	]
+
+	scalar property hasType :> object_diagram:hasField [
+		domain Attribute
+		range xsd:string // not sure if this will work out - maybe we need a relation to the actual type (=an object) itself
+		functional
+	]
+	
+	// An association is a link, with one field (its name)
+	relation entity Association :> classlike, object_diagram:Link [
 		from Class
 		to Class
 		asymmetric
 		irreflexive
 	]
 
+	// A class diagram is a model (=a set of objects)
 	concept ClassDiagram :> object_diagram:Model [
-		restricts all relation object_diagram:hasObject to node
+		restricts all relation object_diagram:hasObject to element
 	]
 }

+ 2 - 5
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/object_diagram.oml

@@ -1,7 +1,5 @@
 vocabulary <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_diagram {
 	
-	extends <http://flandersmake.be/cdf/vocabulary/immutable#> as immutable
-
 	extends <http://www.w3.org/2000/01/rdf-schema#> as rdfs
 
 	aspect Object []
@@ -24,15 +22,14 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_dia
 		to Object
 	]
 		
-	aspect Model :> immutable:Thing [
-	]
+	aspect Model []
 	
 	relation entity HasObject [
 		from Model
 		to Object
 		forward hasObject
 		reverse inModel
-		inverse functional
+		inverse functional // every Object can be part of at most one model
 		asymmetric
 		irreflexive
 	]

+ 9 - 9
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/pm.oml

@@ -35,9 +35,9 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/pm#> as pm {
 		functional
 	]
 
-	aspect Node :> object_diagram:Object []
+	aspect element :> object_diagram:Object []
 	
-	concept Activity :> Node, Named [
+	concept Activity :> element, Named [
 		// must have at least one of the following port types:
 		restricts some relation hasPort to CtrlInputPort
 		restricts some relation hasPort to CtrlOutputPort
@@ -53,7 +53,7 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/pm#> as pm {
 		irreflexive
 	]
 	
-	aspect Port :> Node, Named [
+	aspect Port :> element, Named [
 		restricts relation ofActivity to exactly 1
 	]
 	
@@ -81,14 +81,14 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/pm#> as pm {
 		restricts relation dataFrom to exactly 1
 	]
 	
-	concept Start :> Node, CtrlSource [
+	concept Start :> element, CtrlSource [
 		restricts relation ctrlTo to exactly 1
 	]
-	concept Final :> Node, CtrlSink [
+	concept Final :> element, CtrlSink [
 		restricts relation ctrlFrom to exactly 1
 	]
 	
-	concept Artifact :> Node, Named, DataSource, DataSink [
+	concept Artifact :> element, Named, DataSource, DataSink [
 		// an artifact must come from somewhere :)
 		restricts relation dataTo to min 1
 	]
@@ -103,17 +103,17 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/pm#> as pm {
 		irreflexive
 	]
 	
-	concept ForkJoin :> Node, CtrlSink, CtrlSource [
+	concept ForkJoin :> element, CtrlSink, CtrlSource [
 		restricts relation ctrlFrom to min 1
 		restricts relation ctrlTo to min 1
 	]
 	
-	concept Merge :> Node, CtrlSink, CtrlSource [
+	concept Merge :> element, CtrlSink, CtrlSource [
 		// Only one outgoing control flow link:
 		restricts relation ctrlTo to exactly 1
 	]
 	
 	concept Model :> object_diagram:Model [
-		restricts all relation object_diagram:hasObject to Node
+		restricts all relation object_diagram:hasObject to element
 	]
 }

+ 64 - 0
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/pt.oml

@@ -0,0 +1,64 @@
+vocabulary <http://flandersmake.be/cdf/vocabulary/pt#> as pt {
+	
+	extends <http://flandersmake.be/cdf/vocabulary/immutable#> as immutable
+	extends <http://flandersmake.be/cdf/vocabulary/ftg#> as ftg
+	extends <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_diagram
+	extends <http://flandersmake.be/cdf/vocabulary/acyclic#> as acyclic
+	
+	aspect Event :> immutable:Thing []
+	aspect Artifact :> immutable:Thing []
+	
+	// InternalArtifact: All model elements exist as descriptions in the ontology, are checked for consistency with their vocabulary, and can be part of SPARQL queries.
+	concept InternalArtifact :> Artifact, object_diagram:Model []
+	
+	// ExternalArtifact: We only keep the model as an immutable file, that we don't interpret any further. The immutable::UUID property is a URI of the file.
+	concept ExternalArtifact :> Artifact []
+	
+	concept StartEvent :> Event []
+	concept EndEvent :> Event []
+	
+	// We use 'past tense' for all relations on events, because they are historical in nature.
+	
+	relation entity Started [
+		from StartEvent
+		to ftg:Transformation
+		forward started
+		reverse wasStartedBy
+		asymmetric
+		irreflexive
+		functional
+	]
+	relation entity Ended [
+		from EndEvent
+		to StartEvent
+		forward ended
+		reverse wasEndedBy
+		asymmetric
+		irreflexive
+		functional
+	]
+
+	relation entity Consumed [
+		from StartEvent
+		to Artifact
+		forward consumed
+		reverse wasConsumedBy
+		asymmetric
+		irreflexive
+	]
+	relation entity Produced [
+		from EndEvent
+		to Artifact
+		forward produced
+		reverse wasProducedBy
+	]
+	
+	relation entity HappenedAfter :> acyclic:Acyclic [
+		from Event
+		to Event
+		forward happenedAfter
+		reverse happenedBefore
+		asymmetric
+		irreflexive
+	]
+}

+ 38 - 5
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/statechart.oml

@@ -2,8 +2,12 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/statechart#> as statechart {
 	
 	extends <http://flandersmake.be/cdf/vocabulary/object_diagram#> as object_diagram
 	extends <http://www.w3.org/2001/XMLSchema#> as xsd
+
+	extends <http://flandersmake.be/cdf/vocabulary/acyclic#> as acyclic
 	
-	aspect State :> object_diagram:Object [
+	aspect element :> object_diagram:Object []
+	
+	aspect State :> element [
 		restricts scalar property hasName to exactly 1
 	]
 	
@@ -15,6 +19,7 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/statechart#> as statechart {
 	
 	concept OrState :> State [
 		restricts relation hasDefaultState to exactly 1
+		restricts relation hasChild to min 1
 	]
 	
 	relation entity DefaultState :> object_diagram:Link [
@@ -26,10 +31,15 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/statechart#> as statechart {
 		asymmetric
 		irreflexive
 	]
+
+	rule DefaultStateIsChild [
+		OrState(P) ^ hasDefaultState(P,C) -> hasChild(P,C)
+	]
+
 	
 	concept AndState :> State []
 	
-	relation entity Parent :> object_diagram:Link [
+	relation entity Parent :> object_diagram:Link, acyclic:Acyclic [
 		from State
 		to State
 		forward hasParent
@@ -39,13 +49,36 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/statechart#> as statechart {
 		irreflexive
 	]
 	
-	relation entity Transition :> object_diagram:Link [
+	// Uncomment to add transitive 'hasAncestor' relation and forbid parent cycles:
+
+	//	relation entity HasAncestor [
+	//		from State
+	//		to State
+	//		forward hasAncestor
+	//		reverse hasDescendant
+	//		asymmetric
+	//		irreflexive
+	//		transitive // seems to have no effect in current version of OWL reasoner, see workaround below
+	//	]
+	//	
+	//	rule ParentIsAncestor [
+	//		hasParent(C,P) -> hasAncestor(C,P)
+	//	]
+	//	
+	//	// Workaround:
+	//	rule MakeTransitive [
+	//		hasAncestor(C,P) ^ hasAncestor(P,P2) -> hasAncestor(C,P2)
+	//	]
+	
+	relation entity Transition :> object_diagram:Link, element [
 		from State
 		to State
-		// uncomment to make label mandatory:
+		
 		restricts scalar property hasLabel to exactly 1
 	]
 	
+	// Currently, OML thinks the relation 'hasLabel' is a subtype of 'hasName'.
+	// Not sure why. This is not intended.
 	scalar property hasLabel :> object_diagram:hasField [
 		domain Transition
 		range xsd:string
@@ -54,7 +87,7 @@ vocabulary <http://flandersmake.be/cdf/vocabulary/statechart#> as statechart {
 	
 	concept Model :> object_diagram:Model, object_diagram:Object [
 		restricts relation hasRoot to exactly 1
-		restricts all relation object_diagram:hasObject to State
+		restricts all relation object_diagram:hasObject to element
 	]
 	
 	relation entity Root :> object_diagram:Link [

+ 16 - 0
examples/oml/CDF/src/oml/flandersmake.be/cdf/vocabulary/versioned.oml

@@ -0,0 +1,16 @@
+vocabulary <http://flandersmake.be/cdf/vocabulary/versioned#> as versioned {
+
+	extends <http://flandersmake.be/cdf/vocabulary/acyclic#> as acyclic
+	extends <http://flandersmake.be/cdf/vocabulary/immutable#> as immutable
+
+	aspect Versioned :> immutable:Thing []
+	
+	relation entity HasParent :> acyclic:Acyclic [
+		from Versioned
+		to Versioned
+		forward hasParent
+		reverse isParentOf
+		asymmetric
+		irreflexive
+	]
+}

+ 7 - 0
examples/oml/CDF/src/sparql/GetAncestors.sparql

@@ -0,0 +1,7 @@
+PREFIX statechart: <http://flandersmake.be/cdf/vocabulary/statechart#>
+
+SELECT ?child ?parent
+WHERE {
+	?child statechart:hasAncestor ?parent . 
+	?child statechart:hasName "s1" .
+}

+ 2 - 0
examples/oml/CDF/src/sparql/GetFields.sparql

@@ -6,5 +6,7 @@ SELECT ?object ?fieldType ?fieldValue
 WHERE {
 	?object object_diagram:hasField ?fieldValue .
 	?object ?fieldType ?fieldValue .
+	
+	# We're only interested in the more concrete property:
 	FILTER(?fieldType != object_diagram:hasField)
 }