Skip to content

Commit

Permalink
Updated SysML vocab and shapes
Browse files Browse the repository at this point in the history
Removed the class name prefix, used OMG namespace
  • Loading branch information
jamsden committed Oct 9, 2024
1 parent 308183c commit af5ce90
Show file tree
Hide file tree
Showing 5 changed files with 20,483 additions and 20,031 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
.DS_Store
/.venv
60 changes: 32 additions & 28 deletions specs/sysml/Resources/genVocabAndShapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"# Generate sysml-vocab.ttl\n",
"\n",
"Generate the SysML v2 vocabulary from /Users/jamsden/Developer/SysML/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore. This will be the merged KerML and SysML into a single vocabulary with a single namespace.\n",
"\n",
"The OASIS SysML vocabulary uses the OMG namespace. \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -24,6 +26,7 @@
"import os\n",
"\n",
"# use the class name as a prefix to the attribute name to ensure they are unique\n",
"# this should no longer be used, but is retained.\n",
"def qualident(eClass, eAttribute):\n",
" return eClass.name[0].lower() + eClass.name[1:] + '_' + eAttribute.name[0].capitalize() + eAttribute.name[1:] \n",
"\n",
Expand All @@ -50,8 +53,8 @@
"vann = Namespace('http://purl.org/vocab/vann/')\n",
"oslc = Namespace('http://open-services.net/ns/core#')\n",
"oslc_am = Namespace('http://open-services.net/ns/am#')\n",
"#oslc_sysmlv2 = Namespace('http://www.omg.org/spec/SysML/2.0#') # OMG namespace\n",
"oslc_sysmlv2 = Namespace('http://open-services.net/ns/sysmlv2#') # OASIS namespace\n",
"oslc_sysmlv2 = Namespace('http://www.omg.org/spec/SysML/2.0#') # OMG namespace\n",
"#oslc_sysmlv2 = Namespace('http://open-services.net/ns/sysmlv2#') # OASIS namespace\n",
"\n",
"# add the copywrite information\n",
"copyright = \"\"\"\n",
Expand All @@ -74,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -102,7 +105,7 @@
"\n",
"# load the SysML.ecore model - this is the merged KerML and SysML metamodel using a single namespace\n",
"rset = ResourceSet()\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore'))\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore'))\n",
"mm_root = resource.contents[0]\n",
"rset.metamodel_registry[mm_root.nsURI] = mm_root\n",
"# At this point, the .ecore is loaded in the 'rset' as a metamodel\n",
Expand All @@ -123,7 +126,7 @@
"\n",
" # generate the properties\n",
" for a in c.eStructuralFeatures:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # done't use the class name as a prefix to the attribute name to ensure they are unique\n",
" s = oslc_sysmlv2.term(name)\n",
" g.add((s, RDF.type, RDF.Property))\n",
" g.add((s, RDFS.label, Literal(name)))\n",
Expand All @@ -137,7 +140,7 @@
"\n",
" # generate the enumeration literals\n",
" for a in c.eLiterals:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # don't use the class name as a prefix to the attribute name to ensure they are unique\n",
" s = oslc_sysmlv2.term(name)\n",
" g.add((s, RDF.type, oslc_sysmlv2.term(c.name)))\n",
" g.add((s, RDFS.label, Literal(name)))\n",
Expand All @@ -163,12 +166,14 @@
"Generate the SysML v2 constraints from /Users/jamsden/Developer/SysML/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore. This will be the merged KerML and SysML into a single vocabulary with a single namespace. \n",
"\n",
"This depends on the sysml-vocab.ttl file that was generated above.\n",
"\n",
"The ResourceShape properties also do not need class prefixes because they are added to the classes using blank nodes which makes them unique.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -203,19 +208,18 @@
" addSuperclassProperties(super, shape, graph)\n",
" # and add the properties for this superclass\n",
" for a in super.eStructuralFeatures:\n",
" name = qualident(super, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # don't use the class name as a prefix to the attribute name to ensure they are unique\n",
" graph.add((shape, oslc.property, URIRef(oslc_sysml_shapes.term(name))))\n",
"\n",
" # some useful RDF namespaces\n",
"vann = Namespace('http://purl.org/vocab/vann/')\n",
"oslc = Namespace('http://open-services.net/ns/core#')\n",
"oslc_am = Namespace('http://open-services.net/ns/am#')\n",
"#oslc_sysml_shapes = Namespace('https://www.omg.org/spec/SysML/shapes/20240801#') # OMG namespace\n",
"oslc_sysml_shapes = Namespace('http://open-services.net/ns/sysmlv2/shapes/20240801#') # OASIS namespace\n",
"\n",
"#oslc_sysmlv2 = Namespace('http://www.omg.org/spec/SysML/2.0#') # OMG namespace\n",
"oslc_sysmlv2 = Namespace('http://open-services.net/ns/sysmlv2#') # OASIS namespace\n",
"oslc_sysml_shapes = Namespace('https://www.omg.org/spec/SysML/shapes/20240801#') # OMG namespace versioned for constraints\n",
"#oslc_sysml_shapes = Namespace('http://open-services.net/ns/sysmlv2/shapes/20240801#') # OASIS namespace\n",
"\n",
"oslc_sysmlv2 = Namespace('http://www.omg.org/spec/SysML/2.0#') # OMG namespace\n",
"#oslc_sysmlv2 = Namespace('http://open-services.net/ns/sysmlv2#') # OASIS namespace\n",
"\n",
"jazz_am = Namespace('http://jazz.net/ns/dm/linktypes#')\n",
"\n",
Expand All @@ -224,7 +228,7 @@
"g.bind('oslc_sysmlv2', oslc_sysmlv2)\n",
"g.bind('oslc_am', oslc_am)\n",
"g.bind('oslc', oslc)\n",
"g.bind('', oslc_sysml_shapes)\n",
"g.bind('oslc_sysml_shapes', oslc_sysml_shapes)\n",
"g.bind('jazz_am', jazz_am)\n",
"\n",
"s = URIRef(oslc_sysml_shapes)\n",
Expand All @@ -242,7 +246,7 @@
"\n",
"# load the SysML.ecore model - this is the merged KerML and SysML metamodel using a single namespace\n",
"rset = ResourceSet()\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore'))\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML-v2-Pilot-Implementation/org.omg.sysml/model/SysML.ecore'))\n",
"mm_root = resource.contents[0]\n",
"rset.metamodel_registry[mm_root.nsURI] = mm_root\n",
"# At this point, the .ecore is loaded in the 'rset' as a metamodel\n",
Expand All @@ -262,7 +266,7 @@
"\n",
" # generate the properties specific to this ResourceShape\n",
" for a in c.eStructuralFeatures:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # use the class name as a prefix to the attribute name to ensure they are unique\n",
" g.add((shape, oslc.property, URIRef(oslc_sysml_shapes.term(name))))\n",
"\n",
" # and create the oslc:Property elements defined by this EClass\n",
Expand Down Expand Up @@ -513,16 +517,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Graph identifier=N3cc6c1f0d9cf4628afbca599319c2ce3 (<class 'rdflib.graph.Graph'>)>"
"<Graph identifier=N58639f80d4ca4d92b9b18c039b7dafba (<class 'rdflib.graph.Graph'>)>"
]
},
"execution_count": 3,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -545,7 +549,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 23,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2556,7 +2560,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -2585,7 +2589,7 @@
"\n",
"# load the KerML.ecore model\n",
"rset = ResourceSet()\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML/SysML-v2-Pilot-Implementation/org.omg.sysml/model/KerML.ecore'))\n",
"resource = rset.get_resource(URI('/Users/jamsden/Developer/SysML-v2-Pilot-Implementation/org.omg.sysml/model/KerML.ecore'))\n",
"mm_root = resource.contents[0]\n",
"rset.metamodel_registry[mm_root.nsURI] = mm_root\n",
"# At this point, the .ecore is loaded in the 'rset' as a metamodel\n",
Expand All @@ -2606,7 +2610,7 @@
"\n",
" # generate the properties\n",
" for a in c.eStructuralFeatures:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # use the class name as a prefix to the attribute name to ensure they are unique\n",
" s = oslc_kerml.term(name)\n",
" g.add((s, RDF.type, RDF.Property))\n",
" g.add((s, RDFS.label, Literal(name)))\n",
Expand All @@ -2620,7 +2624,7 @@
"\n",
" # generate the enumeration literals\n",
" for a in c.eLiterals:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # don't use the class name as a prefix to the attribute name to ensure they are unique\n",
" s = oslc_kerml.term(name)\n",
" g.add((s, RDF.type, oslc_kerml.term(c.name)))\n",
" g.add((s, RDFS.label, Literal(name)))\n",
Expand Down Expand Up @@ -2656,7 +2660,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -2699,7 +2703,7 @@
"\n",
" # generate the properties to the ResourceShape\n",
" for a in c.eStructuralFeatures:\n",
" name = qualident(c, a) # use the class name as a prefix to the attribute name to ensure they are unique\n",
" name = a.name # don't use the class name as a prefix to the attribute name to ensure they are unique\n",
" g.add((shape, oslc.property, URIRef(oslc_sysml_shapes.term(name))))\n",
"\n",
" # and create the oslc:Property\n",
Expand Down Expand Up @@ -2961,7 +2965,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit af5ce90

Please sign in to comment.