|
@@ -1,11 +1,17 @@
|
|
|
+Draw.loadPlugin(function(ui) {
|
|
|
+
|
|
|
+const WEE = "http://localhost:8081";
|
|
|
+
|
|
|
const BACKEND = "http://localhost:5000";
|
|
|
const EXPECTED_BACKEND_VERSION = 3; // expected backend version
|
|
|
+
|
|
|
const SPARQL_SERVER = "http://localhost:3030"
|
|
|
const SPARQL_ENDPOINT = "/SystemDesignOntology2Layers/sparql"
|
|
|
|
|
|
const dropVocabularyPrefix = str => str.substring(41);
|
|
|
const dropDescriptionPrefix = str => str.substring(30);
|
|
|
const dropArtifactPrefix = str => str.substring(41);
|
|
|
+const addArtifactPrefix = str => "http://ua.be/sdo2l/description/artifacts/" + str;
|
|
|
|
|
|
const QUERIES = {
|
|
|
// Query that navigates the given link from the given source element, and returns the IRI and most-concrete-type of the target element.
|
|
@@ -83,10 +89,10 @@ const typeToLinkType = new Map([
|
|
|
description: (element, type) => `Is rendered as ${type}`,
|
|
|
},
|
|
|
// Outcommented, because it's not an interesting relation:
|
|
|
- // {
|
|
|
- // relation: "object_diagram#inModel",
|
|
|
- // description: (element, type) => `Is part of model ${type}`,
|
|
|
- // },
|
|
|
+ {
|
|
|
+ relation: "object_diagram#inModel",
|
|
|
+ description: (element, type) => `Is part of model ${type}`,
|
|
|
+ },
|
|
|
{
|
|
|
relation: "traceability_model#traceLinkTo",
|
|
|
description: (element, type) => `Trace-link (outgoing) ${element}`,
|
|
@@ -178,8 +184,6 @@ const defaultSettings = {
|
|
|
dialogHeight: 400,
|
|
|
};
|
|
|
|
|
|
-Draw.loadPlugin(function(ui) {
|
|
|
-
|
|
|
fetch(BACKEND+"/version")
|
|
|
.then(response => response.json())
|
|
|
.catch(() => 0) // parsing failed - probably backend doesn't even have a version
|
|
@@ -329,6 +333,7 @@ fetch(BACKEND+"/version")
|
|
|
// If the plugin was loaded while Fuseki was empty, superclasses will be empty as well.
|
|
|
// After a successful OML build, Fuseki won't be empty and we can load the superclass relations.
|
|
|
// A better way to handle this, would be to guarantee that even if the backend is empty (no models, and hence, no OML descriptions), the vocabularies are always built, and the resulting triples loaded into Fuseki.
|
|
|
+ // For now, however, the following is workable:
|
|
|
if (superclasses.size === 0) {
|
|
|
loadSuperclasses();
|
|
|
}
|
|
@@ -481,7 +486,7 @@ fetch(BACKEND+"/version")
|
|
|
document.body.removeChild(a);
|
|
|
};
|
|
|
}
|
|
|
- function createModelList(modelType, createUploadDiv, downloadButtonLabel, onDownloadClick) {
|
|
|
+ function createModelList(modelType, createUploadDiv, downloadButtonLabel, onDownloadClick, extraStuff) {
|
|
|
const containerDiv = document.createElement('div');
|
|
|
containerDiv.classList.add('geFormatSection')
|
|
|
containerDiv.style.padding = '12px 14px 8px 14px';
|
|
@@ -508,6 +513,8 @@ fetch(BACKEND+"/version")
|
|
|
loadButton.style.marginLeft = "12px";
|
|
|
div.appendChild(document.createTextNode(modelName));
|
|
|
div.appendChild(loadButton);
|
|
|
+ extraStuff(modelName)
|
|
|
+ .then(stuff => stuff.forEach(el => div.appendChild(el)));
|
|
|
return div;
|
|
|
}));
|
|
|
}
|
|
@@ -522,13 +529,49 @@ fetch(BACKEND+"/version")
|
|
|
refreshList();
|
|
|
|
|
|
containerDiv.appendChild(createUploadDiv(refreshList));
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- createModelList("drawio", createSavePageDiv, "Open", modelName => loadPage(modelName));
|
|
|
- createModelList("xopp", createUploadDiv("xopp", "application/x-xopp,.xopp"), "Download", createDownloadHandler("xopp"));
|
|
|
- createModelList("csv", createUploadDiv("csv", "text/csv,.csv"), "Download", createDownloadHandler("csv"));
|
|
|
- createModelList("file", createUploadDiv("file", ""), "Download", createDownloadHandler("file"));
|
|
|
+ const extraButtonsIfPM = modelName => {
|
|
|
+ if (modelName.endsWith(":pm")) {
|
|
|
+ const enactButton = mxUtils.button("Start New", ()=>{});
|
|
|
+ const pmModel = addArtifactPrefix(modelName.substr(0, modelName.length-3)+"_pm#model");
|
|
|
+ const urlEncoded = encodeURIComponent(pmModel);
|
|
|
+ return Promise.all([
|
|
|
+ fetch(WEE+"/traces/active/"+urlEncoded)
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(enactments => {
|
|
|
+ return enactments.map((enactment, i) => mxUtils.button(`Continue ${i}`, ()=>{}))
|
|
|
+ }),
|
|
|
+ fetch(WEE+"/traces/finished/"+urlEncoded)
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(enactments => {
|
|
|
+ return enactments.map((enactment, i) => mxUtils.button(`Finished ${i}`, ()=>{}))
|
|
|
+ }),
|
|
|
+ ])
|
|
|
+ .then(([ongoing, finished]) => {
|
|
|
+ const pmDiv = document.createElement('div');
|
|
|
+ pmDiv.style.marginLeft = '8px';
|
|
|
+ pmDiv.style.borderWidth = '1px';
|
|
|
+ pmDiv.style.borderStyle = 'solid';
|
|
|
+ pmDiv.appendChild(document.createTextNode("PM Enactment: "));
|
|
|
+ pmDiv.appendChild(enactButton);
|
|
|
+ if (ongoing.length > 0) {
|
|
|
+ ongoing.forEach(o => pmDiv.appendChild(o));
|
|
|
+ }
|
|
|
+ if (finished.length > 0) {
|
|
|
+ finished.forEach(f => pmDiv.appendChild(f));
|
|
|
+ }
|
|
|
+ return [pmDiv];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return Promise.resolve([]);
|
|
|
+ };
|
|
|
+ const noExtraButtons = () => Promise.resolve([]);
|
|
|
+
|
|
|
+ createModelList("drawio", createSavePageDiv, "Open", modelName => loadPage(modelName), extraButtonsIfPM);
|
|
|
+ createModelList("xopp", createUploadDiv("xopp", "application/x-xopp,.xopp"), "Download", createDownloadHandler("xopp"), noExtraButtons);
|
|
|
+ createModelList("csv", createUploadDiv("csv", "text/csv,.csv"), "Download", createDownloadHandler("csv"), noExtraButtons);
|
|
|
+ createModelList("file", createUploadDiv("file", ""), "Download", createDownloadHandler("file"), noExtraButtons);
|
|
|
|
|
|
// Load a model and add it as a new page to the editor
|
|
|
function loadPage(pageName) {
|