Skip to content

Commit

Permalink
Improve logging while matching QuantME tasks (#137)
Browse files Browse the repository at this point in the history
* Improve logging while matching QuantME tasks

* Add missing attributes

* only update view if transformation was successful

* remove qprov & camunda endpoint if they exist

* fix wineryEndpoint, add notification if completion request failed

---------

Co-authored-by: LaviniaStiliadou <[email protected]>
  • Loading branch information
wederbn and LaviniaStiliadou authored Jan 8, 2024
1 parent b4ba317 commit 45ddc7c
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
synchronousGetRequest,
synchronousPostRequest,
} from "../utilities/Utilities";
import config from "../framework-config/config";
import { getWineryEndpoint } from "../framework-config/config-manager";
import { getModeler } from "../../../editor/ModelerHandler";

/**
Expand Down Expand Up @@ -59,21 +59,26 @@ export function getServiceTasksToDeploy(startElement) {
onDemand = false;
}

csarsToDeploy.push({
serviceTaskIds: [flowElement.id],
url: flowElement.deploymentModelUrl,
type: getBindingType(flowElement),
csarName: getCSARName(flowElement),
incomplete: !isCompleteDeploymentModel(
flowElement.deploymentModelUrl
),
onDemand: onDemand,
});
const iscomplete = isCompleteDeploymentModel(
flowElement.deploymentModelUrl
);
if (iscomplete !== undefined) {
csarsToDeploy.push({
serviceTaskIds: [flowElement.id],
url: flowElement.deploymentModelUrl,
type: getBindingType(flowElement),
csarName: getCSARName(flowElement),
incomplete: !iscomplete,
onDemand: onDemand,
});
} else {
return { csarsToDeploy: [], status: "failed" };
}
}
}
}

return csarsToDeploy;
return { csarsToDeploy: csarsToDeploy, status: "successful" };
}

/**
Expand Down Expand Up @@ -104,22 +109,26 @@ export function isDeployableServiceTask(element) {
}

/**
* Get the CSAR name from the deployment model URL
* Checks if the deployment model of the CSAR is complete.
*
* @param deploymentModelUrl
* @return {*} the CSAR name
* @return true if deployment model is complete, otherwise false
*/
export function isCompleteDeploymentModel(deploymentModelUrl) {
let url = deploymentModelUrl.split("/?csar")[0];
url = url.split("/");
url.shift();
url = url.join("/");
const iscomplete = synchronousPostRequest(
config.wineryEndpoint + "/" + url + "/topologytemplate/iscomplete",
let iscomplete = synchronousPostRequest(
getWineryEndpoint() + "/" + url + "/topologytemplate/iscomplete",
"text/plain",
null
).responseText;
return iscomplete === "true";
);
if (iscomplete !== undefined) {
iscomplete = iscomplete.responseText;
return iscomplete === "true";
}
return undefined;
}

export function completeIncompleteDeploymentModel(
Expand All @@ -139,7 +148,7 @@ export function completeIncompleteDeploymentModel(
});
try {
return synchronousPostRequest(
config.wineryEndpoint + "/" + url + "/topologytemplate/completemodel",
getWineryEndpoint() + "/" + url + "/topologytemplate/completemodel",
"application/json",
body
).getResponseHeader("location");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,25 @@ export default class DeploymentPlugin extends PureComponent {
}

// get all ServiceTasks with associated deployment model
let csarsToDeploy = getServiceTasksToDeploy(
let result = getServiceTasksToDeploy(
getRootProcess(this.modeler.getDefinitions())
);

if (csarsToDeploy.length === 0) {
const csarsToDeploy = result.csarsToDeploy;
const status = result.status;
if (status === "failed") {
NotificationHandler.getInstance().displayNotification({
type: "info",
title: "Request for completion failed",
content:
"The workflow contains service tasks with associated deployment models but the completion request failed!",
duration: 20000,
});
} else if (csarsToDeploy.length === 0) {
NotificationHandler.getInstance().displayNotification({
type: "info",
title: "No ServiceTasks with associated deployment models",
title: "No service tasks with associated deployment models",
content:
"The workflow does not contain ServiceTasks with associated deployment models. No service deployment required!",
"The workflow does not contain service tasks with associated deployment models. No service deployment required!",
duration: 20000,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ export function synchronousGetRequest(url) {
}

export function synchronousPostRequest(url, type, body) {
const xhr = new XMLHttpRequest();
xhr.open("POST", url, false);
xhr.setRequestHeader("Content-Type", type);
xhr.send(body);
if (xhr.status.toString().startsWith("2")) {
return xhr;
} else {
throw new Error("Request failed: " + xhr.statusText);
try {
const xhr = new XMLHttpRequest();
xhr.open("POST", url, false);
xhr.setRequestHeader("Content-Type", type);
xhr.send(body);
if (xhr.status.toString().startsWith("2")) {
return xhr;
}
} catch (error) {
console.log("Request failed to url " + url);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ export default {
camundaEndpoint: camundaConfig.getCamundaEndpoint(),
}
);
let combinedResult = await updateQuantMEView(
quantumView.xml,
transformedXml.xml
);
modeler.views["view-before-rewriting"] = combinedResult.xml;
if (transformedXml.status === "transformed") {
let combinedResult = await updateQuantMEView(
quantumView.xml,
transformedXml.xml
);
modeler.views["view-before-rewriting"] = combinedResult.xml;
}
return transformedXml;
}}
/>
Expand Down
Loading

0 comments on commit 45ddc7c

Please sign in to comment.