|
@@ -5,84 +5,7 @@ const SPARQL_ENDPOINT = "/SystemDesignOntology2Layers/sparql"
|
|
|
const dropVocabularyPrefix = str => str.substring(30);
|
|
|
const dropDescriptionPrefix = str => str.substring(30);
|
|
|
|
|
|
-const getCellIRI = cellId => `\
|
|
|
-PREFIX drawio: <http://ua.be/sdo2l/vocabulary/formalisms/drawio#>
|
|
|
-
|
|
|
-SELECT DISTINCT ?cell
|
|
|
-WHERE {
|
|
|
- ?cell drawio:hasDrawioId "${cellId}" .
|
|
|
-
|
|
|
-}`;
|
|
|
-
|
|
|
-
|
|
|
-const whatIsCell = cellId => `\
|
|
|
-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/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 ?rel_type ?as_element ?as_type
|
|
|
-WHERE {
|
|
|
- ?cell drawio:hasDrawioId "${cellId}" .
|
|
|
-
|
|
|
- # 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 rdfs:subClassOf object_diagram:Object . # restrict types to objects
|
|
|
-
|
|
|
- # Only get most concrete type:
|
|
|
- NOT EXISTS {
|
|
|
- ?another_more_concrete_type rdfs:subClassOf ?as_type .
|
|
|
- ?as_element a ?another_more_concrete_type
|
|
|
- FILTER(?another_more_concrete_type != ?as_type)
|
|
|
- }
|
|
|
-}`;
|
|
|
-
|
|
|
-const getCellIri = cellId => `\
|
|
|
-PREFIX drawio: <http://ua.be/sdo2l/vocabulary/formalisms/drawio#>
|
|
|
-
|
|
|
-SELECT DISTINCT ?cell ?rel_type ?as_element ?as_type
|
|
|
-WHERE {
|
|
|
- ?cell drawio:hasDrawioId "${cellId}" .
|
|
|
- ?element a ?type .
|
|
|
- ?type rdfs:subClassOf object_diagram:Object .
|
|
|
- NOT EXISTS {
|
|
|
- ?more_concrete_type rdfs:subClassOf ?type .
|
|
|
- ?element a ?more_concrete_type .
|
|
|
- FILTER(?more_concrete_type != ?type)
|
|
|
- }
|
|
|
-}`;
|
|
|
-
|
|
|
-const getAllOutgoingRelations = iri => `\
|
|
|
-SELECT DISTINCT ?rel ?other
|
|
|
-WHERE {
|
|
|
- <${iri}> ?rel ?other .
|
|
|
-}`;
|
|
|
-
|
|
|
+// Query that navigates the given link from the given source element, and returns the IRI and most-concrete-type of the target element.
|
|
|
const getOutgoingLink = (iri, link_type) => `\
|
|
|
PREFIX object_diagram: <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#>
|
|
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
@@ -99,6 +22,7 @@ WHERE {
|
|
|
}
|
|
|
}`;
|
|
|
|
|
|
+// Query that gets the IRI and most-concrete-type of a given drawio cell.
|
|
|
const getCellStuff = (cellId) => `\
|
|
|
PREFIX drawio: <http://ua.be/sdo2l/vocabulary/formalisms/drawio#>
|
|
|
PREFIX object_diagram: <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#>
|
|
@@ -116,6 +40,7 @@ WHERE {
|
|
|
}
|
|
|
}`;
|
|
|
|
|
|
+// Query that, for a given cell IRI, gets the name of the diagram containing the cell, and the ID of the cell.
|
|
|
const getDiagramAndCellId = cellIri => `\
|
|
|
PREFIX drawio: <http://ua.be/sdo2l/vocabulary/formalisms/drawio#>
|
|
|
PREFIX object_diagram: <http://ua.be/sdo2l/vocabulary/formalisms/object_diagram#>
|
|
@@ -127,6 +52,7 @@ WHERE {
|
|
|
?model object_diagram:hasName ?diagramName .
|
|
|
}`;
|
|
|
|
|
|
+// Query that gets ALL subclass relations.
|
|
|
const getSubClassRelations = `
|
|
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
|
|
|
@@ -135,58 +61,44 @@ WHERE {
|
|
|
?subclass rdfs:subClassOf ?superclass
|
|
|
}`;
|
|
|
|
|
|
+// (Hardcoded) link types exposed to the user.
|
|
|
+const typeToLinkType = new Map([
|
|
|
+ ["formalisms/drawio#Cell", {
|
|
|
+ query: "formalisms/cs_as#parsedAs",
|
|
|
+ name: "Is parsed as",
|
|
|
+ }],
|
|
|
+ ["formalisms/pm#Activity", {
|
|
|
+ query: "formalisms/pm#isTransformation",
|
|
|
+ name: "Is typed by transformation",
|
|
|
+ }],
|
|
|
+ ["formalisms/pm#Artifact", {
|
|
|
+ query: "formalisms/pm#hasType",
|
|
|
+ name: "Is typed by formalism",
|
|
|
+ }],
|
|
|
+ ["formalisms/object_diagram#Object", {
|
|
|
+ query: "formalisms/cs_as#renderedAs",
|
|
|
+ name: "Is rendered as",
|
|
|
+ }],
|
|
|
+ ["base/ftg#Transformation", {
|
|
|
+ query: "formalisms/pm#occursAsActivity",
|
|
|
+ name: "Occurs as activity",
|
|
|
+ }],
|
|
|
+ ["base/ftg#Formalism", {
|
|
|
+ query: "formalisms/pm#occursAsArtifact",
|
|
|
+ name: "Occurs as artifact",
|
|
|
+ }],
|
|
|
+]);
|
|
|
+
|
|
|
// mapping from class-IRI to array of superclass-IRIs
|
|
|
-const superclasses = new Map();
|
|
|
+const superclasses = new Map(); // map is populated as soon as the plugin is loaded
|
|
|
|
|
|
function getQueries(type) {
|
|
|
- const sups = superclasses.get(type) || [];
|
|
|
- const result = getBaseQueries(type).concat(... sups.map(sup => getBaseQueries(sup)));
|
|
|
+ const result = [].concat(
|
|
|
+ typeToLinkType.get(dropVocabularyPrefix(type)) || [],
|
|
|
+ ... (superclasses.get(type) || []).map(supertype => typeToLinkType.get(dropVocabularyPrefix(supertype)) || []));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-// Some hardcoded relations...
|
|
|
-function getBaseQueries(type) {
|
|
|
- const queries = [];
|
|
|
- if (type.endsWith("formalisms/drawio#Cell")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/cs_as#parsedAs",
|
|
|
- name: "Is parsed as",
|
|
|
- });
|
|
|
- }
|
|
|
- if (type.endsWith("formalisms/pm#Activity")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/pm#isTransformation",
|
|
|
- name: "Is typed by transformation",
|
|
|
- });
|
|
|
- }
|
|
|
- if (type.endsWith("formalisms/pm#Artifact")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/pm#hasType",
|
|
|
- name: "Is typed by formalism",
|
|
|
- });
|
|
|
- }
|
|
|
- if (type.endsWith("formalisms/object_diagram#Object")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/cs_as#renderedAs",
|
|
|
- name: "Is rendered as",
|
|
|
- });
|
|
|
- }
|
|
|
- if (type.endsWith("base/ftg#Transformation")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/pm#occursAsActivity",
|
|
|
- name: "Occurs as activity",
|
|
|
- });
|
|
|
- }
|
|
|
- if (type.endsWith("base/ftg#Formalism")) {
|
|
|
- queries.push({
|
|
|
- query: "formalisms/pm#occursAsArtifact",
|
|
|
- name: "Occurs as activity",
|
|
|
- });
|
|
|
- }
|
|
|
- return queries;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
function executeSPARQL(query) {
|
|
|
const body = new URLSearchParams();
|
|
|
body.append("query", query);
|
|
@@ -360,7 +272,8 @@ Draw.loadPlugin(function(ui) {
|
|
|
const shortType = dropVocabularyPrefix(type);
|
|
|
// console.log(path, element, type);
|
|
|
let newParent;
|
|
|
- if (superclasses.get(type).some(t => t.endsWith("drawio#Cell"))) {
|
|
|
+ // If the menu item is a (subtype of) a drawio cell, then clicking on it will take us to that cell in drawio.
|
|
|
+ if ((superclasses.get(type) || []).some(t => t.endsWith("drawio#Cell"))) {
|
|
|
newParent = menu.addItem(relName + ' ' + shortType, null, () => goto(element), parent);
|
|
|
} else {
|
|
|
newParent = menu.addItem(relName + ' ' + shortType, null, null, parent);
|
|
@@ -384,7 +297,7 @@ Draw.loadPlugin(function(ui) {
|
|
|
executeSPARQL(getCellStuff(cell.id))
|
|
|
.then(results => {
|
|
|
for (const {element, type} of results) {
|
|
|
- getInfo(element.value, type.value, 8, modelverseMenu, "Is a");
|
|
|
+ getInfo(element.value, type.value, 10, modelverseMenu, "Is a");
|
|
|
}
|
|
|
})
|
|
|
}
|