|
@@ -64,34 +64,50 @@ WHERE {
|
|
|
|
|
|
// (Hardcoded) link types exposed to the user.
|
|
|
const typeToLinkType = new Map([
|
|
|
- ["formalisms/object_diagram#Object", {
|
|
|
- query: "formalisms/cs_as#parsedAs",
|
|
|
- name: "Is parsed as",
|
|
|
- }],
|
|
|
- ["formalisms/object_diagram#Object", {
|
|
|
- query: "formalisms/cs_as#renderedAs",
|
|
|
- name: "Is rendered as",
|
|
|
- }],
|
|
|
- ["formalisms/object_diagram#Object", {
|
|
|
- query: "formalisms/object_diagram#inModel",
|
|
|
- name: "Part of model",
|
|
|
- }],
|
|
|
- ["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/ftg#Transformation", {
|
|
|
- query: "formalisms/pm#occursAsActivity",
|
|
|
- name: "Occurs as activity",
|
|
|
- }],
|
|
|
- ["formalisms/ftg#Formalism", {
|
|
|
- query: "formalisms/pm#occursAsArtifact",
|
|
|
- name: "Occurs as artifact",
|
|
|
- }],
|
|
|
+ ["formalisms/object_diagram#Object", [
|
|
|
+ {
|
|
|
+ query: "formalisms/cs_as#parsedAs",
|
|
|
+ name: "Is parsed as",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ query: "formalisms/cs_as#renderedAs",
|
|
|
+ name: "Is rendered as",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ query: "formalisms/object_diagram#inModel",
|
|
|
+ name: "Is part of model",
|
|
|
+ },
|
|
|
+ ]],
|
|
|
+ ["formalisms/drawio#Model", [
|
|
|
+ {
|
|
|
+ query: "formalisms/drawio#hasRootCell",
|
|
|
+ name: "Has root",
|
|
|
+ },
|
|
|
+ ]],
|
|
|
+ ["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/ftg#Transformation", [
|
|
|
+ {
|
|
|
+ query: "formalisms/pm#occursAsActivity",
|
|
|
+ name: "Occurs as activity",
|
|
|
+ }
|
|
|
+ ]],
|
|
|
+ ["formalisms/ftg#Formalism", [
|
|
|
+ {
|
|
|
+ query: "formalisms/pm#occursAsArtifact",
|
|
|
+ name: "Occurs as artifact",
|
|
|
+ },
|
|
|
+ ]],
|
|
|
]);
|
|
|
|
|
|
// mapping from class-IRI to array of superclass-IRIs
|
|
@@ -101,6 +117,7 @@ function getQueries(type) {
|
|
|
const result = [].concat(
|
|
|
typeToLinkType.get(dropVocabularyPrefix(type)) || [],
|
|
|
... (superclasses.get(type) || []).map(supertype => typeToLinkType.get(dropVocabularyPrefix(supertype)) || []));
|
|
|
+ // console.log("getQueries,type=",type,"superclasses=",superclasses.get(type),"result=",result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -280,36 +297,34 @@ fetch(BACKEND+"/version")
|
|
|
// Override context menu when right-clicking somewhere in the diagram:
|
|
|
const oldFactoryMethod = ui.editor.graph.popupMenuHandler.factoryMethod;
|
|
|
ui.editor.graph.popupMenuHandler.factoryMethod = function(menu, cell, evt) {
|
|
|
+ // We recursively construct a submenu where the user can navigate the onthology:
|
|
|
const modelverseMenu = menu.addItem("ModelVerse", null, null);
|
|
|
oldFactoryMethod.apply(this, arguments);
|
|
|
if (cell && cell.vertex) {
|
|
|
const alreadyVisited = new Set();
|
|
|
- function getInfo(element, type, maxRecursion, parent, relName) {
|
|
|
+ function buildMenu(element, type, maxRecursion, parentMenuItem, relName) {
|
|
|
if (alreadyVisited.has(element+'---'+type)) {
|
|
|
- // console.log('alreadyVisited')
|
|
|
return; // don't go in circles
|
|
|
}
|
|
|
const shortType = dropVocabularyPrefix(type);
|
|
|
- // console.log(path, element, type);
|
|
|
- let newParent;
|
|
|
- // If the menu item is a (subtype of) a drawio cell, then clicking on it will take us to that cell in drawio.
|
|
|
+ let createdMenuItem;
|
|
|
+ // 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);
|
|
|
+ createdMenuItem = menu.addItem(relName + ' ' + shortType, null, () => goto(element), parentMenuItem);
|
|
|
} else {
|
|
|
- newParent = menu.addItem(relName + ' ' + shortType, null, null, parent);
|
|
|
+ createdMenuItem = menu.addItem(relName + ' ' + shortType, null, null, parentMenuItem);
|
|
|
}
|
|
|
alreadyVisited.add(element+'---'+type);
|
|
|
if (maxRecursion <= 0) {
|
|
|
- // console.log('maxRecursion 0')
|
|
|
return;
|
|
|
}
|
|
|
const queries = getQueries(type);
|
|
|
for (const {query, name} of queries) {
|
|
|
+ // console.log("RemDepth=",maxRecursion,"element=",element,"queries=",queries);
|
|
|
executeSPARQL(getOutgoingLink(element, "http://ua.be/sdo2l/vocabulary/"+query))
|
|
|
.then(results => {
|
|
|
- // console.log(path, name, "results:", results);
|
|
|
for (const {element, type} of results) {
|
|
|
- getInfo(element.value, type.value, maxRecursion-1, newParent, name);
|
|
|
+ buildMenu(element.value, type.value, maxRecursion-1, createdMenuItem, name);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -317,7 +332,7 @@ fetch(BACKEND+"/version")
|
|
|
executeSPARQL(getCellStuff(cell.id))
|
|
|
.then(results => {
|
|
|
for (const {element, type} of results) {
|
|
|
- getInfo(element.value, type.value, 10, modelverseMenu, "Is a");
|
|
|
+ buildMenu(element.value, type.value, 10, modelverseMenu, "Is a");
|
|
|
}
|
|
|
})
|
|
|
}
|