From 67ea27890ac7328510041183b107d5364d82a02a Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 12:30:13 +0200 Subject: [PATCH 01/74] Improve logs in pattern transformator --- .../pattern/replacement/PatternTransformator.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 010d0b15..1e11836b 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -40,7 +40,7 @@ export async function startPatternReplacementProcess(xml) { // get root element of the current diagram let definitions = modeler.getDefinitions(); let rootElement = getRootProcess(definitions); - console.log(rootElement); + console.log("Root element for pattern transformation: ", rootElement); if (typeof rootElement === "undefined") { console.log("Unable to retrieve root process element from definitions!"); return { @@ -50,29 +50,30 @@ export async function startPatternReplacementProcess(xml) { } // get all patterns from the process - let replacementConstructs = getPatterns(rootElement, elementRegistry); + let containedPatterns = getPatterns(rootElement, elementRegistry); console.log( "Process contains " + - replacementConstructs.length + + containedPatterns.length + " patterns to replace..." ); - if (!replacementConstructs || !replacementConstructs.length) { + if (!containedPatterns || !containedPatterns.length) { + console.log("No patterns to replace, terminating transformation..."); return { status: "transformed", xml: xml }; } - console.log(replacementConstructs); + console.log("Patterns to replace: ", containedPatterns); attachPatternsToSuitableTasks( rootElement, elementRegistry, - replacementConstructs, + containedPatterns, modeling ); - replacementConstructs = getPatterns(rootElement, elementRegistry); + containedPatterns = getPatterns(rootElement, elementRegistry); // Mitigation have to be handled first since cutting inserts tasks after them // if the general pattern is attached then we add it to the elements to delete - for (let replacementConstruct of replacementConstructs) { + for (let replacementConstruct of containedPatterns) { if (replacementConstruct.task.$type === constants.PATTERN) { const pattern = elementRegistry.get(replacementConstruct.task.id); patterns.push(pattern); From 598e41de790fa6b5386bbfff3136418f83a9c214 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 12:33:16 +0200 Subject: [PATCH 02/74] Remove unused code --- .../extensions/pattern/replacement/PatternTransformator.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 1e11836b..21901bf7 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -466,11 +466,6 @@ export function attachPatternsToSuitableTasks( patterns, modeling ) { - let flowElements = process.flowElements; - if (!flowElements) { - flowElements = process.children; - } - let pattern; for (let j = 0; j < patterns.length; j++) { pattern = elementRegistry.get(patterns[j].task.id); From d54bf7f7af561794586c735a9743b44efc364197 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 12:34:05 +0200 Subject: [PATCH 03/74] Inline pattern declaration --- .../extensions/pattern/replacement/PatternTransformator.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 21901bf7..27847cfa 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -466,9 +466,8 @@ export function attachPatternsToSuitableTasks( patterns, modeling ) { - let pattern; for (let j = 0; j < patterns.length; j++) { - pattern = elementRegistry.get(patterns[j].task.id); + let pattern = elementRegistry.get(patterns[j].task.id); if (pattern !== undefined) { console.log("Start with attachment of pattern ", pattern.id); From 137ae8d3a3f931ca1be50878a8893cba252c77d7 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 12:53:55 +0200 Subject: [PATCH 04/74] Add missing variable declaration --- .../extensions/pattern/replacement/PatternTransformator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 27847cfa..ab429594 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -133,7 +133,7 @@ export async function startPatternReplacementProcess(xml) { } } - replacementConstructs = replacementConstructs.filter( + let replacementConstructs = replacementConstructs.filter( (construct) => construct.task.$type !== constants.READOUT_ERROR_MITIGATION && construct.task.$type !== constants.GATE_ERROR_MITIGATION && From ee976fc45c27a03dfbe5984248f7ea41984cca16 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:03:18 +0200 Subject: [PATCH 05/74] Move pattern removal to utils --- .../replacement/PatternTransformator.js | 19 ++++++-------- .../extensions/pattern/util/PatternUtil.js | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index ab429594..4b8d4517 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -18,7 +18,11 @@ import { replaceCuttingPattern } from "./cutting/CuttingPatternHandler"; import { replaceErrorCorrectionPattern } from "./correction/ErrorCorrectionPatternHandler"; import { replaceMitigationPattern } from "./mitigation/MitigationPatternHandler"; import * as quantmeConsts from "../../quantme/Constants"; -import { attachPatternsToSuitableConstruct } from "../util/PatternUtil"; +import { + attachPatternsToSuitableConstruct, + removeAlgorithmAndAugmentationPatterns, + removeBehavioralPatterns +} from "../util/PatternUtil"; import { findOptimizationCandidates } from "../../quantme/ui/adaptation/CandidateDetector"; import { getQRMs } from "../../quantme/qrm-manager"; import { rewriteWorkflow } from "../../quantme/ui/adaptation/WorkflowRewriter"; @@ -483,7 +487,7 @@ export function attachPatternsToSuitableTasks( (child.$type && child.$type === "bpmn:SubProcess") || (child.type && child.type === "bpmn:SubProcess") ) { - // Recursively retrieve the subprocess's flowElements + // Recursively retrieve the subprocesses flowElements let subProcessFlowElements = retrieveFlowElements( child.flowElements, elementRegistry @@ -505,13 +509,6 @@ export function attachPatternsToSuitableTasks( } } - for (let i = 0; i < patterns.length; i++) { - let hostFlowElements = patterns[i].attachedToRef.flowElements; - if (hostFlowElements !== undefined) { - // behavioral patterns are deleted after acting on the optimization candidate - if (!constants.BEHAVIORAL_PATTERNS.includes(patterns[i].task.$type)) { - modeling.removeShape(elementRegistry.get(patterns[i].task.id)); - } - } - } + // remove all contained algorithm and augmentation patterns after applying them to the workflow + removeAlgorithmAndAugmentationPatterns(patterns, modeling, elementRegistry); } diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index a83d2e76..c7f3d23a 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -11,6 +11,7 @@ import * as consts from "../Constants"; import * as quantmeConsts from "../../quantme/Constants"; import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; +import * as constants from "../Constants"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); @@ -239,3 +240,27 @@ export function checkForbiddenPatternCombinations(construct, patternType) { } return false; } + +/** + * TODO + * + * @param patterns the set of pattern to work on + * @param modeling the modeling to remove shapes from the workflow + * @param elementRegistry the element registry to access elements of the workflow + */ +export function removeAlgorithmAndAugmentationPatterns(patterns, modeling, elementRegistry) { + for (let i = 0; i < patterns.length; i++) { + let hostFlowElements = patterns[i].attachedToRef.flowElements; + + // check if pattern is attached to a flow element of the workflow + if (hostFlowElements !== undefined) { + + // behavioral patterns are deleted after acting on the optimization candidate + if (!constants.BEHAVIORAL_PATTERNS.includes(patterns[i].task.$type)) { + modeling.removeShape(elementRegistry.get(patterns[i].task.id)); + } + } else{ + console.warn("Pattern not attached to flow element: ", patterns[i]); + } + } +} From 2d60ba14234fab41ae56fb58a1d475c15be547f8 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:07:36 +0200 Subject: [PATCH 06/74] Add docs --- .../extensions/pattern/replacement/PatternTransformator.js | 1 - .../modeler-component/extensions/pattern/util/PatternUtil.js | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 4b8d4517..0edfd95c 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -21,7 +21,6 @@ import * as quantmeConsts from "../../quantme/Constants"; import { attachPatternsToSuitableConstruct, removeAlgorithmAndAugmentationPatterns, - removeBehavioralPatterns } from "../util/PatternUtil"; import { findOptimizationCandidates } from "../../quantme/ui/adaptation/CandidateDetector"; import { getQRMs } from "../../quantme/qrm-manager"; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index c7f3d23a..bf05ca00 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -197,6 +197,7 @@ export function changeIdOfContainedElements( /** * Checks whether the attached patterns conflict with the pattern intended to be attached to the construct. + * * @param construct The construct to which the pattern is intended to be attached. * @param patternType The type of the pattern being considered. * @returns True if there is a conflict, false otherwise. @@ -242,7 +243,7 @@ export function checkForbiddenPatternCombinations(construct, patternType) { } /** - * TODO + * Remove augmentation and algorithm patterns if they are successfully replaced by a corresponding task * * @param patterns the set of pattern to work on * @param modeling the modeling to remove shapes from the workflow From 57bdfabca285f0d3aa7d71b35bc0b321a53ce9b1 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:18:19 +0200 Subject: [PATCH 07/74] Fix linting --- .../pattern/replacement/PatternTransformator.js | 4 +--- .../extensions/pattern/util/PatternUtil.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 0edfd95c..a16850c1 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -55,9 +55,7 @@ export async function startPatternReplacementProcess(xml) { // get all patterns from the process let containedPatterns = getPatterns(rootElement, elementRegistry); console.log( - "Process contains " + - containedPatterns.length + - " patterns to replace..." + "Process contains " + containedPatterns.length + " patterns to replace..." ); if (!containedPatterns || !containedPatterns.length) { console.log("No patterns to replace, terminating transformation..."); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index bf05ca00..c9a4da6e 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -151,7 +151,7 @@ function attachPatternToShape(shape, patternType, modeling) { modeling.updateProperties(pattern, { attachedToRef: shape.businessObject, }); - console.log(pattern); + console.log("Added new modeling construct for pattern: ", pattern); } export function changeIdOfContainedElements( @@ -243,24 +243,27 @@ export function checkForbiddenPatternCombinations(construct, patternType) { } /** - * Remove augmentation and algorithm patterns if they are successfully replaced by a corresponding task + * Remove augmentation and algorithm patterns if they are successfully attached to a corresponding task * * @param patterns the set of pattern to work on * @param modeling the modeling to remove shapes from the workflow * @param elementRegistry the element registry to access elements of the workflow */ -export function removeAlgorithmAndAugmentationPatterns(patterns, modeling, elementRegistry) { +export function removeAlgorithmAndAugmentationPatterns( + patterns, + modeling, + elementRegistry +) { for (let i = 0; i < patterns.length; i++) { let hostFlowElements = patterns[i].attachedToRef.flowElements; // check if pattern is attached to a flow element of the workflow if (hostFlowElements !== undefined) { - // behavioral patterns are deleted after acting on the optimization candidate if (!constants.BEHAVIORAL_PATTERNS.includes(patterns[i].task.$type)) { modeling.removeShape(elementRegistry.get(patterns[i].task.id)); } - } else{ + } else { console.warn("Pattern not attached to flow element: ", patterns[i]); } } From 66e24fa51a7c678853eff627149fe7cbddb0c2a7 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:23:14 +0200 Subject: [PATCH 08/74] Remove unused code --- .../editor/util/ModellingUtilities.js | 114 ------------------ .../replacement/PatternTransformator.js | 2 +- 2 files changed, 1 insertion(+), 115 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js b/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js index 8ac5ddca..6a30cde1 100644 --- a/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js @@ -6,120 +6,6 @@ import { } from "./camunda-utils/ExtensionElementsUtil"; import { is } from "bpmn-js/lib/util/ModelUtil"; -/** - * Returns all start events of the workflow defined by the process businessObject - * - * @param processBo The process businessObject containing the workflow - * @returns {*[]} All found start event elements of the workflow. - */ -export function getStartEvents(processBo) { - return processBo.flowElements.filter( - (element) => element.$type === "bpmn:StartEvent" - ); -} - -/** - * Adds a Camunda execution listener to the given element which creates the given process variable. - * - * @param element The element to add the execution listener to. - * @param moddle The moddle module of the current bpmn-js modeler. - * @param processVariable The process variable which should be created through the executionn listener - */ -export function addExecutionListener(element, moddle, processVariable) { - // create the execution listener for the process variable - const listener = { - event: "start", - expression: - '${execution.setVariable("' + - processVariable.name + - '", ' + - processVariable.value + - ")}", - }; - - const elementBo = element.businessObject; - let extensionElements = elementBo.extensionElements; - - // create new extension element if needed - if (!extensionElements) { - extensionElements = moddle.create("bpmn:ExtensionElements"); - } - - if (!extensionElements.values) { - extensionElements.values = []; - } - - // add execution listener to the extension element of the element - extensionElements.values.push( - moddle.create("camunda:ExecutionListener", listener) - ); - elementBo.extensionElements = extensionElements; -} - -/** - * Add the data of the given key value map as properties to a created Camunda form field. The form field is added to the given - * element. - * - * @param elementID The ID of the given element. - * @param name Name of the form field - * @param keyValueMap The key value map - * @param elementRegistry The elementRegistry of the bpmn-js modeler - * @param moddle The moddle module of the bpmn-js modeler - * @param modeling The modeling module of the bpmn-js modeler - */ -export function addFormFieldForMap( - elementID, - name, - keyValueMap, - elementRegistry, - moddle, - modeling -) { - // create the properties of the form field - let formFieldData = { - defaultValue: "", - id: name.replace(/\s+/g, "_"), - label: name, - type: "string", - }; - - // create the form field for the key value map - addFormFieldDataForMap( - elementID, - formFieldData, - keyValueMap, - elementRegistry, - moddle, - modeling - ); -} - -/** - * Add the data of the given key value map as properties to a created Camunda form field defined by the given form field - * data. The form field is added to the given element. - * - * @param elementID The ID of the given element. - * @param formFieldData The given form field data. - * @param keyValueMap The key value map - * @param elementRegistry The elementRegistry of the bpmn-js modeler - * @param moddle The moddle module of the bpmn-js modeler - * @param modeling The modeling module of the bpmn-js modeler - */ -export function addFormFieldDataForMap( - elementID, - formFieldData, - keyValueMap, - elementRegistry, - moddle, - modeling -) { - // create camunda properties for each entry of the key value map - formFieldData.properties = createCamundaProperties(keyValueMap, moddle); - - // create form field for form field data - addFormField(elementID, formFieldData, elementRegistry, moddle, modeling); -} - /** * Create a camunda form filed for the given form field data. * diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index a16850c1..df0c1b25 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -434,7 +434,7 @@ function retrieveFlowElements(flowElements, elementRegistry) { (element.type && element.type === "bpmn:SubProcess") ) { console.log("searchFlow", element.id); - // Recursively search through subprocess's children or flowElements + // Recursively search through subprocesses children or flowElements let childrenOrFlowElements = element.children; if (element.children === undefined) { childrenOrFlowElements = element.flowElements; From 34a73c50eceb4674962b93337cbe21abc6fa8b58 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:26:57 +0200 Subject: [PATCH 09/74] Add utility function to retrieve types in a generic manner --- .../editor/util/ModellingUtilities.js | 9 +++++++++ .../pattern/replacement/PatternTransformator.js | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js b/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js index 6a30cde1..87871915 100644 --- a/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js @@ -6,6 +6,15 @@ import { } from "./camunda-utils/ExtensionElementsUtil"; import { is } from "bpmn-js/lib/util/ModelUtil"; +/** + * Get the type of a given element + * + * @param element the element to retrieve the type for + */ +export function getType(element) { + return element.$type ? element.$type : element.type; +} + /** * Create a camunda form filed for the given form field data. * diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index df0c1b25..22622177 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -11,7 +11,10 @@ import { layout } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; import { createTempModelerFromXml } from "../../../editor/ModelerHandler"; -import { getRootProcess } from "../../../editor/util/ModellingUtilities"; +import { + getRootProcess, + getType, +} from "../../../editor/util/ModellingUtilities"; import { getXml } from "../../../editor/util/IoUtilities"; import { replaceWarmStart } from "./warm-start/WarmStartPatternHandler"; import { replaceCuttingPattern } from "./cutting/CuttingPatternHandler"; @@ -429,10 +432,7 @@ function retrieveFlowElements(flowElements, elementRegistry) { flowElements.forEach((flowElement) => { let element = elementRegistry.get(flowElement.id); - if ( - (element.$type && element.$type === "bpmn:SubProcess") || - (element.type && element.type === "bpmn:SubProcess") - ) { + if (getType(element) && getType(element) === "bpmn:SubProcess") { console.log("searchFlow", element.id); // Recursively search through subprocesses children or flowElements let childrenOrFlowElements = element.children; From 583aed00470ba77b272487d8370413a693c11dbe Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:34:06 +0200 Subject: [PATCH 10/74] Add utility method to check for QuantME subprocesses --- .../replacement/PatternTransformator.js | 12 +++--------- .../PatternSelectionPlugin.js | 18 ++---------------- .../extensions/quantme/utilities/Utilities.js | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 22622177..beff5b84 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -20,7 +20,6 @@ import { replaceWarmStart } from "./warm-start/WarmStartPatternHandler"; import { replaceCuttingPattern } from "./cutting/CuttingPatternHandler"; import { replaceErrorCorrectionPattern } from "./correction/ErrorCorrectionPatternHandler"; import { replaceMitigationPattern } from "./mitigation/MitigationPatternHandler"; -import * as quantmeConsts from "../../quantme/Constants"; import { attachPatternsToSuitableConstruct, removeAlgorithmAndAugmentationPatterns, @@ -30,6 +29,7 @@ import { getQRMs } from "../../quantme/qrm-manager"; import { rewriteWorkflow } from "../../quantme/ui/adaptation/WorkflowRewriter"; import { getQiskitRuntimeProgramDeploymentModel } from "../../quantme/ui/adaptation/runtimes/QiskitRuntimeHandler"; import { getHybridRuntimeProvenance } from "../../quantme/framework-config/config-manager"; +import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; /** * Initiate the replacement process for the patterns that are contained in the current process model @@ -137,7 +137,7 @@ export async function startPatternReplacementProcess(xml) { } } - let replacementConstructs = replacementConstructs.filter( + let replacementConstructs = containedPatterns.filter( (construct) => construct.task.$type !== constants.READOUT_ERROR_MITIGATION && construct.task.$type !== constants.GATE_ERROR_MITIGATION && @@ -411,13 +411,7 @@ export function getPatterns(process, elementRegistry) { } // recursively retrieve patterns if subprocess is found - if ( - flowElement.$type && - (flowElement.$type === "bpmn:SubProcess" || - flowElement.$type === quantmeConsts.CIRCUIT_CUTTING_SUBPROCESS || - flowElement.$type === - quantmeConsts.QUANTUM_HARDWARE_SELECTION_SUBPROCESS) - ) { + if (flowElement.$type && isQuantMESubprocess(flowElement)) { Array.prototype.push.apply( patterns, getPatterns(flowElement, elementRegistry) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js index 4fbf42a6..29a995fe 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js @@ -32,12 +32,12 @@ import { } from "../../util/PatternUtil"; import { getBusinessObject } from "bpmn-js/lib/util/ModelUtil"; import { getExtension } from "../../../../editor/util/camunda-utils/ExtensionElementsUtil"; -import * as quantmeConsts from "../../../quantme/Constants"; import { getPatternAtlasEndpoint, getQcAtlasEndpoint, } from "../../framework-config/config-manager"; import NotificationHandler from "../../../../editor/ui/notifications/NotificationHandler"; +import { isQuantMESubprocess } from "../../../quantme/utilities/Utilities"; const defaultState = { patternOverviewOpen: false, @@ -322,21 +322,7 @@ export default class PatternSelectionPlugin extends PureComponent { modeling.connect(start, shape, { type: "bpmn:SequenceFlow" }); solutionModeling.removeElements(outgoingFlows); } - } else if ( - type !== quantmeConsts.CIRCUIT_CUTTING_SUBPROCESS && - type !== quantmeConsts.QUANTUM_HARDWARE_SELECTION_SUBPROCESS && - type !== "bpmn:SubProcess" - ) { - /** - updateShape = modeling.createShape( - s, - { x: 50 + offset, y: 50 }, - elementRegistry.get(collapsedSubprocess.id) - ); - modeling.updateProperties(elementRegistry.get(updateShape.id), { - id: collapsedSubprocess.id + "_" + updateShape.id, - }); - */ + } else if (!isQuantMESubprocess(flowElement)) { updateShape = modeling.createShape( flowElement, { x: 442 + offset, y: 100 }, diff --git a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js index dedd53e0..4ead41ee 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js @@ -10,6 +10,7 @@ */ import $ from "jquery"; +import * as quantmeConsts from "../Constants"; /** * Check if the given task is a QuantME task @@ -52,3 +53,16 @@ export function performAjax(targetUrl, dataToSend) { }); }); } + +/** + * Checks if the given element is a subprocess or not + * + * @param element the element to check + */ +export function isQuantMESubprocess(element) { + return ( + element.$type === "bpmn:SubProcess" || + element.$type === quantmeConsts.CIRCUIT_CUTTING_SUBPROCESS || + element.$type === quantmeConsts.QUANTUM_HARDWARE_SELECTION_SUBPROCESS + ); +} From cd4b74b4704ba1f63b6140a84959a21f87be714e Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:36:14 +0200 Subject: [PATCH 11/74] Remove redundant code --- .../extensions/pattern/util/PatternUtil.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index c9a4da6e..e4d44974 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -12,6 +12,7 @@ import * as consts from "../Constants"; import * as quantmeConsts from "../../quantme/Constants"; import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; +import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); @@ -179,11 +180,7 @@ export function changeIdOfContainedElements( }); child.di.id = id + "_" + child.id + "_di"; - if ( - child.$type === "bpmn:SubProcess" || - child.$type === quantmeConsts.QUANTUM_HARDWARE_SELECTION_SUBPROCESS || - child.$type === quantmeConsts.CIRCUIT_CUTTING_SUBPROCESS - ) { + if (isQuantMESubprocess(child)) { changeIdOfContainedElements( child, child.parent, From 728ee150a9225d9437aa4e7c995ecdb6a773633a Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:38:03 +0200 Subject: [PATCH 12/74] Improve logging --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index e4d44974..c6f0ab5d 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -200,9 +200,7 @@ export function changeIdOfContainedElements( * @returns True if there is a conflict, false otherwise. */ export function checkForbiddenPatternCombinations(construct, patternType) { - console.log("attach patternType to construct", patternType, construct.id); - console.log(construct); - console.log(construct.attachers); + console.log("Checking if patternType " + patternType + " can be attached to construct: ", construct); if (construct.attachers !== undefined) { if (patternType === consts.ERROR_CORRECTION) { const forbiddenPatterns = construct.attachers.filter( From 1a0aa848e48000917ec4aa3769061c813907c690 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:42:29 +0200 Subject: [PATCH 13/74] Simplify check for forbidden patterns --- .../extensions/pattern/util/PatternUtil.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index c6f0ab5d..c1a5d43c 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -200,41 +200,46 @@ export function changeIdOfContainedElements( * @returns True if there is a conflict, false otherwise. */ export function checkForbiddenPatternCombinations(construct, patternType) { - console.log("Checking if patternType " + patternType + " can be attached to construct: ", construct); + console.log( + "Checking if patternType " + + patternType + + " can be attached to construct: ", + construct + ); + + // set of patterns that are unsuitable for combination with given pattern + let forbiddenPatterns = []; + if (construct.attachers !== undefined) { if (patternType === consts.ERROR_CORRECTION) { - const forbiddenPatterns = construct.attachers.filter( + forbiddenPatterns = construct.attachers.filter( (pattern) => pattern.type === consts.GATE_ERROR_MITIGATION || pattern.type === consts.READOUT_ERROR_MITIGATION ); - return forbiddenPatterns.length > 0; } if ( patternType === consts.GATE_ERROR_MITIGATION || patternType === consts.READOUT_ERROR_MITIGATION ) { - const forbiddenPatterns = construct.attachers.filter( + forbiddenPatterns = construct.attachers.filter( (pattern) => pattern.type === consts.ERROR_CORRECTION ); - return forbiddenPatterns.length > 0; } if (patternType === consts.ORCHESTRATED_EXECUTION) { - const forbiddenPatterns = construct.attachers.filter( + forbiddenPatterns = construct.attachers.filter( (pattern) => pattern.type === consts.PRE_DEPLOYED_EXECUTION ); - return forbiddenPatterns.length > 0; } if (patternType === consts.PRE_DEPLOYED_EXECUTION) { - const forbiddenPatterns = construct.attachers.filter( + forbiddenPatterns = construct.attachers.filter( (pattern) => pattern.type === consts.ORCHESTRATED_EXECUTION ); - console.log(forbiddenPatterns.length > 0); - console.log("predeployed attached or not"); - return forbiddenPatterns.length > 0; } } - return false; + + console.log("Set of forbidden patterns: ", forbiddenPatterns); + return forbiddenPatterns.length > 0; } /** From 96220b1289dbb0b3ab0c5cea72f3249aeecf8949 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:47:18 +0200 Subject: [PATCH 14/74] Add constant for pattern prefix --- .../extensions/pattern/Constants.js | 2 ++ .../pattern/replacement/PatternTransformator.js | 3 ++- .../warm-start/WarmStartPatternHandler.js | 3 ++- .../extensions/pattern/util/PatternUtil.js | 15 ++++----------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/Constants.js b/components/bpmn-q/modeler-component/extensions/pattern/Constants.js index cf26a7e9..37bde029 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/Constants.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/Constants.js @@ -15,6 +15,8 @@ export const PATTERN_AUGMENTATION = "augmentation"; export const PATTERN = "pattern:Pattern"; +export const PATTERN_PREFIX = "pattern:"; + export const QUANTUM_KERNEL_ESTIMATOR = "pattern:QuantumKernelEstimator"; export const ALTERNATING_OPERATOR_ANSATZ = "pattern:AlternatingOperatorAnsatz"; export const QUANTUM_APPROXIMATE_OPTIMIZATION_ALGORITHM = diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index beff5b84..45c92f8c 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -30,6 +30,7 @@ import { rewriteWorkflow } from "../../quantme/ui/adaptation/WorkflowRewriter"; import { getQiskitRuntimeProgramDeploymentModel } from "../../quantme/ui/adaptation/runtimes/QiskitRuntimeHandler"; import { getHybridRuntimeProvenance } from "../../quantme/framework-config/config-manager"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; +import { PATTERN_PREFIX } from "../Constants"; /** * Initiate the replacement process for the patterns that are contained in the current process model @@ -402,7 +403,7 @@ export function getPatterns(process, elementRegistry) { for (let i = 0; i < flowElements.length; i++) { let flowElement = flowElements[i]; console.log(flowElement); - if (flowElement.$type && flowElement.$type.startsWith("pattern:")) { + if (flowElement.$type && flowElement.$type.startsWith(PATTERN_PREFIX)) { patterns.push({ task: flowElement, parent: processBo, diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js index e39f935e..4129a52e 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js @@ -9,6 +9,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; +import { PATTERN_PREFIX } from "../../Constants"; /** * Replace the given warm start pattern by a quantme warm starting task */ @@ -34,7 +35,7 @@ export async function replaceWarmStart(warmStartPattern, parent, modeler) { warmStartTaskBo.name = "Warm Start"; // remove the prefix - let warmStartPatternName = warmStartPattern.$type.replace("pattern:", ""); + let warmStartPatternName = warmStartPattern.$type.replace(PATTERN_PREFIX, ""); // first letter to lowerCase warmStartPatternName = diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index c1a5d43c..305d11c9 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -13,10 +13,10 @@ import * as quantmeConsts from "../../quantme/Constants"; import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; +import * as Constants from "constants"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); - const patternPrefix = "pattern:"; const patternSpacing = 65; const createPatterns = (patternList, offsetX) => { for (let i = 0; i < patternList.length; i++) { @@ -25,14 +25,7 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let patternX = subprocess.x + patternSpacing * (i + offsetX); let patternY = subprocess.y + dimensions.height; - createPattern( - modeling, - patternPrefix, - patternName, - patternX, - patternY, - subprocess - ); + createPattern(modeling, patternName, patternX, patternY, subprocess); } }; @@ -43,9 +36,9 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { ); } -function createPattern(modeling, patternPrefix, patternName, x, y, subprocess) { +function createPattern(modeling, patternName, x, y, subprocess) { const pattern = modeling.createShape( - { type: patternPrefix + patternName }, + { type: Constants.PATTERN_PREFIX + patternName }, { x: x, y: y }, subprocess, { attach: true } From d1a2df2464289239c606248386e027d416a07b29 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 13:48:00 +0200 Subject: [PATCH 15/74] Switch to direct import --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 305d11c9..648aec82 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -13,7 +13,7 @@ import * as quantmeConsts from "../../quantme/Constants"; import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; -import * as Constants from "constants"; +import { PATTERN_PREFIX } from "../Constants"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); @@ -38,7 +38,7 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { function createPattern(modeling, patternName, x, y, subprocess) { const pattern = modeling.createShape( - { type: Constants.PATTERN_PREFIX + patternName }, + { type: PATTERN_PREFIX + patternName }, { x: x, y: y }, subprocess, { attach: true } From d57eecd03d8c07b594a5f6d49e044b5de2010109 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 14:09:25 +0200 Subject: [PATCH 16/74] Fix headings --- .../replacement/correction/ErrorCorrectionPatternHandler.js | 1 + .../pattern/replacement/cutting/CuttingPatternHandler.js | 1 + .../pattern/replacement/mitigation/MitigationPatternHandler.js | 1 + .../pattern/replacement/warm-start/WarmStartPatternHandler.js | 1 + 4 files changed, 4 insertions(+) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js index 93aefd9b..80ee96cf 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js @@ -9,6 +9,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; + /** * Replace the given error correction pattern by a quantme error correction task */ diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js index 995c6221..68140c8f 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js @@ -9,6 +9,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; + /** * Replace the cutting pattern by quantme modeling constructs */ diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js index 84ffe368..e0dcbad9 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js @@ -10,6 +10,7 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import * as consts from "../../Constants"; + /** * Replace the given mitigation by a quantme modeling construct */ diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js index 4129a52e..4e6b5d7f 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js @@ -10,6 +10,7 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import { PATTERN_PREFIX } from "../../Constants"; + /** * Replace the given warm start pattern by a quantme warm starting task */ From 65c31a9fcf21cdb0196cb9d6efa75ffb74e95cbc Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 14:35:48 +0200 Subject: [PATCH 17/74] Add PatternId to pattern modeling constructs --- .../replacement/PatternTransformator.js | 7 +++ .../pattern/resources/pattern4bpmn.json | 44 +++++++++++-------- .../extensions/pattern/util/PatternUtil.js | 12 +++++ 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 45c92f8c..b9d84a58 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -22,6 +22,7 @@ import { replaceErrorCorrectionPattern } from "./correction/ErrorCorrectionPatte import { replaceMitigationPattern } from "./mitigation/MitigationPatternHandler"; import { attachPatternsToSuitableConstruct, + getSolutionForPattern, removeAlgorithmAndAugmentationPatterns, } from "../util/PatternUtil"; import { findOptimizationCandidates } from "../../quantme/ui/adaptation/CandidateDetector"; @@ -156,6 +157,12 @@ export async function startPatternReplacementProcess(xml) { ); for (let replacementConstruct of augmentationReplacementConstructs) { + console.log("Replacing augmentation pattern: ", replacementConstruct); + + // retrieve solution for pattern to enable correct configuration + let concreteSolution = getSolutionForPattern(replacementConstruct.id); + console.log("Solution: ", concreteSolution); + let replacementSuccess = false; if (replacementConstruct.task.$type === constants.CIRCUIT_CUTTING) { let { replaced, flows, pattern } = await replaceCuttingPattern( diff --git a/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json b/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json index 5528735c..aa1251c4 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json +++ b/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json @@ -8,98 +8,104 @@ "types": [ { "name": "QuantumKernelEstimator", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "AlternatingOperatorAnsatz", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "QuantumApproximateOptimizationAlgorithm", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "QuantumPhaseEstimation", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "VariationalQuantumAlgorithm", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "VariationalQuantumEigensolver", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "OrchestratedExecution", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "PredeployedExecution", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "PrioritizedExecution", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "ErrorCorrection", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "GateErrorMitigation", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "ReadoutErrorMitigation", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "WarmStart", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "BiasedInitialState", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "ChainedOptimization", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "VariationalParameterTransfer", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "PreTrainedFeatureExtractor", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "CircuitCutting", - "superClass": ["bpmn:BoundaryEvent"], + "superClass": ["pattern:Pattern"], "properties": [] }, { "name": "Pattern", "superClass": ["bpmn:BoundaryEvent"], - "properties": [] + "properties": [ + { + "name": "PatternId", + "isAttr": true, + "type": "String" + } + ] } ], "enumerations": [], diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 648aec82..cbe92d21 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -261,3 +261,15 @@ export function removeAlgorithmAndAugmentationPatterns( } } } + +/** + * Get the solution for the given pattern + * + * @param id the ID of the solution to retrieve the pattern for + */ +export function getSolutionForPattern(id) { + console.log("Retrieving solution for pattern with ID: ", id); + + // TODO + return undefined; +} From b415439450275e45c91f365aaa2ab6a6a51af590 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 15:00:48 +0200 Subject: [PATCH 18/74] Incorporate pattern ID when adding pattern modeling constructs for selected patterns --- .../extensions/pattern/Constants.js | 2 ++ .../pattern/resources/pattern4bpmn.json | 2 +- .../pattern-selection/PatternSelectionPlugin.js | 17 ----------------- .../extensions/pattern/util/PatternUtil.js | 17 +++++++++++++---- .../quantme/replacement/layouter/Layouter.js | 10 ++-------- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/Constants.js b/components/bpmn-q/modeler-component/extensions/pattern/Constants.js index 37bde029..c58fc030 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/Constants.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/Constants.js @@ -17,6 +17,8 @@ export const PATTERN = "pattern:Pattern"; export const PATTERN_PREFIX = "pattern:"; +export const PATTERN_ID = "patternId"; + export const QUANTUM_KERNEL_ESTIMATOR = "pattern:QuantumKernelEstimator"; export const ALTERNATING_OPERATOR_ANSATZ = "pattern:AlternatingOperatorAnsatz"; export const QUANTUM_APPROXIMATE_OPTIMIZATION_ALGORITHM = diff --git a/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json b/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json index aa1251c4..3b79cf65 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json +++ b/components/bpmn-q/modeler-component/extensions/pattern/resources/pattern4bpmn.json @@ -101,7 +101,7 @@ "superClass": ["bpmn:BoundaryEvent"], "properties": [ { - "name": "PatternId", + "name": "patternId", "isAttr": true, "type": "String" } diff --git a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js index 29a995fe..7abfaf88 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/PatternSelectionPlugin.js @@ -204,27 +204,10 @@ export default class PatternSelectionPlugin extends PureComponent { }); // Combine the sorted filtered elements with the remaining elements - /** - const sortedSolutionFlowElements = nonFilteredElements.concat( - solutionFlowElements.filter((element) => { - const elementType = solutionElementRegistry.get(element.id).$type; - const elementCustomType = solutionElementRegistry.get( - element.id - ).type; - - return ( - elementType === "bpmn:SequenceFlow" || - elementCustomType === "bpmn:SequenceFlow" - ); - }) - ); - - */ const sortedSolutionFlowElements = nonFilteredElements; const solutionFlowElementsLength = nonFilteredElements.length; let offset = 0; console.log(sortedSolutionFlowElements); - console.log(sortedSolutionFlowElements); for (let j = 0; j < solutionFlowElementsLength; j++) { let flowElement = solutionElementRegistry.get( diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index cbe92d21..d25f77a0 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -13,7 +13,7 @@ import * as quantmeConsts from "../../quantme/Constants"; import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; -import { PATTERN_PREFIX } from "../Constants"; +import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); @@ -21,11 +21,18 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { const createPatterns = (patternList, offsetX) => { for (let i = 0; i < patternList.length; i++) { const patternName = patternList[i].name.replace(/[\s-]/g, ""); - console.log("add pattern", patternName); + console.log("Adding pattern: ", patternList[i]); let patternX = subprocess.x + patternSpacing * (i + offsetX); let patternY = subprocess.y + dimensions.height; - createPattern(modeling, patternName, patternX, patternY, subprocess); + createPattern( + modeling, + patternName, + patternList[i].id, + patternX, + patternY, + subprocess + ); } }; @@ -36,7 +43,7 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { ); } -function createPattern(modeling, patternName, x, y, subprocess) { +function createPattern(modeling, patternName, patternId, x, y, subprocess) { const pattern = modeling.createShape( { type: PATTERN_PREFIX + patternName }, { x: x, y: y }, @@ -46,7 +53,9 @@ function createPattern(modeling, patternName, x, y, subprocess) { modeling.updateProperties(pattern, { attachedToRef: subprocess.businessObject, + [PATTERN_ID]: patternId, }); + console.log("Added new pattern: ", pattern); } export function attachPatternsToSuitableConstruct( construct, diff --git a/components/bpmn-q/modeler-component/extensions/quantme/replacement/layouter/Layouter.js b/components/bpmn-q/modeler-component/extensions/quantme/replacement/layouter/Layouter.js index 3e61bff1..d72d472f 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/replacement/layouter/Layouter.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/replacement/layouter/Layouter.js @@ -17,6 +17,7 @@ import { CIRCUIT_CUTTING_SUBPROCESS, QUANTUM_HARDWARE_SELECTION_SUBPROCESS, } from "../../Constants"; +import { isQuantMESubprocess } from "../../utilities/Utilities"; // space between multiple boundary events of a task/subprocess let BOUNDARY_EVENT_MARGIN = "8"; @@ -447,7 +448,6 @@ function layoutWithDagre( console.log("Adding %i tasks to the graph for layouting: ", tasks.length); for (let i = 0; i < tasks.length; i++) { let task = tasks[i]; - console.log(task.type); if ( task.type === "bpmn:SubProcess" || task.type === CIRCUIT_CUTTING_SUBPROCESS || @@ -510,12 +510,7 @@ function layoutWithDagre( }); for (let i = 0; i < tasks.length; i++) { let task = tasks[i]; - console.log(task.type); - if ( - task.type === "bpmn:SubProcess" || - task.type === CIRCUIT_CUTTING_SUBPROCESS || - task.type === QUANTUM_HARDWARE_SELECTION_SUBPROCESS - ) { + if (isQuantMESubprocess(task)) { changeAttachersCoordinates(task); } } @@ -535,7 +530,6 @@ export function computeDimensionsOfSubprocess(subprocess) { console.log(subprocess); subprocess.children.forEach((child) => { - console.log("Get coordinates of child ", child.id); if (child.di && child.di.bounds) { const childX = child.di.bounds.x; const childY = child.di.bounds.y; From fbcc9710f77689927c92b51afdcca9a93fb2289d Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 15:40:21 +0200 Subject: [PATCH 19/74] Forward pattern ID during transformation --- .../replacement/PatternTransformator.js | 8 +- .../extensions/pattern/util/PatternUtil.js | 89 ++++++++++++------- 2 files changed, 65 insertions(+), 32 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index b9d84a58..d85dee82 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -160,9 +160,13 @@ export async function startPatternReplacementProcess(xml) { console.log("Replacing augmentation pattern: ", replacementConstruct); // retrieve solution for pattern to enable correct configuration - let concreteSolution = getSolutionForPattern(replacementConstruct.id); + let concreteSolution = getSolutionForPattern( + replacementConstruct.task.patternId + ); console.log("Solution: ", concreteSolution); + // TODO: load detector from solution and configure inserted task + let replacementSuccess = false; if (replacementConstruct.task.$type === constants.CIRCUIT_CUTTING) { let { replaced, flows, pattern } = await replaceCuttingPattern( @@ -500,7 +504,7 @@ export function attachPatternsToSuitableTasks( children.values().forEach((id) => { attachPatternsToSuitableConstruct( elementRegistry.get(id), - pattern.type, + pattern, modeling ); }); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index d25f77a0..31d95819 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -14,6 +14,7 @@ import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layoute import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; + export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); console.log(subprocess); @@ -27,7 +28,7 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let patternY = subprocess.y + dimensions.height; createPattern( modeling, - patternName, + PATTERN_PREFIX + patternName, patternList[i].id, patternX, patternY, @@ -43,27 +44,29 @@ export function attachPatternsToSubprocess(subprocess, patterns, modeling) { ); } -function createPattern(modeling, patternName, patternId, x, y, subprocess) { +function createPattern(modeling, patternName, patternId, x, y, parent) { + console.log("Adding pattern with name: ", patternName); const pattern = modeling.createShape( - { type: PATTERN_PREFIX + patternName }, + { type: patternName }, { x: x, y: y }, - subprocess, + parent, { attach: true } ); modeling.updateProperties(pattern, { - attachedToRef: subprocess.businessObject, + attachedToRef: parent.businessObject, [PATTERN_ID]: patternId, }); console.log("Added new pattern: ", pattern); } export function attachPatternsToSuitableConstruct( construct, - patternType, + pattern, modeling ) { - console.log("attach pattern to suitable modeling construct"); - console.log(construct); + console.log("Attaching pattern to suitable modeling construct: ", construct); + console.log("Pattern to attach: ", pattern); + let patternType = pattern.type; if (construct !== undefined) { let type = construct.$type; if (type === undefined) { @@ -93,14 +96,28 @@ export function attachPatternsToSuitableConstruct( patternType === consts.BIASED_INITIAL_STATE && type === quantmeConsts.QUANTUM_CIRCUIT_LOADING_TASK ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("added biased initial state"); } if ( patternType === consts.VARIATIONAL_PARAMETER_TRANSFER && type === quantmeConsts.QUANTUM_CIRCUIT_EXECUTION_TASK ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("added variational parameter transfer"); } if ( @@ -108,7 +125,14 @@ export function attachPatternsToSuitableConstruct( (type === quantmeConsts.QUANTUM_CIRCUIT_EXECUTION_TASK || type === quantmeConsts.QUANTUM_CIRCUIT_LOADING_TASK) ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("added error correction", construct.id); } if ( @@ -116,7 +140,14 @@ export function attachPatternsToSuitableConstruct( patternType === consts.READOUT_ERROR_MITIGATION) && type === quantmeConsts.QUANTUM_CIRCUIT_EXECUTION_TASK ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("added mitigation", construct.id); } @@ -124,7 +155,14 @@ export function attachPatternsToSuitableConstruct( patternType === consts.CIRCUIT_CUTTING && type === quantmeConsts.QUANTUM_CIRCUIT_EXECUTION_TASK ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("added cutting"); } @@ -132,11 +170,15 @@ export function attachPatternsToSuitableConstruct( consts.BEHAVIORAL_PATTERNS.includes(patternType) && type === "bpmn:SubProcess" ) { - attachPatternToShape(construct, patternType, modeling); + createPattern( + modeling, + patternType, + pattern.businessObject.patternId, + construct.x + construct.width, + construct.y + construct.height, + construct + ); console.log("attached behavioral pattern"); - console.log(patternType); - console.log(construct); - console.log("added behavioral pattern"); } } } @@ -144,19 +186,6 @@ export function attachPatternsToSuitableConstruct( } } -function attachPatternToShape(shape, patternType, modeling) { - let pattern = modeling.createShape( - { type: patternType }, - { x: shape.x + shape.width, y: shape.y + shape.height }, - shape, - { attach: true } - ); - modeling.updateProperties(pattern, { - attachedToRef: shape.businessObject, - }); - console.log("Added new modeling construct for pattern: ", pattern); -} - export function changeIdOfContainedElements( subprocess, parent, From 882a5b8e9d4bfbc300944893d08a9bfbfe0f7717 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 15:47:35 +0200 Subject: [PATCH 20/74] Remove faulty logging --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 5 +++++ .../extensions/quantme/ui/adaptation/CandidateDetector.js | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 31d95819..644d0096 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -14,6 +14,7 @@ import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layoute import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; +import { getQcAtlasEndpoint } from "../framework-config/config-manager"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); @@ -308,6 +309,10 @@ export function removeAlgorithmAndAugmentationPatterns( export function getSolutionForPattern(id) { console.log("Retrieving solution for pattern with ID: ", id); + const qcAtlasEndpoint = getQcAtlasEndpoint(); + let endpoint = qcAtlasEndpoint + "/TODO/" + id; + console.log("Retrieving solutions from URL: ", endpoint); + // TODO return undefined; } diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js index 841d75da..abe1eb83 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js @@ -101,7 +101,6 @@ async function visualizeCandidate(optimizationCandidate, workflowXml, modeler) { let tempModeler = await createTempModelerFromXml(workflowXml); let modeling = tempModeler.get("modeling"); let tempElementRegistry = tempModeler.get("elementRegistry"); - console.log(elementRegistry); let rootElement = getRootProcess(tempModeler.getDefinitions()); let elementRegistry = modeler.get("elementRegistry"); From d902210a21785edc7e12ab20a277bbf8ddef5286 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 17:34:06 +0200 Subject: [PATCH 21/74] Retrieve pattern ID by type --- .../replacement/PatternTransformator.js | 15 +++++-- .../extensions/pattern/util/PatternUtil.js | 44 ++++++++++++++++++- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index d85dee82..80f0ded7 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -22,6 +22,7 @@ import { replaceErrorCorrectionPattern } from "./correction/ErrorCorrectionPatte import { replaceMitigationPattern } from "./mitigation/MitigationPatternHandler"; import { attachPatternsToSuitableConstruct, + findPatternIdByName, getSolutionForPattern, removeAlgorithmAndAugmentationPatterns, } from "../util/PatternUtil"; @@ -159,13 +160,21 @@ export async function startPatternReplacementProcess(xml) { for (let replacementConstruct of augmentationReplacementConstructs) { console.log("Replacing augmentation pattern: ", replacementConstruct); + let patternId = replacementConstruct.task.patternId; + if (!patternId) { + console.log( + "Pattern ID undefined. Trying to retrieve via pattern name..." + ); + patternId = await findPatternIdByName(replacementConstruct.task.$type); + console.log("Retrieved pattern ID: ", patternId); + } + // retrieve solution for pattern to enable correct configuration - let concreteSolution = getSolutionForPattern( - replacementConstruct.task.patternId - ); + let concreteSolution = getSolutionForPattern(patternId); console.log("Solution: ", concreteSolution); // TODO: load detector from solution and configure inserted task + // TODO: incorporate augmentation patterns handled above let replacementSuccess = false; if (replacementConstruct.task.$type === constants.CIRCUIT_CUTTING) { diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 644d0096..6cfc29fd 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -14,7 +14,11 @@ import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layoute import * as constants from "../Constants"; import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; -import { getQcAtlasEndpoint } from "../framework-config/config-manager"; +import { + getPatternAtlasEndpoint, + getQcAtlasEndpoint, +} from "../framework-config/config-manager"; +import { fetchDataFromEndpoint } from "../../../editor/util/HttpUtilities"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); @@ -316,3 +320,41 @@ export function getSolutionForPattern(id) { // TODO return undefined; } + +/** + * Retrieve the ID of a pattern with the given type from the Pattern Atlas + * + * @param patternType the type of the pattern to retrieve the ID for + */ +export async function findPatternIdByName(patternType) { + console.log("Retrieving pattern ID by pattern type: ", patternType); + let patternName = patternType.split(":")[1]; + console.log("Pattern name: ", patternName); + + // retrieve all available patterns + console.log( + "Retrieving patterns from URL: ", + getPatternAtlasEndpoint() + "/patterns" + ); + const response = await fetchDataFromEndpoint( + getPatternAtlasEndpoint() + "/patterns" + ); + console.log("Response: ", response); + let patterns = response._embedded.patternModels; + console.log("Available patterns: ", patterns); + + // search pattern with given name + let filteredPatterns = patterns.filter( + (pattern) => + patternName.toUpperCase() === pattern.name.replace(" ", "").toUpperCase() + ); + console.log("Patterns with given type: ", filteredPatterns); + + // take the first solution if there are multiple + if (!filteredPatterns || filteredPatterns.length < 1) { + console.warn("Unable to retrieve pattern with name: ", patternName); + return undefined; + } else { + return filteredPatterns[0].id; + } +} From 47a04de083ae62df06478b1a431ae2a5ac139648 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 17:44:18 +0200 Subject: [PATCH 22/74] Add IDs to test --- components/bpmn-q/test/tests/helpers/DiagramHelper.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bpmn-q/test/tests/helpers/DiagramHelper.js b/components/bpmn-q/test/tests/helpers/DiagramHelper.js index 1c1025a3..b805374e 100644 --- a/components/bpmn-q/test/tests/helpers/DiagramHelper.js +++ b/components/bpmn-q/test/tests/helpers/DiagramHelper.js @@ -351,6 +351,5 @@ export const validQuantMESubprocessDiagram = ' Flow_036tksd Flow_19sigyl Flow_036tksdFlow_0k45o2vdef packagesUrl = execution.getVariable("packagesUrl"); def packageString = new URL (packagesUrl).getText(); //def packageString = new URL ("https://raw.githubusercontent.com/UST-QuAntiL/QuantME-UseCases/icwe/2023-icwe/data/packages.txt").getText(); def packages = [] def destinations = [] packageString.split("\\n").each { p -> def packageValues = [:] def values = p.split(",") packageValues.put("destination", values[0]) packageValues.put("size", values[1].toInteger()) packageValues.put("deliveryDate", values[2]) packages.add(packageValues) if (!destinations.contains(values[0])){destinations.add(values[0]) } } println(packages); println(destinations) execution.setVariable("destinations", destinations); execution.setVariable("packages", packages); execution.setVariable("nextDestinations", [destinations.getClass().newInstance(destinations)]); Flow_0k45o2vFlow_1o0job9 def trucksUrl = execution.getVariable("trucksUrl"); def destinations = execution.getVariable("destinations"); def trucksString = new URL (trucksUrl).getText(); def trucks = [] trucksString.split("\\n").each { p -> def truckValues = [:] def values = p.split(",") truckValues.put("driver", values[0]) truckValues.put("capacity", values[1].toInteger()) truckValues.put("location", values[2]) truckValues.put("email", values[3]) trucks.add(truckValues) if (!destinations.contains(values[2])){destinations.add(values[2]) } } execution.setVariable("trucks", trucks); execution.setVariable("allCities", destinations); execution.setVariable("unassignedTrucks", trucks); POST application/jsonapplication/json http://distance-matrix:8101/useCaseDistanceMatrix import groovy.json.JsonBuilderdef allCities = execution.getVariable("allCities"); def aws_token = execution.getVariable("awsToken"); def request = [:]; request.put("towns", allCities); request.put("token", aws_token); requeststring = new JsonBuilder(request).toPrettyString() return requeststring; def resp = connector.getVariable("response");resp = new groovy.json.JsonSlurper().parseText(resp)distanceMatrix= resp.get("distanceMatrix")println(distanceMatrix);return distanceMatrix; def resp = connector.getVariable("response");resp = new groovy.json.JsonSlurper().parseText(resp)durationMatrix= resp.get("durationMatrix")println(durationMatrix);return durationMatrix; http-connectorFlow_1o0job9Flow_0pqisjm Flow_164r496Flow_1uk996u def nextDestinations = execution.getVariable("nextDestinations"); execution.setVariable("currentDestinations", nextDestinations[0].getClass().newInstance(nextDestinations[0])); Flow_1lgu2v0Flow_19sigyl Flow_1uk996uFlow_0ey4t8g def unassignedTrucks = execution.getVariable("unassignedTrucks"); def packages = execution.getVariable("packages"); def currentDestinations = execution.getVariable("currentDestinations"); def maxCapacity = 0; unassignedTrucks.each { truck -> if (truck.get("capacity") > maxCapacity) {maxCapacity = truck.get("capacity"); } } def totalSize = 0; packages.each { p -> if( currentDestinations.contains(p.get("destination"))) {totalSize += p.get("size"); } } execution.setVariable("allFitsInTruck", totalSize < maxCapacity); Flow_08svt2nFlow_1lgu2v0Flow_1mglfkn def unassignedTrucks = execution.getVariable("unassignedTrucks"); def nextDestinations= execution.getVariable("nextDestinations"); return !(unassignedTrucks.size() > 0 && nextDestinations.size() > 0) Flow_1mglfknFlow_0kiekyoFlow_03ixpie def unassignedTrucks = execution.getVariable("unassignedTrucks"); def nextDestinations= execution.getVariable("nextDestinations"); return (unassignedTrucks.size() > 0 && nextDestinations.size() > 0) Flow_0pqisjmFlow_03ixpieFlow_164r496 Flow_0ey4t8gFlow_0wg476aFlow_1d4o5uw ${ execution.getVariable("allFitsInTruck")!= null && execution.getVariable("allFitsInTruck") == "true"} Flow_0wg476aFlow_1k013oeFlow_1m1hkm4 Flow_1d4o5uwFlow_0awxqtpFlow_1k013oe ${ execution.getVariable("allFitsInTruck")== null || execution.getVariable("allFitsInTruck") == "false"} def unassignedTrucks = execution.getVariable("unassignedTrucks"); def currentDestinations = execution.getVariable("currentDestinations"); return unassignedTrucks.size() > 1 && currentDestinations.size() > 1 def unassignedTrucks = execution.getVariable("unassignedTrucks"); def currentDestinations = execution.getVariable("currentDestinations"); return !(unassignedTrucks.size() > 1 && currentDestinations.size() > 1) Flow_0t1933oFlow_08svt2ndef unassignedTrucks = execution.getVariable("unassignedTrucks");def nextDestinations = execution.getVariable("nextDestinations");def currentRoute= execution.getVariable("currentRoute");def allRoutes= execution.getVariable("allRoutes");println(unassignedTrucks[0].get("driver")+" on route" + currentRoute.inspect());if(allRoutes == null){ allRoutes = [];}this_route =[:]this_route.put("route", currentRoute.getClass().newInstance(currentRoute));this_route.put("driver", unassignedTrucks[0].getClass().newInstance(unassignedTrucks[0]));allRoutes.push(this_route);nextDestinations.removeAt(0);unassignedTrucks.removeAt(0);execution.setVariable("allRoutes", allRoutes);execution.setVariable("nextDestinations", nextDestinations);execution.setVariable("unassignedTrucks", unassignedTrucks); Flow_1gu7ma8Flow_0kiekyo def currentDestinations = execution.getVariable("currentDestinations"); def nextDestinations = execution.getVariable("nextDestinations"); def evaluatedCosts = execution.getVariable("evaluatedCosts");println(nextDestinations); evaluatedCosts = evaluatedCosts[0].get("bitstring");println(evaluatedCosts); def cities_with_zero =[]; def cities_with_one =[]; evaluatedCosts.toCharArray().eachWithIndex { c, index -> (c == "0") ? cities_with_zero.push(currentDestinations[index]) : cities_with_one.push(currentDestinations[index]); }if (cities_with_zero.size()==0 || cities_with_one.size()==0) { nextDestinations.push(currentDestinations[0..((int)(currentDestinations.size()/2))-1]); nextDestinations.push(currentDestinations[((int)(currentDestinations.size()/2))..currentDestinations.size()-1]);} else { nextDestinations.push(cities_with_zero); nextDestinations.push(cities_with_one);}println(nextDestinations); nextDestinations.removeAt(0); println(nextDestinations); execution.setVariable("nextDestinations", nextDestinations); Flow_1m1hkm4Flow_0t1933o [1] [1] YOUR_TOKENFlow_12pjp7kFlow_1gu7ma8 Flow_0awxqtpFlow_12pjp7k def allCities = execution.getVariable("allCities"); def currentDestinations = execution.getVariable("currentDestinations"); def distanceMatrix = execution.getVariable("distanceMatrix"); def durationMatrix = execution.getVariable("durationMatrix"); def requiredIndizes = [] for (def i in 0..allCities.size()-1) { if (currentDestinations.contains(allCities[i])){requiredIndizes.push(i) } } def submatrixOfDistanceMatrix = new Integer [requiredIndizes.size()] [requiredIndizes.size()]; def submatrixOfDurationMatrix = new Float [requiredIndizes.size()] [requiredIndizes.size()]; for (def i in 0..requiredIndizes.size()-1) { submatrixOfDistanceMatrix [i][i] = 0; submatrixOfDurationMatrix [i][i] = 0.0; for (def j in i+1..requiredIndizes.size()-1) {if (j < requiredIndizes.size()){submatrixOfDistanceMatrix [i][j] = distanceMatrix[requiredIndizes[i]][requiredIndizes[j]];submatrixOfDistanceMatrix [j][i] = distanceMatrix[requiredIndizes[j]][requiredIndizes[i]];submatrixOfDurationMatrix [j][i] = durationMatrix[requiredIndizes[j]][requiredIndizes[i]];submatrixOfDurationMatrix [j][i] = durationMatrix[requiredIndizes[j]][requiredIndizes[i]];} } }println(submatrixOfDistanceMatrix); // switch between distance and duration depending on reqs execution.setVariable("adjMatrix", submatrixOfDistanceMatrix); '; export const validPatternDiagram = - ' Flow_1xhrbpv Flow_1xhrbpv Flow_0xn9oed Flow_1tfrxew Flow_1tfrxew Flow_13c71gm Flow_13c71gm Flow_1mo76yx SequenceFlow_14lmcjd SequenceFlow_0q54ilk SequenceFlow_1g4nyfq SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_14lmcjd SequenceFlow_123mbe9 ${ execution.getVariable("converged")!= null && execution.getVariable("converged") == "true"} ${ execution.getVariable("converged")== null || execution.getVariable("converged") == "false"} SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_123mbe9 SequenceFlow_0wggqgf SequenceFlow_0q54ilk SequenceFlow_0wggqgf SequenceFlow_1g4nyfq Flow_1mo76yx Flow_0tbeqf7 Flow_0tbeqf7 Flow_0xn9oed '; - + ' Flow_1xhrbpv Flow_1xhrbpv Flow_0xn9oed Flow_1tfrxew Flow_1tfrxew Flow_13c71gm Flow_13c71gm Flow_1mo76yx SequenceFlow_14lmcjd SequenceFlow_0q54ilk SequenceFlow_1g4nyfq SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_14lmcjd SequenceFlow_123mbe9 ${ execution.getVariable("converged")!= null && execution.getVariable("converged") == "true"} ${ execution.getVariable("converged")== null || execution.getVariable("converged") == "false"} SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_123mbe9 SequenceFlow_0wggqgf SequenceFlow_0q54ilk SequenceFlow_0wggqgf SequenceFlow_1g4nyfq Flow_1mo76yx Flow_0tbeqf7 Flow_0tbeqf7 Flow_0xn9oed '; export { validPlanqkDiagram, transformedValidPlanqkDiagram }; From 13ed40dd3b5960b00d32396138da3f627d5bb5be Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 14 May 2024 17:54:51 +0200 Subject: [PATCH 23/74] Add QC atlas to test setup --- .github/workflows/run-npm-test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index af1661d7..09051f4c 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -16,6 +16,11 @@ jobs: image: planqk/workflow-engine-test:latest ports: - 8090:8090 + pattern-atlas-api: + image: patternatlas/pattern-atlas-api:latest + ports: + - 1978:80 + steps: - uses: actions/checkout@v3 @@ -27,4 +32,4 @@ jobs: npm ci npm run build npm test - working-directory: ./components/bpmn-q \ No newline at end of file + working-directory: ./components/bpmn-q From 263de274d11af51534d9bcdbe4346b7864d3f5c3 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 10:47:37 +0200 Subject: [PATCH 24/74] Add environment and version for Pattern Atlas container --- .github/workflows/run-npm-test.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 09051f4c..56f7d542 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -17,9 +17,20 @@ jobs: ports: - 8090:8090 pattern-atlas-api: - image: patternatlas/pattern-atlas-api:latest + image: patternatlas/pattern-atlas-api:v1.9.0 ports: - 1978:80 + env: + JDBC_DATABASE_URL: db + JDBC_DATABASE_USERNAME: patternatlas + JDBC_DATABASE_PASSWORD: patternatlas + JDBC_DATABASE_PORT: 5060 + DB_INIT_USER: patternatlas + DB_INIT_PASSWORD: patternatlas + JDBC_DATABASE_NAME: patternatlas + PATTERN_ATLAS_FETCH_INITIAL_DATA: 'true' + HAL_EXPLORER: 'false' + SPRING_PROFILES_ACTIVE: docker steps: From 2f6481461a75f077e4722b6b9224d244b72998c5 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 10:59:45 +0200 Subject: [PATCH 25/74] Add QC Atlas --- .github/workflows/run-npm-test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 56f7d542..ff8de55e 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -16,6 +16,8 @@ jobs: image: planqk/workflow-engine-test:latest ports: - 8090:8090 + + ### Pattern-based Test Setup ### pattern-atlas-api: image: patternatlas/pattern-atlas-api:v1.9.0 ports: @@ -32,6 +34,18 @@ jobs: HAL_EXPLORER: 'false' SPRING_PROFILES_ACTIVE: docker + qc-atlas: + image: planqk/atlas:v3.1.3 + ports: + - "6626:6626" + env: + POSTGRES_HOSTNAME: db + POSTGRES_PORT: 5060 + POSTGRES_USER: planqk + POSTGRES_PASSWORD: planqk + POSTGRES_DB: planqk + ### End of Pattern-based Test Setup ### + steps: - uses: actions/checkout@v3 From 99c8b93afb41f089b187e2a9badf0a579799f994 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:03:02 +0200 Subject: [PATCH 26/74] Fix ports for test setup --- .github/workflows/run-npm-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index ff8de55e..53f84a6a 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -37,7 +37,7 @@ jobs: qc-atlas: image: planqk/atlas:v3.1.3 ports: - - "6626:6626" + - 6626:6626 env: POSTGRES_HOSTNAME: db POSTGRES_PORT: 5060 From daf5b0f2645be2a9c9adba173484779d7e55698e Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:13:59 +0200 Subject: [PATCH 27/74] Add version for WF engine --- .github/workflows/run-npm-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 53f84a6a..71ef9bc2 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -12,10 +12,12 @@ jobs: runs-on: ubuntu-latest services: + ### Workflow Deployment Test Setup ### workflow-test-engine: - image: planqk/workflow-engine-test:latest + image: planqk/workflow-engine-test:v1.0.0 ports: - 8090:8090 + ### End of Workflow Deployment Test Setup ### ### Pattern-based Test Setup ### pattern-atlas-api: From 1da98823950ca4bc27d765ebdb4c8d49713aa103 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:18:16 +0200 Subject: [PATCH 28/74] Add database to test setup --- .github/workflows/run-npm-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 71ef9bc2..2775bf3f 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -20,6 +20,11 @@ jobs: ### End of Workflow Deployment Test Setup ### ### Pattern-based Test Setup ### + db: + image: planqk/db-test:v1.0.0 + ports: + - 5060:5060 + pattern-atlas-api: image: patternatlas/pattern-atlas-api:v1.9.0 ports: From 37993d0e1eee34d3699c5aae2a2a99b5e9539c1f Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:25:01 +0200 Subject: [PATCH 29/74] remove unused import --- .../opentosca/ui/deployment/services/DeploymentPlugin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js index 049fd2bb..ae4d1227 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js @@ -43,13 +43,11 @@ import { DEDICATED_HOSTING_POLICY, LOCATION_POLICY, } from "../../../Constants"; -import { forEach } from "min-dash"; import { getOpenTOSCAEndpoint, getWineryEndpoint, } from "../../../framework-config/config-manager"; import { fetchDataFromEndpoint } from "../../../../../editor/util/HttpUtilities"; -import * as config from "../../../framework-config/config-manager"; const defaultState = { windowOpenOnDemandDeploymentOverview: false, From 2e0820102d41d98a5a24e33886bb1f2c6b670838 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:25:35 +0200 Subject: [PATCH 30/74] remove unused import --- .../ui/deployment/services/ServiceDeploymentInputModal.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/ServiceDeploymentInputModal.js b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/ServiceDeploymentInputModal.js index 2f6462a6..d0e1628a 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/ServiceDeploymentInputModal.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/ServiceDeploymentInputModal.js @@ -14,10 +14,7 @@ import React, { useEffect } from "react"; // polyfill upcoming structural components import Modal from "../../../../../editor/ui/modal/Modal"; -import { fetch } from "whatwg-fetch"; import config from "../../../framework-config/config"; -import { forEach } from "min-dash"; -import { useState } from "diagram-js/lib/ui"; import { synchronousGetRequest } from "../../../utilities/Utilities"; const Title = Modal.Title || (({ children }) =>

{children}

); From 8843d502bd9db6642804aff8fc2d65274e39b7b4 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:27:46 +0200 Subject: [PATCH 31/74] Fix equality checks --- .../bpmn-q/modeler-component/editor/ui/Toolbar.js | 10 +++++----- .../modeler-component/editor/ui/XMLViewerButton.js | 2 +- .../extensions/opentosca/modeling/OpenTOSCARules.js | 2 +- .../ui/deployment/services/DeploymentPlugin.js | 2 +- .../extensions/pattern/modeling/PatternRules.js | 2 +- .../extensions/quantme/modeling/QuantMERules.js | 2 +- .../quantme/replacement/QuantMETransformator.js | 6 +++--- .../quantme/ui/adaptation/WorkflowRewriter.js | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/ui/Toolbar.js b/components/bpmn-q/modeler-component/editor/ui/Toolbar.js index ab33922c..d1a8bc3f 100644 --- a/components/bpmn-q/modeler-component/editor/ui/Toolbar.js +++ b/components/bpmn-q/modeler-component/editor/ui/Toolbar.js @@ -39,19 +39,19 @@ export default function Toolbar(props) { // retrieve all active plugins to identify also the dependency plugins const activePlugins = getActivePlugins(); const patternEnabled = activePlugins.some( - (p) => p.name == consts.pluginNames.PATTERN + (p) => p.name === consts.pluginNames.PATTERN ); const quantmeEnabled = activePlugins.some( - (p) => p.name == consts.pluginNames.QUANTME + (p) => p.name === consts.pluginNames.QUANTME ); const qhanaEnabled = activePlugins.some( - (p) => p.name == consts.pluginNames.QHANA + (p) => p.name === consts.pluginNames.QHANA ); const opentoscaEnabled = activePlugins.some( - (p) => p.name == consts.pluginNames.OPENTOSCA + (p) => p.name === consts.pluginNames.OPENTOSCA ); const dataflowEnabled = activePlugins.some( - (p) => p.name == consts.pluginNames.DATAFLOW + (p) => p.name === consts.pluginNames.DATAFLOW ); const handleShortcutClick = () => { diff --git a/components/bpmn-q/modeler-component/editor/ui/XMLViewerButton.js b/components/bpmn-q/modeler-component/editor/ui/XMLViewerButton.js index 4be7ec20..8eb15631 100644 --- a/components/bpmn-q/modeler-component/editor/ui/XMLViewerButton.js +++ b/components/bpmn-q/modeler-component/editor/ui/XMLViewerButton.js @@ -40,7 +40,7 @@ export default function XMLViewerButton() { // Dynamically set the value of the editor let xml = getModeler().xml; - if (xml.xml != undefined) { + if (xml.xml !== undefined) { xml = xml.xml; } aceEditor.setValue(xml); diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARules.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARules.js index 1a2b6f8b..df08e703 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARules.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARules.js @@ -48,7 +48,7 @@ export default class OpenTOSCARules extends RuleProvider { function canMove(context) { let target = context.target; - if (target != undefined) { + if (target !== undefined) { if (context.shapes[0].type.includes("Policy")) { return false; } diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js index ae4d1227..91e8949e 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/ui/deployment/services/DeploymentPlugin.js @@ -265,7 +265,7 @@ export default class DeploymentPlugin extends PureComponent { "Check instance with Id %i", serviceTemplateInstance.id ); - if (serviceTemplateInstance.state != "CREATED") { + if (serviceTemplateInstance.state !== "CREATED") { console.log( "Instance has invalid state: %s", serviceTemplateInstance.state diff --git a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js index 95a216d4..254f2753 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js @@ -28,7 +28,7 @@ export default class PatternRules extends RuleProvider { function canMove(context) { let target = context.target; - if (target != undefined) { + if (target !== undefined) { if (context.shapes[0].type.includes("pattern")) { return false; } diff --git a/components/bpmn-q/modeler-component/extensions/quantme/modeling/QuantMERules.js b/components/bpmn-q/modeler-component/extensions/quantme/modeling/QuantMERules.js index 39532d45..06f9df3b 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/modeling/QuantMERules.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/modeling/QuantMERules.js @@ -33,7 +33,7 @@ export default class QuantMERules extends RuleProvider { function canMove(context) { var target = context.target; - if (target != undefined) { + if (target !== undefined) { if (context.shapes[0].type.includes("Policy")) { return false; } diff --git a/components/bpmn-q/modeler-component/extensions/quantme/replacement/QuantMETransformator.js b/components/bpmn-q/modeler-component/extensions/quantme/replacement/QuantMETransformator.js index 383ddf2e..b008b45a 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/replacement/QuantMETransformator.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/replacement/QuantMETransformator.js @@ -222,7 +222,7 @@ function removeDiagramElements(modeler) { let elementsToRemove = []; let diagrams = definitions.diagrams; for (let i = 0; i < diagrams.length; i++) { - if (diagrams[i].plane.planeElement == undefined) { + if (diagrams[i].plane.planeElement === undefined) { elementsToRemove.push(diagrams[i]); } } @@ -372,7 +372,7 @@ async function replaceByFragment( let attachers = attachersPlaceholder.attachers; // if all policies are moved to the new target - if (attachers.length == 0) { + if (attachers.length === 0) { modeling.removeShape(attachersPlaceholder); } } @@ -462,7 +462,7 @@ function addQProvEndpoint(rootElement, elementRegistry, modeling, moddle) { } let form = extensionElements.get("values").filter(function (elem) { - return elem.$type == "camunda:FormData"; + return elem.$type === "camunda:FormData"; })[0]; if (!form) { diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/WorkflowRewriter.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/WorkflowRewriter.js index aa0d39b6..ad227a40 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/WorkflowRewriter.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/WorkflowRewriter.js @@ -448,7 +448,7 @@ function addSessionFormFields(rootElement, elementRegistry, modeling, moddle) { } let form = extensionElements.get("values").filter(function (elem) { - return elem.$type == "camunda:FormData"; + return elem.$type === "camunda:FormData"; })[0]; if (!form) { From 9ca4ff5c8f675c732248fb632f34eaa57360e8e0 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:29:44 +0200 Subject: [PATCH 32/74] Fix unused declarations --- .../opentosca/modeling/properties-provider/Connector.js | 4 +--- .../pattern/replacement/cutting/CuttingPatternHandler.js | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js index 32c970d2..8151de21 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js @@ -139,9 +139,7 @@ export function Connector({ element, translate, filteredUrls, methodUrlList }) { inputParameters.push(urlInputParameter); inputParameters.push(payloadInputParameter); - let outputParameters = []; - - outputParameters = determineOutputParameters(element.businessObject.yaml); + let outputParameters = determineOutputParameters(element.businessObject.yaml); let camundaOutputParameters = constructCamundaOutputParameters(outputParameters); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js index 68140c8f..fd863c7a 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js @@ -21,7 +21,6 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { let elementRegistry = modeler.get("elementRegistry"); let host = elementRegistry.get(cuttingPattern.id).host; - let elementToConnect = host; let flows = []; let cuttingTask = modeling.createShape( { type: quantmeConsts.CIRCUIT_CUTTING_TASK }, @@ -58,9 +57,7 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { { type: "bpmn:SequenceFlow" } ); }); - elementToConnect = resultCombinationTaks; - - modeling.connect(host, elementToConnect, { + modeling.connect(host, resultCombinationTaks, { type: "bpmn:SequenceFlow", }); From afa72114807b8391513e920135da4f26e0468191 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:34:04 +0200 Subject: [PATCH 33/74] Remove unused code --- .../util/camunda-utils/ConnectorUtil.js | 27 ------------------- .../quantme/ui/adaptation/AdaptationPlugin.js | 3 --- 2 files changed, 30 deletions(-) delete mode 100644 components/bpmn-q/modeler-component/editor/util/camunda-utils/ConnectorUtil.js diff --git a/components/bpmn-q/modeler-component/editor/util/camunda-utils/ConnectorUtil.js b/components/bpmn-q/modeler-component/editor/util/camunda-utils/ConnectorUtil.js deleted file mode 100644 index 09c7981d..00000000 --- a/components/bpmn-q/modeler-component/editor/util/camunda-utils/ConnectorUtil.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2015 camunda Services GmbH - * - * This code and the accompanying materials are made available by camunda under the - * terms of the MIT License. - */ -import { getServiceTaskLikeBusinessObject } from "./ImplementationTypeUtils"; -import { getExtensionElementsList } from "./ExtensionElementsUtil"; -import { getImplementationType } from "../../../extensions/quantme/utilities/ImplementationTypeHelperExtension"; - -export function areConnectorsSupported(element) { - const businessObject = getServiceTaskLikeBusinessObject(element); - return ( - businessObject && getImplementationType(businessObject) === "connector" - ); -} - -export function getConnectors(businessObject) { - return getExtensionElementsList(businessObject, "camunda:Connector"); -} - -export function getConnector(element) { - const businessObject = getServiceTaskLikeBusinessObject(element); - const connectors = getConnectors(businessObject); - - return connectors[0]; -} diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/AdaptationPlugin.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/AdaptationPlugin.js index b4392dd9..e2a8b775 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/AdaptationPlugin.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/AdaptationPlugin.js @@ -39,9 +39,6 @@ export default class AdaptationPlugin extends PureComponent { this.handleAdaptationClosed = this.handleAdaptationClosed.bind(this); this.handleRewriteClosed = this.handleRewriteClosed.bind(this); - - // get QuantME component from the backend, e.g., to retrieve current QRMs - this.quantME = ""; } async handleAdaptationClosed(result) { From 624e311e5305f628acb0f4accd8f767ff40efad8 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:36:20 +0200 Subject: [PATCH 34/74] Run linter --- .../editor/ModelerHandler.js | 28 ------------------- .../modeling/properties-provider/Connector.js | 4 ++- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/ModelerHandler.js b/components/bpmn-q/modeler-component/editor/ModelerHandler.js index 56f21ff1..ec785785 100644 --- a/components/bpmn-q/modeler-component/editor/ModelerHandler.js +++ b/components/bpmn-q/modeler-component/editor/ModelerHandler.js @@ -52,23 +52,6 @@ export function createModeler(containerId, propertiesParentId) { return modeler; } -/** - * Create a new modeler object with the Camunda extensions but no custom extensions - * - * @return the created modeler - */ -export function createPlainModeler() { - return new BpmnModeler({ - additionalModules: [CamundaExtensionModule], - keyboard: { - bindTo: document, - }, - moddleExtensions: { - camunda: camundaModdleDescriptor, - }, - }); -} - /** * Creates a modeler with all additional modules and extension moddles from all active plugins which is not * saved in as the current modeler instance @@ -85,17 +68,6 @@ export function createTempModeler() { }); } -/** - * Create a Modeler with only Camunda native extensions and no additional modules - * - * @returns the created bpmn-js modeler - */ -export function createLightweightModeler() { - return new BpmnModeler({ - moddleExtensions: getExtensions(), - }); -} - /** * Creates a modeler with all additional modules and extension moddles from all active plugins which is not * saved in as the current modeler instance and load the given xml into it. diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js index 8151de21..6c241641 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js @@ -139,7 +139,9 @@ export function Connector({ element, translate, filteredUrls, methodUrlList }) { inputParameters.push(urlInputParameter); inputParameters.push(payloadInputParameter); - let outputParameters = determineOutputParameters(element.businessObject.yaml); + let outputParameters = determineOutputParameters( + element.businessObject.yaml + ); let camundaOutputParameters = constructCamundaOutputParameters(outputParameters); From aba073697d143c5ffadb1b2c19be9ece94b53afc Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:41:15 +0200 Subject: [PATCH 35/74] Use constant for QuantumCircuitExecutionTask --- .../pattern/modeling/PatternReplaceMenuProvider.js | 5 ----- .../extensions/pattern/modeling/PatternRules.js | 3 ++- .../replacement/circuit-cutting/QuantMECuttingHandler.js | 3 ++- .../extensions/quantme/ui/adaptation/CandidateDetector.js | 3 ++- .../extensions/quantme/utilities/Utilities.js | 3 ++- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternReplaceMenuProvider.js b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternReplaceMenuProvider.js index ca027133..bdb97d35 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternReplaceMenuProvider.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternReplaceMenuProvider.js @@ -126,11 +126,6 @@ export default class PatternReplaceMenuProvider { return {}; } - //Object.assign( - // behavioralPatterns, - // augmentationPatterns - //); - return { ["replace-by-more-options"]: createMoreOptionsEntryWithReturn( element, diff --git a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js index 254f2753..0870bef4 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/modeling/PatternRules.js @@ -13,6 +13,7 @@ import RuleProvider from "diagram-js/lib/features/rules/RuleProvider"; import * as consts from "../Constants"; import * as quantmeConsts from "../../quantme/Constants"; import { getBoundaryAttachment as isBoundaryAttachment } from "bpmn-js/lib/features/snapping/BpmnSnappingUtil"; +import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../../quantme/Constants"; export default class PatternRules extends RuleProvider { constructor(eventBus, modeling) { super(eventBus); @@ -161,7 +162,7 @@ export default class PatternRules extends RuleProvider { if ( shapeToAttach.type.includes("pattern:Pattern") && - (target.type === "quantme:QuantumCircuitExecutionTask" || + (target.type === QUANTUM_CIRCUIT_EXECUTION_TASK || target.type === "quantme:QuantumCircuitLoadingTask") ) { return true; diff --git a/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js b/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js index 29215cb0..6189d77a 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js @@ -19,6 +19,7 @@ import { getDefinitionsFromXml, getRootProcess, } from "../../../../editor/util/ModellingUtilities"; +import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../../Constants"; /** * Replace the given QuantumHardwareSelectionSubprocess by a native subprocess orchestrating the hardware selection */ @@ -71,7 +72,7 @@ export async function replaceCuttingSubprocess( bo.flowElements.forEach((element) => { if (element.$type === "bpmn:StartEvent") { startEvent = element; - } else if (element.$type === "quantme:QuantumCircuitExecutionTask") { + } else if (element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK) { if ( element.outgoing[0].targetRef.$type === "quantme:ReadoutErrorMitigationTask" diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js index abe1eb83..0cf43619 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js @@ -17,6 +17,7 @@ import { getModeler, } from "../../../../editor/ModelerHandler"; import { getXml } from "../../../../editor/util/IoUtilities"; +import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../../Constants"; /** * Find candidates within the current workflow model that can be executed efficiently using a hybrid runtime @@ -477,7 +478,7 @@ function containsQuantumCircuitExecutionTask(candidate) { let element = candidate.containedElements[i]; if ( element.$type && - element.$type === "quantme:QuantumCircuitExecutionTask" + element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK ) { return true; } diff --git a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js index 4ead41ee..dc85c617 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js @@ -11,6 +11,7 @@ import $ from "jquery"; import * as quantmeConsts from "../Constants"; +import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../Constants"; /** * Check if the given task is a QuantME task @@ -30,7 +31,7 @@ export function isQuantMETask(task) { */ export function getQuantumCircuitExecutionTasks(modelingElements) { return modelingElements.filter( - (element) => element.$type === "quantme:QuantumCircuitExecutionTask" + (element) => element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK ); } From afd513b420fdd450ee3f7b829657c6b0e243c8cc Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:43:28 +0200 Subject: [PATCH 36/74] Use constant for REM --- .../properties-provider/QuantMEPropertyEntries.js | 3 ++- .../replacement/circuit-cutting/QuantMECuttingHandler.js | 8 +++++--- .../extensions/quantme/ui/adaptation/CandidateDetector.js | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertyEntries.js b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertyEntries.js index cb6978ff..345c92aa 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertyEntries.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertyEntries.js @@ -19,6 +19,7 @@ import { import * as consts from "../../Constants"; import { useService } from "bpmn-js-properties-panel"; import { HiddenTextFieldEntry } from "../../../../editor/popup/HiddenFieldEntry"; +import { READOUT_ERROR_MITIGATION_TASK } from "../../Constants"; /** * All entries needed to display the different properties introduced through the QuantME task types. One entry represents one @@ -740,7 +741,7 @@ export function ObjectiveFunctionEntry({ element }) { const hidden = function () { let taskType = element.businessObject.$type; - if (taskType === "quantme:ReadoutErrorMitigationTask") { + if (taskType === READOUT_ERROR_MITIGATION_TASK) { let mitigationMethod = element.businessObject.mitigationMethod; return !(mitigationMethod === "geneticBasedREM"); } else { diff --git a/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js b/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js index 6189d77a..b3686437 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/replacement/circuit-cutting/QuantMECuttingHandler.js @@ -19,7 +19,10 @@ import { getDefinitionsFromXml, getRootProcess, } from "../../../../editor/util/ModellingUtilities"; -import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../../Constants"; +import { + QUANTUM_CIRCUIT_EXECUTION_TASK, + READOUT_ERROR_MITIGATION_TASK, +} from "../../Constants"; /** * Replace the given QuantumHardwareSelectionSubprocess by a native subprocess orchestrating the hardware selection */ @@ -74,8 +77,7 @@ export async function replaceCuttingSubprocess( startEvent = element; } else if (element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK) { if ( - element.outgoing[0].targetRef.$type === - "quantme:ReadoutErrorMitigationTask" + element.outgoing[0].targetRef.$type === READOUT_ERROR_MITIGATION_TASK ) { combinePointers.push(element.outgoing[0].targetRef); } else { diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js index 0cf43619..9356f816 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js @@ -476,10 +476,7 @@ function getOptimizationCandidate(candidate) { function containsQuantumCircuitExecutionTask(candidate) { for (let i = 0; i < candidate.containedElements.length; i++) { let element = candidate.containedElements[i]; - if ( - element.$type && - element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK - ) { + if (element.$type && element.$type === QUANTUM_CIRCUIT_EXECUTION_TASK) { return true; } } From 8e1e7c4e50adcd847a049dafd7f2702d482ca07b Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 11:49:35 +0200 Subject: [PATCH 37/74] Move comment to correct position --- .../extensions/quantme/ui/adaptation/CandidateDetector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js index 9356f816..33c70099 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/CandidateDetector.js @@ -360,9 +360,9 @@ function getXOREntryPoints(rootElement) { if (flowElement.$type && flowElement.$type === "bpmn:SubProcess") { console.log("Found subprocess ", flowElement); - Array.prototype.push.apply(entryPoints, getXOREntryPoints(flowElement)); // recursively call method to find optimization candidates + Array.prototype.push.apply(entryPoints, getXOREntryPoints(flowElement)); } } From 9baffc44a10ad32511996c6b9b4d775499ee365d Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 15:05:13 +0200 Subject: [PATCH 38/74] Remove duplicate ajax method --- .../editor/util/HttpUtilities.js | 22 +++++++++++++++++++ .../opentosca/deployment/OpenTOSCAUtils.js | 2 +- .../opentosca/utilities/Utilities.js | 20 ----------------- .../adaptation/runtimes/AwsRuntimeHandler.js | 6 ++--- .../runtimes/QiskitRuntimeHandler.js | 6 ++--- .../extensions/quantme/utilities/Utilities.js | 21 ------------------ 6 files changed, 27 insertions(+), 50 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js index d08e9c9a..0c015160 100644 --- a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js @@ -9,6 +9,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +import $ from "jquery"; + /** * Retrieves the Json data from the given endpoint. * @@ -47,3 +49,23 @@ export async function fetchSolutionFromEndpoint(endpoint) { return {}; } } + +export function performAjax(targetUrl, dataToSend) { + return new Promise(function (resolve, reject) { + $.ajax({ + type: "POST", + url: targetUrl, + data: dataToSend, + processData: false, + crossDomain: true, + contentType: false, + beforeSend: function () {}, + success: function (data) { + resolve(data); + }, + error: function (err) { + reject(err); + }, + }); + }); +} diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/deployment/OpenTOSCAUtils.js b/components/bpmn-q/modeler-component/extensions/opentosca/deployment/OpenTOSCAUtils.js index 14371c8f..59b39551 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/deployment/OpenTOSCAUtils.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/deployment/OpenTOSCAUtils.js @@ -10,7 +10,7 @@ */ import { fetch } from "whatwg-fetch"; -import { performAjax } from "../utilities/Utilities"; +import { performAjax } from "../../../editor/util/HttpUtilities"; /** * Upload the CSAR located at the given URL to the connected OpenTOSCA Container and return the corresponding URL and required input parameters diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/utilities/Utilities.js b/components/bpmn-q/modeler-component/extensions/opentosca/utilities/Utilities.js index 66da8a3f..bfa340de 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/utilities/Utilities.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/utilities/Utilities.js @@ -9,29 +9,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import $ from "jquery"; import { ON_DEMAND_POLICY, POLICIES } from "../Constants"; import * as config from "../framework-config/config-manager"; -export function performAjax(targetUrl, dataToSend) { - return new Promise(function (resolve, reject) { - $.ajax({ - type: "POST", - url: targetUrl, - data: dataToSend, - processData: false, - contentType: false, - beforeSend: function () {}, - success: function (data) { - resolve(data); - }, - error: function (err) { - reject(err); - }, - }); - }); -} - export function synchronousGetRequest(url) { const xhr = new XMLHttpRequest(); xhr.open("GET", url, false); diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/AwsRuntimeHandler.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/AwsRuntimeHandler.js index 01fd67d7..e1c8cfa3 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/AwsRuntimeHandler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/AwsRuntimeHandler.js @@ -10,10 +10,7 @@ */ import { fetch } from "whatwg-fetch"; -import { - getQuantumCircuitExecutionTasks, - performAjax, -} from "../../../utilities/Utilities"; +import { getQuantumCircuitExecutionTasks } from "../../../utilities/Utilities"; import { startQuantmeReplacementProcess } from "../../../replacement/QuantMETransformator"; import { createNewArtifactTemplate, @@ -26,6 +23,7 @@ import { } from "./RuntimeHandlerUtils"; import { createTempModelerFromXml } from "../../../../../editor/ModelerHandler"; import { getRootProcess } from "../../../../../editor/util/ModellingUtilities"; +import { performAjax } from "../../../../../editor/util/HttpUtilities"; /** * Generate a AWS Runtime program for the given candidate diff --git a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/QiskitRuntimeHandler.js b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/QiskitRuntimeHandler.js index 4331b2af..cff38a2b 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/QiskitRuntimeHandler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/ui/adaptation/runtimes/QiskitRuntimeHandler.js @@ -11,10 +11,7 @@ import { fetch } from "whatwg-fetch"; import { startQuantmeReplacementProcess } from "../../../replacement/QuantMETransformator"; -import { - getQuantumCircuitExecutionTasks, - performAjax, -} from "../../../utilities/Utilities"; +import { getQuantumCircuitExecutionTasks } from "../../../utilities/Utilities"; import { createNewArtifactTemplate, createNewServiceTemplateVersion, @@ -29,6 +26,7 @@ import { getQiskitRuntimeHandlerEndpoint, } from "../../../framework-config/config-manager"; import JSZip from "jszip"; +import { performAjax } from "../../../../../editor/util/HttpUtilities"; /** * Generate a Qiskit Runtime program for the given candidate diff --git a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js index dc85c617..a172e631 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/utilities/Utilities.js @@ -9,7 +9,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import $ from "jquery"; import * as quantmeConsts from "../Constants"; import { QUANTUM_CIRCUIT_EXECUTION_TASK } from "../Constants"; @@ -35,26 +34,6 @@ export function getQuantumCircuitExecutionTasks(modelingElements) { ); } -export function performAjax(targetUrl, dataToSend) { - return new Promise(function (resolve, reject) { - $.ajax({ - type: "POST", - url: targetUrl, - data: dataToSend, - processData: false, - crossDomain: true, - contentType: false, - beforeSend: function () {}, - success: function (data) { - resolve(data); - }, - error: function (err) { - reject(err); - }, - }); - }); -} - /** * Checks if the given element is a subprocess or not * From c2c081b83468844039846a88afaca2614296c022 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 15:53:43 +0200 Subject: [PATCH 39/74] Remove pattern IDs from test workflow --- components/bpmn-q/test/tests/helpers/DiagramHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/helpers/DiagramHelper.js b/components/bpmn-q/test/tests/helpers/DiagramHelper.js index b805374e..f66508ab 100644 --- a/components/bpmn-q/test/tests/helpers/DiagramHelper.js +++ b/components/bpmn-q/test/tests/helpers/DiagramHelper.js @@ -351,5 +351,5 @@ export const validQuantMESubprocessDiagram = ' Flow_036tksd Flow_19sigyl Flow_036tksdFlow_0k45o2vdef packagesUrl = execution.getVariable("packagesUrl"); def packageString = new URL (packagesUrl).getText(); //def packageString = new URL ("https://raw.githubusercontent.com/UST-QuAntiL/QuantME-UseCases/icwe/2023-icwe/data/packages.txt").getText(); def packages = [] def destinations = [] packageString.split("\\n").each { p -> def packageValues = [:] def values = p.split(",") packageValues.put("destination", values[0]) packageValues.put("size", values[1].toInteger()) packageValues.put("deliveryDate", values[2]) packages.add(packageValues) if (!destinations.contains(values[0])){destinations.add(values[0]) } } println(packages); println(destinations) execution.setVariable("destinations", destinations); execution.setVariable("packages", packages); execution.setVariable("nextDestinations", [destinations.getClass().newInstance(destinations)]); Flow_0k45o2vFlow_1o0job9 def trucksUrl = execution.getVariable("trucksUrl"); def destinations = execution.getVariable("destinations"); def trucksString = new URL (trucksUrl).getText(); def trucks = [] trucksString.split("\\n").each { p -> def truckValues = [:] def values = p.split(",") truckValues.put("driver", values[0]) truckValues.put("capacity", values[1].toInteger()) truckValues.put("location", values[2]) truckValues.put("email", values[3]) trucks.add(truckValues) if (!destinations.contains(values[2])){destinations.add(values[2]) } } execution.setVariable("trucks", trucks); execution.setVariable("allCities", destinations); execution.setVariable("unassignedTrucks", trucks); POST application/jsonapplication/json http://distance-matrix:8101/useCaseDistanceMatrix import groovy.json.JsonBuilderdef allCities = execution.getVariable("allCities"); def aws_token = execution.getVariable("awsToken"); def request = [:]; request.put("towns", allCities); request.put("token", aws_token); requeststring = new JsonBuilder(request).toPrettyString() return requeststring; def resp = connector.getVariable("response");resp = new groovy.json.JsonSlurper().parseText(resp)distanceMatrix= resp.get("distanceMatrix")println(distanceMatrix);return distanceMatrix; def resp = connector.getVariable("response");resp = new groovy.json.JsonSlurper().parseText(resp)durationMatrix= resp.get("durationMatrix")println(durationMatrix);return durationMatrix; http-connectorFlow_1o0job9Flow_0pqisjm Flow_164r496Flow_1uk996u def nextDestinations = execution.getVariable("nextDestinations"); execution.setVariable("currentDestinations", nextDestinations[0].getClass().newInstance(nextDestinations[0])); Flow_1lgu2v0Flow_19sigyl Flow_1uk996uFlow_0ey4t8g def unassignedTrucks = execution.getVariable("unassignedTrucks"); def packages = execution.getVariable("packages"); def currentDestinations = execution.getVariable("currentDestinations"); def maxCapacity = 0; unassignedTrucks.each { truck -> if (truck.get("capacity") > maxCapacity) {maxCapacity = truck.get("capacity"); } } def totalSize = 0; packages.each { p -> if( currentDestinations.contains(p.get("destination"))) {totalSize += p.get("size"); } } execution.setVariable("allFitsInTruck", totalSize < maxCapacity); Flow_08svt2nFlow_1lgu2v0Flow_1mglfkn def unassignedTrucks = execution.getVariable("unassignedTrucks"); def nextDestinations= execution.getVariable("nextDestinations"); return !(unassignedTrucks.size() > 0 && nextDestinations.size() > 0) Flow_1mglfknFlow_0kiekyoFlow_03ixpie def unassignedTrucks = execution.getVariable("unassignedTrucks"); def nextDestinations= execution.getVariable("nextDestinations"); return (unassignedTrucks.size() > 0 && nextDestinations.size() > 0) Flow_0pqisjmFlow_03ixpieFlow_164r496 Flow_0ey4t8gFlow_0wg476aFlow_1d4o5uw ${ execution.getVariable("allFitsInTruck")!= null && execution.getVariable("allFitsInTruck") == "true"} Flow_0wg476aFlow_1k013oeFlow_1m1hkm4 Flow_1d4o5uwFlow_0awxqtpFlow_1k013oe ${ execution.getVariable("allFitsInTruck")== null || execution.getVariable("allFitsInTruck") == "false"} def unassignedTrucks = execution.getVariable("unassignedTrucks"); def currentDestinations = execution.getVariable("currentDestinations"); return unassignedTrucks.size() > 1 && currentDestinations.size() > 1 def unassignedTrucks = execution.getVariable("unassignedTrucks"); def currentDestinations = execution.getVariable("currentDestinations"); return !(unassignedTrucks.size() > 1 && currentDestinations.size() > 1) Flow_0t1933oFlow_08svt2ndef unassignedTrucks = execution.getVariable("unassignedTrucks");def nextDestinations = execution.getVariable("nextDestinations");def currentRoute= execution.getVariable("currentRoute");def allRoutes= execution.getVariable("allRoutes");println(unassignedTrucks[0].get("driver")+" on route" + currentRoute.inspect());if(allRoutes == null){ allRoutes = [];}this_route =[:]this_route.put("route", currentRoute.getClass().newInstance(currentRoute));this_route.put("driver", unassignedTrucks[0].getClass().newInstance(unassignedTrucks[0]));allRoutes.push(this_route);nextDestinations.removeAt(0);unassignedTrucks.removeAt(0);execution.setVariable("allRoutes", allRoutes);execution.setVariable("nextDestinations", nextDestinations);execution.setVariable("unassignedTrucks", unassignedTrucks); Flow_1gu7ma8Flow_0kiekyo def currentDestinations = execution.getVariable("currentDestinations"); def nextDestinations = execution.getVariable("nextDestinations"); def evaluatedCosts = execution.getVariable("evaluatedCosts");println(nextDestinations); evaluatedCosts = evaluatedCosts[0].get("bitstring");println(evaluatedCosts); def cities_with_zero =[]; def cities_with_one =[]; evaluatedCosts.toCharArray().eachWithIndex { c, index -> (c == "0") ? cities_with_zero.push(currentDestinations[index]) : cities_with_one.push(currentDestinations[index]); }if (cities_with_zero.size()==0 || cities_with_one.size()==0) { nextDestinations.push(currentDestinations[0..((int)(currentDestinations.size()/2))-1]); nextDestinations.push(currentDestinations[((int)(currentDestinations.size()/2))..currentDestinations.size()-1]);} else { nextDestinations.push(cities_with_zero); nextDestinations.push(cities_with_one);}println(nextDestinations); nextDestinations.removeAt(0); println(nextDestinations); execution.setVariable("nextDestinations", nextDestinations); Flow_1m1hkm4Flow_0t1933o [1] [1] YOUR_TOKENFlow_12pjp7kFlow_1gu7ma8 Flow_0awxqtpFlow_12pjp7k def allCities = execution.getVariable("allCities"); def currentDestinations = execution.getVariable("currentDestinations"); def distanceMatrix = execution.getVariable("distanceMatrix"); def durationMatrix = execution.getVariable("durationMatrix"); def requiredIndizes = [] for (def i in 0..allCities.size()-1) { if (currentDestinations.contains(allCities[i])){requiredIndizes.push(i) } } def submatrixOfDistanceMatrix = new Integer [requiredIndizes.size()] [requiredIndizes.size()]; def submatrixOfDurationMatrix = new Float [requiredIndizes.size()] [requiredIndizes.size()]; for (def i in 0..requiredIndizes.size()-1) { submatrixOfDistanceMatrix [i][i] = 0; submatrixOfDurationMatrix [i][i] = 0.0; for (def j in i+1..requiredIndizes.size()-1) {if (j < requiredIndizes.size()){submatrixOfDistanceMatrix [i][j] = distanceMatrix[requiredIndizes[i]][requiredIndizes[j]];submatrixOfDistanceMatrix [j][i] = distanceMatrix[requiredIndizes[j]][requiredIndizes[i]];submatrixOfDurationMatrix [j][i] = durationMatrix[requiredIndizes[j]][requiredIndizes[i]];submatrixOfDurationMatrix [j][i] = durationMatrix[requiredIndizes[j]][requiredIndizes[i]];} } }println(submatrixOfDistanceMatrix); // switch between distance and duration depending on reqs execution.setVariable("adjMatrix", submatrixOfDistanceMatrix); '; export const validPatternDiagram = - ' Flow_1xhrbpv Flow_1xhrbpv Flow_0xn9oed Flow_1tfrxew Flow_1tfrxew Flow_13c71gm Flow_13c71gm Flow_1mo76yx SequenceFlow_14lmcjd SequenceFlow_0q54ilk SequenceFlow_1g4nyfq SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_14lmcjd SequenceFlow_123mbe9 ${ execution.getVariable("converged")!= null && execution.getVariable("converged") == "true"} ${ execution.getVariable("converged")== null || execution.getVariable("converged") == "false"} SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_123mbe9 SequenceFlow_0wggqgf SequenceFlow_0q54ilk SequenceFlow_0wggqgf SequenceFlow_1g4nyfq Flow_1mo76yx Flow_0tbeqf7 Flow_0tbeqf7 Flow_0xn9oed '; + ' Flow_1xhrbpv Flow_1xhrbpv Flow_0xn9oed Flow_1tfrxew Flow_1tfrxew Flow_13c71gm Flow_13c71gm Flow_1mo76yx SequenceFlow_14lmcjd SequenceFlow_0q54ilk SequenceFlow_1g4nyfq SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_14lmcjd SequenceFlow_123mbe9 ${ execution.getVariable("converged")!= null && execution.getVariable("converged") == "true"} ${ execution.getVariable("converged")== null || execution.getVariable("converged") == "false"} SequenceFlow_0rvah9x SequenceFlow_03d0zlb SequenceFlow_123mbe9 SequenceFlow_0wggqgf SequenceFlow_0q54ilk SequenceFlow_0wggqgf SequenceFlow_1g4nyfq Flow_1mo76yx Flow_0tbeqf7 Flow_0tbeqf7 Flow_0xn9oed '; export { validPlanqkDiagram, transformedValidPlanqkDiagram }; From 98a7a2fb2045fd12985a2d50164e9a58c2b39773 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:06:15 +0200 Subject: [PATCH 40/74] Fix port mapping --- .github/workflows/run-npm-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 2775bf3f..5f1996c7 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -28,7 +28,7 @@ jobs: pattern-atlas-api: image: patternatlas/pattern-atlas-api:v1.9.0 ports: - - 1978:80 + - 1977:1977 env: JDBC_DATABASE_URL: db JDBC_DATABASE_USERNAME: patternatlas From 57a8fb75ab7cc4888fcab5607838ca5fb198d0b4 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:23:49 +0200 Subject: [PATCH 41/74] Bump DB version --- .github/workflows/run-npm-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 5f1996c7..fa868bef 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -21,7 +21,7 @@ jobs: ### Pattern-based Test Setup ### db: - image: planqk/db-test:v1.0.0 + image: planqk/db-test:v1.1.0 ports: - 5060:5060 From c7291d3f0cd8e011804ce273f7b72ba67b7fe92f Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:28:36 +0200 Subject: [PATCH 42/74] Add DB env --- .github/workflows/run-npm-test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index fa868bef..c697af7f 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -17,6 +17,12 @@ jobs: image: planqk/workflow-engine-test:v1.0.0 ports: - 8090:8090 + env: + POSTGRES_USERS: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' + POSTGRES_DATABASES: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' + QC_ATLAS_CONTENT_REPOSITORY_BRANCH: 'master' + ATLAS_DB: planqk + PATTERNATLAS_DB: patternatlas ### End of Workflow Deployment Test Setup ### ### Pattern-based Test Setup ### From e8761c39b98adbfa68a2dfdddac0523574b5ca72 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:31:29 +0200 Subject: [PATCH 43/74] Move env to corresct container --- .github/workflows/run-npm-test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index c697af7f..7f1c6945 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -17,12 +17,6 @@ jobs: image: planqk/workflow-engine-test:v1.0.0 ports: - 8090:8090 - env: - POSTGRES_USERS: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' - POSTGRES_DATABASES: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' - QC_ATLAS_CONTENT_REPOSITORY_BRANCH: 'master' - ATLAS_DB: planqk - PATTERNATLAS_DB: patternatlas ### End of Workflow Deployment Test Setup ### ### Pattern-based Test Setup ### @@ -30,6 +24,12 @@ jobs: image: planqk/db-test:v1.1.0 ports: - 5060:5060 + env: + POSTGRES_USERS: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' + POSTGRES_DATABASES: 'planqk:planqk|patternatlas:patternatlas|qprov:qprov' + QC_ATLAS_CONTENT_REPOSITORY_BRANCH: 'master' + ATLAS_DB: planqk + PATTERNATLAS_DB: patternatlas pattern-atlas-api: image: patternatlas/pattern-atlas-api:v1.9.0 From 830884ef94ad2558e02fe6da4095c992bd2b8bdd Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:41:18 +0200 Subject: [PATCH 44/74] Add endpoint for Latex renderer --- .github/workflows/run-npm-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 7f1c6945..8cddb579 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -42,6 +42,8 @@ jobs: JDBC_DATABASE_PORT: 5060 DB_INIT_USER: patternatlas DB_INIT_PASSWORD: patternatlas + LATEX_RENDERER_HOST_NAME: latex-renderer + LATEX_RENDERER_PORT: 5030 JDBC_DATABASE_NAME: patternatlas PATTERN_ATLAS_FETCH_INITIAL_DATA: 'true' HAL_EXPLORER: 'false' From ed708c8dbea43ac5f075d6b971e43d3e790f9abb Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 16:55:55 +0200 Subject: [PATCH 45/74] Log status code --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 6cfc29fd..4d35a39b 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -340,6 +340,7 @@ export async function findPatternIdByName(patternType) { getPatternAtlasEndpoint() + "/patterns" ); console.log("Response: ", response); + console.log("Status code: ", response.status); let patterns = response._embedded.patternModels; console.log("Available patterns: ", patterns); From 1a1f9b5a87c9ef5822f8cd1606cba035c79d136d Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:10:14 +0200 Subject: [PATCH 46/74] Add log for wf deployment --- components/bpmn-q/modeler-component/editor/util/IoUtilities.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js index af76cb2f..b9a048fd 100644 --- a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js @@ -291,6 +291,7 @@ export async function deployWorkflowToCamunda( // make the request and wait for the response of the deployment endpoint try { + console.log("Deploying to Camunda Engine: ", editorConfig.getCamundaEndpoint() + "/deployment/create"); const response = await fetch( editorConfig.getCamundaEndpoint() + "/deployment/create", { From 1228ce573c217d2c34496d2e7e7fbbda3146b89e Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:14:22 +0200 Subject: [PATCH 47/74] Run linter --- .../bpmn-q/modeler-component/editor/util/IoUtilities.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js index b9a048fd..249020a4 100644 --- a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js @@ -291,7 +291,10 @@ export async function deployWorkflowToCamunda( // make the request and wait for the response of the deployment endpoint try { - console.log("Deploying to Camunda Engine: ", editorConfig.getCamundaEndpoint() + "/deployment/create"); + console.log( + "Deploying to Camunda Engine: ", + editorConfig.getCamundaEndpoint() + "/deployment/create" + ); const response = await fetch( editorConfig.getCamundaEndpoint() + "/deployment/create", { From 8c731a011ea0983b382e1af97a061587afb31292 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:19:30 +0200 Subject: [PATCH 48/74] Adapt pattern endpoints --- .../bpmn-q/test/tests/pattern/pattern-config.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-config.spec.js b/components/bpmn-q/test/tests/pattern/pattern-config.spec.js index a5d9f80a..c55e3e81 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-config.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-config.spec.js @@ -18,20 +18,20 @@ describe("Test Pattern ConfigManager", function () { name: "pattern", config: { patternAtlasEndpoint: - "http://test:1977/patternatlas/patternLanguages/af7780d5-1f97-4536-8da7-4194b093ab1d", - patternAtlasUIEndpoint: "http://test:1978", - qcAtlasEndpoint: "http://test:6626", + "http://localhost:1977/patternatlas/patternLanguages/af7780d5-1f97-4536-8da7-4194b093ab1d", + patternAtlasUIEndpoint: "http://localhost:1978", + qcAtlasEndpoint: "http://localhost:6626", }, }, ]); expect(patternConfig.getPatternAtlasEndpoint()).to.equal( - "http://test:1977/patternatlas/patternLanguages/af7780d5-1f97-4536-8da7-4194b093ab1d" + "http://localhost:1977/patternatlas/patternLanguages/af7780d5-1f97-4536-8da7-4194b093ab1d" ); expect(patternConfig.getPatternAtlasUIEndpoint()).to.equal( - "http://test:1978" + "http://localhost:1978" ); - expect(patternConfig.getQcAtlasEndpoint()).to.equal("http://test:6626"); + expect(patternConfig.getQcAtlasEndpoint()).to.equal("http://localhost:6626"); }); }); }); From 60788fc1c28682437ca1d0bf9d468d2a46f0b88d Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:21:07 +0200 Subject: [PATCH 49/74] Run linter --- components/bpmn-q/test/tests/pattern/pattern-config.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-config.spec.js b/components/bpmn-q/test/tests/pattern/pattern-config.spec.js index c55e3e81..1e8bd4bf 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-config.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-config.spec.js @@ -31,7 +31,9 @@ describe("Test Pattern ConfigManager", function () { expect(patternConfig.getPatternAtlasUIEndpoint()).to.equal( "http://localhost:1978" ); - expect(patternConfig.getQcAtlasEndpoint()).to.equal("http://localhost:6626"); + expect(patternConfig.getQcAtlasEndpoint()).to.equal( + "http://localhost:6626" + ); }); }); }); From 267636d2d337602503b5da9b4137285135842dfc Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:31:11 +0200 Subject: [PATCH 50/74] Add additional logging --- .../extensions/pattern/replacement/PatternTransformator.js | 6 +++++- .../test/tests/pattern/pattern-transformation.spec.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 80f0ded7..01abf904 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -214,10 +214,14 @@ export async function startPatternReplacementProcess(xml) { " failed. Aborting process!", }; } + console.log( + "Successfully replaced augmentation pattern with id: ", + replacementConstruct.task.id + ); } let elementsToDelete = patterns.concat(allFlow); - console.log("df"); + console.log("Applying behavioral patterns..."); console.log(elementsToDelete); modeling.removeElements(elementsToDelete); const optimizationCandidates = await findOptimizationCandidates(modeler); diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 0fdd4fee..635d3b2f 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -19,6 +19,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () const transformationResult = await startPatternReplacementProcess( validPatternDiagram ); + console.log("Pattern replacement terminated!"); chai.expect(transformationResult.status).to.equal("transformed"); chai From 8a4beca732432dbc47718fbf31f694294aca98f2 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:35:33 +0200 Subject: [PATCH 51/74] Add logging --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 635d3b2f..5f6ce5d1 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -35,6 +35,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () .expect(transformationResult.xml) .to.contain(" Date: Wed, 15 May 2024 17:44:01 +0200 Subject: [PATCH 52/74] Add done statement --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 5f6ce5d1..0b0f92e1 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -15,7 +15,7 @@ const { const { instantiateModeler } = require("../helpers/ModelerHelper"); describe("Test the PatternTransformator of the Pattern extension.", function () { describe("Transformation of Pattern extensions", function () { - it("should replace all patterns by quantme modeling constructs", async function () { + it("should replace all patterns by quantme modeling constructs", async function (done) { const transformationResult = await startPatternReplacementProcess( validPatternDiagram ); @@ -76,6 +76,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () .to.equal(RESULT_EVALUATION_TASK); } console.log("Pattern test terminated!"); + done(); } }); }); From 28813333fa7fcafd690cec248375788ba877ff7b Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:50:32 +0200 Subject: [PATCH 53/74] Increase timeout --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 0b0f92e1..193b6c24 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -78,6 +78,6 @@ describe("Test the PatternTransformator of the Pattern extension.", function () console.log("Pattern test terminated!"); done(); } - }); + }).timeout(10000); }); }); From 63efa4003a2891c985dde2cef8d15a73caa6fc7c Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:54:26 +0200 Subject: [PATCH 54/74] Remove done() --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 193b6c24..75cfe8a8 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -15,7 +15,7 @@ const { const { instantiateModeler } = require("../helpers/ModelerHelper"); describe("Test the PatternTransformator of the Pattern extension.", function () { describe("Transformation of Pattern extensions", function () { - it("should replace all patterns by quantme modeling constructs", async function (done) { + it("should replace all patterns by quantme modeling constructs", async function () { const transformationResult = await startPatternReplacementProcess( validPatternDiagram ); @@ -76,7 +76,6 @@ describe("Test the PatternTransformator of the Pattern extension.", function () .to.equal(RESULT_EVALUATION_TASK); } console.log("Pattern test terminated!"); - done(); } }).timeout(10000); }); From 89cc77e12667250bc99f7b63ada3943988b055c6 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 17:58:25 +0200 Subject: [PATCH 55/74] Remove log --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 4d35a39b..6cfc29fd 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -340,7 +340,6 @@ export async function findPatternIdByName(patternType) { getPatternAtlasEndpoint() + "/patterns" ); console.log("Response: ", response); - console.log("Status code: ", response.status); let patterns = response._embedded.patternModels; console.log("Available patterns: ", patterns); From 0cb62fc1a5429ddf1d7b316cd322b0a7b3c75175 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Wed, 15 May 2024 18:00:45 +0200 Subject: [PATCH 56/74] Add TODO for test case --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 75cfe8a8..2e1b9230 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -76,6 +76,8 @@ describe("Test the PatternTransformator of the Pattern extension.", function () .to.equal(RESULT_EVALUATION_TASK); } console.log("Pattern test terminated!"); + + // TODO: add transformation + check result } }).timeout(10000); }); From 60c7c5f4bcbee030bc3b4e6202bca03f544092a1 Mon Sep 17 00:00:00 2001 From: mbeisel Date: Thu, 16 May 2024 18:42:02 +0200 Subject: [PATCH 57/74] adding funcitionalty for inserting concrete solutions from qc-atlas for augmentation patterns --- .../editor/util/HttpUtilities.js | 4 +- .../replacement/PatternTransformator.js | 44 +++++++-- .../ErrorCorrectionPatternHandler.js | 10 +- .../cutting/CuttingPatternHandler.js | 25 ++++- .../mitigation/MitigationPatternHandler.js | 10 +- .../warm-start/WarmStartPatternHandler.js | 8 +- .../ui/pattern-selection/ProgressBarModal.js | 3 +- .../extensions/pattern/util/PatternUtil.js | 97 ++++++++++++++++--- .../QuantMEPropertiesProvider.js | 6 +- 9 files changed, 173 insertions(+), 34 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js index 0c015160..37534414 100644 --- a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js @@ -18,12 +18,12 @@ import $ from "jquery"; * @param method * @returns */ -export async function fetchDataFromEndpoint(endpoint, method = "GET") { +export async function fetchDataFromEndpoint(endpoint, method = "GET", acceptHeader = ["application/json", "application/hal+json"]) { try { const response = await fetch(endpoint, { method: method, headers: { - Accept: ["application/json", "application/hal+json"], + Accept: acceptHeader, }, }); if (!response.ok) { diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 01abf904..9d7e4d2e 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -89,10 +89,24 @@ export async function startPatternReplacementProcess(xml) { replacementConstruct.task.$type === constants.READOUT_ERROR_MITIGATION || replacementConstruct.task.$type === constants.GATE_ERROR_MITIGATION ) { + let patternId = replacementConstruct.task.patternId; + if (!patternId) { + console.log( + "Pattern ID undefined. Trying to retrieve via pattern name..." + ); + patternId = await findPatternIdByName(replacementConstruct.task.$type); + console.log("Retrieved pattern ID: ", patternId); + } + + // retrieve solution for pattern to enable correct configuration + let matchingDetectorMap = await getSolutionForPattern(patternId); + console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); + let { replaced, flows, pattern } = await replaceMitigationPattern( replacementConstruct.task, replacementConstruct.parent, - modeler + modeler, + matchingDetectorMap ); allFlow = allFlow.concat(flows); patterns.push(pattern); @@ -115,10 +129,25 @@ export async function startPatternReplacementProcess(xml) { if ( constants.WARM_STARTING_PATTERNS.includes(replacementConstruct.task.$type) ) { + + let patternId = replacementConstruct.task.patternId; + if (!patternId) { + console.log( + "Pattern ID undefined. Trying to retrieve via pattern name..." + ); + patternId = await findPatternIdByName(replacementConstruct.task.$type); + console.log("Retrieved pattern ID: ", patternId); + } + + // retrieve solution for pattern to enable correct configuration + let matchingDetectorMap = await getSolutionForPattern(patternId); + console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); + let { replaced, flows, pattern } = await replaceWarmStart( replacementConstruct.task, replacementConstruct.parent, - modeler + modeler, + matchingDetectorMap ); allFlow = allFlow.concat(flows); patterns.push(pattern); @@ -170,9 +199,8 @@ export async function startPatternReplacementProcess(xml) { } // retrieve solution for pattern to enable correct configuration - let concreteSolution = getSolutionForPattern(patternId); - console.log("Solution: ", concreteSolution); - + let matchingDetectorMap = await getSolutionForPattern(patternId); + console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); // TODO: load detector from solution and configure inserted task // TODO: incorporate augmentation patterns handled above @@ -181,7 +209,8 @@ export async function startPatternReplacementProcess(xml) { let { replaced, flows, pattern } = await replaceCuttingPattern( replacementConstruct.task, replacementConstruct.parent, - modeler + modeler, + matchingDetectorMap ); allFlow = allFlow.concat(flows); patterns.push(pattern); @@ -193,7 +222,8 @@ export async function startPatternReplacementProcess(xml) { let { replaced, flows, pattern } = await replaceErrorCorrectionPattern( replacementConstruct.task, replacementConstruct.parent, - modeler + modeler, + matchingDetectorMap ); allFlow = allFlow.concat(flows); patterns.push(pattern); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js index 80ee96cf..70c27089 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js @@ -9,6 +9,8 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; +import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import {copyQuantMEProperties} from "../../util/PatternUtil"; /** * Replace the given error correction pattern by a quantme error correction task @@ -16,7 +18,8 @@ import * as quantmeConsts from "../../../quantme/Constants"; export async function replaceErrorCorrectionPattern( errorCorrectionPattern, parent, - modeler + modeler, + matchingDetectorMap ) { console.log( "Replace error correction pattern " + @@ -24,6 +27,10 @@ export async function replaceErrorCorrectionPattern( "of parent " + parent.id ); + + const ecDetector = matchingDetectorMap[quantmeConsts.ERROR_CORRECTION_TASK]; + let propertiesEC = QuantMEProps(ecDetector); + let modeling = modeler.get("modeling"); let elementRegistry = modeler.get("elementRegistry"); let internHost = elementRegistry.get(errorCorrectionPattern.id).host; @@ -33,6 +40,7 @@ export async function replaceErrorCorrectionPattern( parent, {} ); + copyQuantMEProperties(propertiesEC, ecDetector, errorCorrectionTask, modeler); let startEventBo = elementRegistry.get(errorCorrectionTask.id).businessObject; startEventBo.name = "Correct Errors"; let flows = []; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js index fd863c7a..cf4d12e7 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js @@ -9,11 +9,14 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; +import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import {copyQuantMEProperties} from "../../util/PatternUtil"; + /** * Replace the cutting pattern by quantme modeling constructs */ -export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { +export async function replaceCuttingPattern(cuttingPattern, parent, modeler, matchingDetectorMap) { console.log( "Replace cutting pattern " + cuttingPattern.id + "of parent " + parent.id ); @@ -21,6 +24,12 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { let elementRegistry = modeler.get("elementRegistry"); let host = elementRegistry.get(cuttingPattern.id).host; + + const cuttingDetector = matchingDetectorMap[quantmeConsts.CIRCUIT_CUTTING_TASK]; + const combinationDetector = matchingDetectorMap[quantmeConsts.CUTTING_RESULT_COMBINATION_TASK]; + let propertiesCutting = QuantMEProps(cuttingDetector); + let propertiesCombination = QuantMEProps(combinationDetector); + let flows = []; let cuttingTask = modeling.createShape( { type: quantmeConsts.CIRCUIT_CUTTING_TASK }, @@ -28,16 +37,22 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { parent, {} ); + + copyQuantMEProperties(propertiesCutting, cuttingDetector, cuttingTask, modeler); + + let startEventBo = elementRegistry.get(cuttingTask.id).businessObject; startEventBo.name = "Cut Circuit"; - let resultCombinationTaks = modeling.createShape( + let resultCombinationTask = modeling.createShape( { type: quantmeConsts.CUTTING_RESULT_COMBINATION_TASK }, { x: 50, y: 50 }, parent, {} ); - startEventBo = elementRegistry.get(resultCombinationTaks.id).businessObject; + copyQuantMEProperties(propertiesCombination, combinationDetector, resultCombinationTask, modeler); + + startEventBo = elementRegistry.get(resultCombinationTask.id).businessObject; startEventBo.name = "Combine Circuits"; host.incoming.forEach((element) => { @@ -52,12 +67,12 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler) { host.outgoing.forEach((element) => { flows.push(elementRegistry.get(element.id)); modeling.connect( - resultCombinationTaks, + resultCombinationTask, elementRegistry.get(element.target.id), { type: "bpmn:SequenceFlow" } ); }); - modeling.connect(host, resultCombinationTaks, { + modeling.connect(host, resultCombinationTask, { type: "bpmn:SequenceFlow", }); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js index e0dcbad9..4e2a8851 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js @@ -10,6 +10,8 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import * as consts from "../../Constants"; +import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import {copyQuantMEProperties} from "../../util/PatternUtil"; /** * Replace the given mitigation by a quantme modeling construct @@ -17,7 +19,8 @@ import * as consts from "../../Constants"; export async function replaceMitigationPattern( mitigationPattern, parent, - modeler + modeler, + matchingDetectorMap ) { console.log( "Replace mitigation pattern " + @@ -25,6 +28,10 @@ export async function replaceMitigationPattern( "of parent " + parent.id ); + + const remDetector = matchingDetectorMap[quantmeConsts.READOUT_ERROR_MITIGATION_TASK]; + let propertiesREM = QuantMEProps(remDetector); + let modeling = modeler.get("modeling"); let elementRegistry = modeler.get("elementRegistry"); let host = elementRegistry.get(mitigationPattern.id).host; @@ -41,6 +48,7 @@ export async function replaceMitigationPattern( parent, {} ); + copyQuantMEProperties(propertiesREM, remDetector, mitigationTask, modeler); let readoutMitigationTaskBo = elementRegistry.get( mitigationTask.id ).businessObject; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js index 4e6b5d7f..4bcd621e 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js @@ -10,17 +10,22 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import { PATTERN_PREFIX } from "../../Constants"; +import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import {copyQuantMEProperties} from "../../util/PatternUtil"; /** * Replace the given warm start pattern by a quantme warm starting task */ -export async function replaceWarmStart(warmStartPattern, parent, modeler) { +export async function replaceWarmStart(warmStartPattern, parent, modeler, matchingDetectorMap) { console.log( "Replace warm start pattern " + warmStartPattern.id + "of parent " + parent.id ); + const warmstartingDetector = matchingDetectorMap[quantmeConsts.WARM_STARTING_TASK]; + let propertiesWarmStart = QuantMEProps(warmstartingDetector); + let modeling = modeler.get("modeling"); let elementRegistry = modeler.get("elementRegistry"); let host = elementRegistry.get(warmStartPattern.id).host; @@ -32,6 +37,7 @@ export async function replaceWarmStart(warmStartPattern, parent, modeler) { parent, {} ); + copyQuantMEProperties(propertiesWarmStart, warmstartingDetector, warmStartTask, modeler); let warmStartTaskBo = elementRegistry.get(warmStartTask.id).businessObject; warmStartTaskBo.name = "Warm Start"; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/ProgressBarModal.js b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/ProgressBarModal.js index 4102fa00..13c991ad 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/ProgressBarModal.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/ui/pattern-selection/ProgressBarModal.js @@ -50,7 +50,8 @@ const ProgressBarModal = ({ responseData, selectedPatterns, onClose }) => { ); if (response && response.content.length > 0) { - // currently takes the first solution + // currently takes the first concrete solution + let solutionId = response.content[0].id; const solutionPackage = await fetchSolutionFromEndpoint( `${qcAtlasEndpoint}/atlas/algorithms/${implementedAlgorithmId}/implementations/${id}/implementation-packages/${solutionId}/file/content` diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 6cfc29fd..333794a6 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -9,16 +9,17 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as consts from "../Constants"; -import * as quantmeConsts from "../../quantme/Constants"; -import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; import * as constants from "../Constants"; -import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; -import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; -import { - getPatternAtlasEndpoint, - getQcAtlasEndpoint, -} from "../framework-config/config-manager"; -import { fetchDataFromEndpoint } from "../../../editor/util/HttpUtilities"; +import {PATTERN_ID, PATTERN_PREFIX} from "../Constants"; +import * as quantmeConsts from "../../quantme/Constants"; +import {computeDimensionsOfSubprocess} from "../../quantme/replacement/layouter/Layouter"; +import {isQuantMESubprocess} from "../../quantme/utilities/Utilities"; +import {getPatternAtlasEndpoint, getQcAtlasEndpoint,} from "../framework-config/config-manager"; +import {fetchDataFromEndpoint} from "../../../editor/util/HttpUtilities"; +import JSZip from "jszip"; +import {saveFileFormats} from "../../../editor/EditorConstants"; +import {createTempModelerFromXml} from "../../../editor/ModelerHandler"; +import {getRootProcess} from "../../../editor/util/ModellingUtilities"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); @@ -305,20 +306,69 @@ export function removeAlgorithmAndAugmentationPatterns( } } +async function retrieveTaskTypeSolutionMap(files, taskTypeSolutionMap) { + for (const [fileName, file] of files) { + console.log("Searching file with name: ", fileName); + if (!file.dir && fileName.endsWith(saveFileFormats.ZIP)){ + console.log("ZIP detected"); + let zip = await JSZip.loadAsync(await file.async("blob")); + const retrievedSolutionMap = await retrieveTaskTypeSolutionMap(Object.entries(zip.files), taskTypeSolutionMap); + taskTypeSolutionMap = Object.assign({}, taskTypeSolutionMap, retrievedSolutionMap); + } + if (fileName.endsWith("detector.bpmn")) { + console.log("Identified detector with name ", fileName); + let tempModeler = await createTempModelerFromXml(await file.async("text")); + let rootElement = getRootProcess(tempModeler.getDefinitions()); + if (rootElement.flowElements.length !== 1) { + console.warn("Detector invalid - Detector must contain exactly 1 modeling construct"); + continue; + } + taskTypeSolutionMap[rootElement.flowElements[0].$type] = rootElement.flowElements[0]; + + } + } + console.log("taskTypeSolutionMap ", taskTypeSolutionMap); + return taskTypeSolutionMap; +} + /** * Get the solution for the given pattern * * @param id the ID of the solution to retrieve the pattern for */ -export function getSolutionForPattern(id) { +export async function getSolutionForPattern(id) { console.log("Retrieving solution for pattern with ID: ", id); const qcAtlasEndpoint = getQcAtlasEndpoint(); - let endpoint = qcAtlasEndpoint + "/TODO/" + id; - console.log("Retrieving solutions from URL: ", endpoint); + const qcAtlasSolutionEndpoint = qcAtlasEndpoint + "/atlas/solutions"; + console.log("Retrieving solutions from URL: ", qcAtlasSolutionEndpoint); + let listOfSolutions = await fetchDataFromEndpoint(qcAtlasSolutionEndpoint); + console.log("Retrieved solutions: {}", listOfSolutions); + listOfSolutions = listOfSolutions.content.filter( (solution) => + id === solution.patternId && "QRM" === solution.solutionType); + console.log("Retrieved matching solutions: {}", listOfSolutions); + - // TODO - return undefined; + if (!listOfSolutions || listOfSolutions.length < 1) { + console.warn("Unable to find QRM-based solution for pattern: ", id); + return undefined; + } else { + const qrmSolutionEndpoint = qcAtlasSolutionEndpoint + "/" + listOfSolutions[0].id + "/file/content"; + console.log("Retrieving QRM from URL: ", qrmSolutionEndpoint); + const qrm = await fetch(qrmSolutionEndpoint); + let blob = await qrm.blob(); + + console.log("Found QRM with content {}", blob); + let zip = await JSZip.loadAsync(blob); + + // Iterate over each file in the zip + let files = Object.entries(zip.files); + console.log("Zip comprises %i files!", files.length); + + let taskTypeSolutionMap = await retrieveTaskTypeSolutionMap(files, {}); + console.log(taskTypeSolutionMap); + return taskTypeSolutionMap; + } } /** @@ -358,3 +408,22 @@ export async function findPatternIdByName(patternType) { return filteredPatterns[0].id; } } + +export function copyQuantMEProperties(quantMEProperties, sourceTask, targetTask, modeler){ + let modeling = modeler.get("modeling"); + let elementRegistry = modeler.get("elementRegistry"); + if (quantMEProperties !== undefined) { + let propertyEntries = {}; + quantMEProperties.forEach((propertyEntry) => { + let entryId = propertyEntry.id; + let entry = sourceTask[entryId]; + entry = entry !== undefined && entry.includes(",") ? entry.split(",")[0] : entry; + propertyEntries[entryId] = entry; + }); + console.log("properties", propertyEntries); + modeling.updateProperties( + elementRegistry.get(targetTask.id), + propertyEntries + ); + } +} diff --git a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js index 36bfcd87..dcf81c05 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js @@ -21,6 +21,7 @@ import { ErrorCorrectionTaskEntries, } from "./QuantMETaskProperties"; import { DeploymentModelProps } from "./DeploymentModelProps"; +import {getType} from "../../../../editor/util/ModellingUtilities"; const LOW_PRIORITY = 600; @@ -95,8 +96,9 @@ function createQuantMEGroup(element, translate) { * * @param element the QuantME element */ -function QuantMEProps(element) { - switch (element.type) { +export function QuantMEProps(element) { + console.log("Element for props: ", element); + switch (getType(element)) { case consts.QUANTUM_COMPUTATION_TASK: return QuantumComputationTaskProperties(element); From 12eb9181872122aece185b131c0473c2308cbbcd Mon Sep 17 00:00:00 2001 From: mbeisel Date: Thu, 16 May 2024 18:45:17 +0200 Subject: [PATCH 58/74] linting --- .../editor/util/HttpUtilities.js | 6 +- .../replacement/PatternTransformator.js | 23 +++++-- .../ErrorCorrectionPatternHandler.js | 4 +- .../cutting/CuttingPatternHandler.js | 33 ++++++--- .../mitigation/MitigationPatternHandler.js | 7 +- .../warm-start/WarmStartPatternHandler.js | 21 ++++-- .../extensions/pattern/util/PatternUtil.js | 69 ++++++++++++------- .../QuantMEPropertiesProvider.js | 2 +- 8 files changed, 115 insertions(+), 50 deletions(-) diff --git a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js index 37534414..fc8f5ae0 100644 --- a/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/HttpUtilities.js @@ -18,7 +18,11 @@ import $ from "jquery"; * @param method * @returns */ -export async function fetchDataFromEndpoint(endpoint, method = "GET", acceptHeader = ["application/json", "application/hal+json"]) { +export async function fetchDataFromEndpoint( + endpoint, + method = "GET", + acceptHeader = ["application/json", "application/hal+json"] +) { try { const response = await fetch(endpoint, { method: method, diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 9d7e4d2e..27384b1a 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -92,7 +92,7 @@ export async function startPatternReplacementProcess(xml) { let patternId = replacementConstruct.task.patternId; if (!patternId) { console.log( - "Pattern ID undefined. Trying to retrieve via pattern name..." + "Pattern ID undefined. Trying to retrieve via pattern name..." ); patternId = await findPatternIdByName(replacementConstruct.task.$type); console.log("Retrieved pattern ID: ", patternId); @@ -100,7 +100,11 @@ export async function startPatternReplacementProcess(xml) { // retrieve solution for pattern to enable correct configuration let matchingDetectorMap = await getSolutionForPattern(patternId); - console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); + console.log( + "matchingDetectorMap for pattern: ", + matchingDetectorMap, + patternId + ); let { replaced, flows, pattern } = await replaceMitigationPattern( replacementConstruct.task, @@ -129,11 +133,10 @@ export async function startPatternReplacementProcess(xml) { if ( constants.WARM_STARTING_PATTERNS.includes(replacementConstruct.task.$type) ) { - let patternId = replacementConstruct.task.patternId; if (!patternId) { console.log( - "Pattern ID undefined. Trying to retrieve via pattern name..." + "Pattern ID undefined. Trying to retrieve via pattern name..." ); patternId = await findPatternIdByName(replacementConstruct.task.$type); console.log("Retrieved pattern ID: ", patternId); @@ -141,7 +144,11 @@ export async function startPatternReplacementProcess(xml) { // retrieve solution for pattern to enable correct configuration let matchingDetectorMap = await getSolutionForPattern(patternId); - console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); + console.log( + "matchingDetectorMap for pattern: ", + matchingDetectorMap, + patternId + ); let { replaced, flows, pattern } = await replaceWarmStart( replacementConstruct.task, @@ -200,7 +207,11 @@ export async function startPatternReplacementProcess(xml) { // retrieve solution for pattern to enable correct configuration let matchingDetectorMap = await getSolutionForPattern(patternId); - console.log("matchingDetectorMap for pattern: ", matchingDetectorMap, patternId); + console.log( + "matchingDetectorMap for pattern: ", + matchingDetectorMap, + patternId + ); // TODO: load detector from solution and configure inserted task // TODO: incorporate augmentation patterns handled above diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js index 70c27089..4e1e439d 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/correction/ErrorCorrectionPatternHandler.js @@ -9,8 +9,8 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; -import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; -import {copyQuantMEProperties} from "../../util/PatternUtil"; +import { QuantMEProps } from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import { copyQuantMEProperties } from "../../util/PatternUtil"; /** * Replace the given error correction pattern by a quantme error correction task diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js index cf4d12e7..f6621e75 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/cutting/CuttingPatternHandler.js @@ -9,14 +9,18 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as quantmeConsts from "../../../quantme/Constants"; -import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; -import {copyQuantMEProperties} from "../../util/PatternUtil"; - +import { QuantMEProps } from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import { copyQuantMEProperties } from "../../util/PatternUtil"; /** * Replace the cutting pattern by quantme modeling constructs */ -export async function replaceCuttingPattern(cuttingPattern, parent, modeler, matchingDetectorMap) { +export async function replaceCuttingPattern( + cuttingPattern, + parent, + modeler, + matchingDetectorMap +) { console.log( "Replace cutting pattern " + cuttingPattern.id + "of parent " + parent.id ); @@ -25,8 +29,10 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler, mat let host = elementRegistry.get(cuttingPattern.id).host; - const cuttingDetector = matchingDetectorMap[quantmeConsts.CIRCUIT_CUTTING_TASK]; - const combinationDetector = matchingDetectorMap[quantmeConsts.CUTTING_RESULT_COMBINATION_TASK]; + const cuttingDetector = + matchingDetectorMap[quantmeConsts.CIRCUIT_CUTTING_TASK]; + const combinationDetector = + matchingDetectorMap[quantmeConsts.CUTTING_RESULT_COMBINATION_TASK]; let propertiesCutting = QuantMEProps(cuttingDetector); let propertiesCombination = QuantMEProps(combinationDetector); @@ -38,8 +44,12 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler, mat {} ); - copyQuantMEProperties(propertiesCutting, cuttingDetector, cuttingTask, modeler); - + copyQuantMEProperties( + propertiesCutting, + cuttingDetector, + cuttingTask, + modeler + ); let startEventBo = elementRegistry.get(cuttingTask.id).businessObject; startEventBo.name = "Cut Circuit"; @@ -50,7 +60,12 @@ export async function replaceCuttingPattern(cuttingPattern, parent, modeler, mat parent, {} ); - copyQuantMEProperties(propertiesCombination, combinationDetector, resultCombinationTask, modeler); + copyQuantMEProperties( + propertiesCombination, + combinationDetector, + resultCombinationTask, + modeler + ); startEventBo = elementRegistry.get(resultCombinationTask.id).businessObject; startEventBo.name = "Combine Circuits"; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js index 4e2a8851..d62015f7 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/mitigation/MitigationPatternHandler.js @@ -10,8 +10,8 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import * as consts from "../../Constants"; -import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; -import {copyQuantMEProperties} from "../../util/PatternUtil"; +import { QuantMEProps } from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import { copyQuantMEProperties } from "../../util/PatternUtil"; /** * Replace the given mitigation by a quantme modeling construct @@ -29,7 +29,8 @@ export async function replaceMitigationPattern( parent.id ); - const remDetector = matchingDetectorMap[quantmeConsts.READOUT_ERROR_MITIGATION_TASK]; + const remDetector = + matchingDetectorMap[quantmeConsts.READOUT_ERROR_MITIGATION_TASK]; let propertiesREM = QuantMEProps(remDetector); let modeling = modeler.get("modeling"); diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js index 4bcd621e..eecbe754 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/warm-start/WarmStartPatternHandler.js @@ -10,20 +10,26 @@ */ import * as quantmeConsts from "../../../quantme/Constants"; import { PATTERN_PREFIX } from "../../Constants"; -import {QuantMEProps} from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; -import {copyQuantMEProperties} from "../../util/PatternUtil"; +import { QuantMEProps } from "../../../quantme/modeling/properties-provider/QuantMEPropertiesProvider"; +import { copyQuantMEProperties } from "../../util/PatternUtil"; /** * Replace the given warm start pattern by a quantme warm starting task */ -export async function replaceWarmStart(warmStartPattern, parent, modeler, matchingDetectorMap) { +export async function replaceWarmStart( + warmStartPattern, + parent, + modeler, + matchingDetectorMap +) { console.log( "Replace warm start pattern " + warmStartPattern.id + "of parent " + parent.id ); - const warmstartingDetector = matchingDetectorMap[quantmeConsts.WARM_STARTING_TASK]; + const warmstartingDetector = + matchingDetectorMap[quantmeConsts.WARM_STARTING_TASK]; let propertiesWarmStart = QuantMEProps(warmstartingDetector); let modeling = modeler.get("modeling"); @@ -37,7 +43,12 @@ export async function replaceWarmStart(warmStartPattern, parent, modeler, matchi parent, {} ); - copyQuantMEProperties(propertiesWarmStart, warmstartingDetector, warmStartTask, modeler); + copyQuantMEProperties( + propertiesWarmStart, + warmstartingDetector, + warmStartTask, + modeler + ); let warmStartTaskBo = elementRegistry.get(warmStartTask.id).businessObject; warmStartTaskBo.name = "Warm Start"; diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 333794a6..c3969d65 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -10,16 +10,19 @@ */ import * as consts from "../Constants"; import * as constants from "../Constants"; -import {PATTERN_ID, PATTERN_PREFIX} from "../Constants"; +import { PATTERN_ID, PATTERN_PREFIX } from "../Constants"; import * as quantmeConsts from "../../quantme/Constants"; -import {computeDimensionsOfSubprocess} from "../../quantme/replacement/layouter/Layouter"; -import {isQuantMESubprocess} from "../../quantme/utilities/Utilities"; -import {getPatternAtlasEndpoint, getQcAtlasEndpoint,} from "../framework-config/config-manager"; -import {fetchDataFromEndpoint} from "../../../editor/util/HttpUtilities"; +import { computeDimensionsOfSubprocess } from "../../quantme/replacement/layouter/Layouter"; +import { isQuantMESubprocess } from "../../quantme/utilities/Utilities"; +import { + getPatternAtlasEndpoint, + getQcAtlasEndpoint, +} from "../framework-config/config-manager"; +import { fetchDataFromEndpoint } from "../../../editor/util/HttpUtilities"; import JSZip from "jszip"; -import {saveFileFormats} from "../../../editor/EditorConstants"; -import {createTempModelerFromXml} from "../../../editor/ModelerHandler"; -import {getRootProcess} from "../../../editor/util/ModellingUtilities"; +import { saveFileFormats } from "../../../editor/EditorConstants"; +import { createTempModelerFromXml } from "../../../editor/ModelerHandler"; +import { getRootProcess } from "../../../editor/util/ModellingUtilities"; export function attachPatternsToSubprocess(subprocess, patterns, modeling) { let dimensions = computeDimensionsOfSubprocess(subprocess); @@ -309,22 +312,33 @@ export function removeAlgorithmAndAugmentationPatterns( async function retrieveTaskTypeSolutionMap(files, taskTypeSolutionMap) { for (const [fileName, file] of files) { console.log("Searching file with name: ", fileName); - if (!file.dir && fileName.endsWith(saveFileFormats.ZIP)){ + if (!file.dir && fileName.endsWith(saveFileFormats.ZIP)) { console.log("ZIP detected"); let zip = await JSZip.loadAsync(await file.async("blob")); - const retrievedSolutionMap = await retrieveTaskTypeSolutionMap(Object.entries(zip.files), taskTypeSolutionMap); - taskTypeSolutionMap = Object.assign({}, taskTypeSolutionMap, retrievedSolutionMap); + const retrievedSolutionMap = await retrieveTaskTypeSolutionMap( + Object.entries(zip.files), + taskTypeSolutionMap + ); + taskTypeSolutionMap = Object.assign( + {}, + taskTypeSolutionMap, + retrievedSolutionMap + ); } if (fileName.endsWith("detector.bpmn")) { console.log("Identified detector with name ", fileName); - let tempModeler = await createTempModelerFromXml(await file.async("text")); + let tempModeler = await createTempModelerFromXml( + await file.async("text") + ); let rootElement = getRootProcess(tempModeler.getDefinitions()); if (rootElement.flowElements.length !== 1) { - console.warn("Detector invalid - Detector must contain exactly 1 modeling construct"); + console.warn( + "Detector invalid - Detector must contain exactly 1 modeling construct" + ); continue; } - taskTypeSolutionMap[rootElement.flowElements[0].$type] = rootElement.flowElements[0]; - + taskTypeSolutionMap[rootElement.flowElements[0].$type] = + rootElement.flowElements[0]; } } console.log("taskTypeSolutionMap ", taskTypeSolutionMap); @@ -344,16 +358,17 @@ export async function getSolutionForPattern(id) { console.log("Retrieving solutions from URL: ", qcAtlasSolutionEndpoint); let listOfSolutions = await fetchDataFromEndpoint(qcAtlasSolutionEndpoint); console.log("Retrieved solutions: {}", listOfSolutions); - listOfSolutions = listOfSolutions.content.filter( (solution) => - id === solution.patternId && "QRM" === solution.solutionType); + listOfSolutions = listOfSolutions.content.filter( + (solution) => id === solution.patternId && "QRM" === solution.solutionType + ); console.log("Retrieved matching solutions: {}", listOfSolutions); - if (!listOfSolutions || listOfSolutions.length < 1) { console.warn("Unable to find QRM-based solution for pattern: ", id); return undefined; } else { - const qrmSolutionEndpoint = qcAtlasSolutionEndpoint + "/" + listOfSolutions[0].id + "/file/content"; + const qrmSolutionEndpoint = + qcAtlasSolutionEndpoint + "/" + listOfSolutions[0].id + "/file/content"; console.log("Retrieving QRM from URL: ", qrmSolutionEndpoint); const qrm = await fetch(qrmSolutionEndpoint); let blob = await qrm.blob(); @@ -409,7 +424,12 @@ export async function findPatternIdByName(patternType) { } } -export function copyQuantMEProperties(quantMEProperties, sourceTask, targetTask, modeler){ +export function copyQuantMEProperties( + quantMEProperties, + sourceTask, + targetTask, + modeler +) { let modeling = modeler.get("modeling"); let elementRegistry = modeler.get("elementRegistry"); if (quantMEProperties !== undefined) { @@ -417,13 +437,16 @@ export function copyQuantMEProperties(quantMEProperties, sourceTask, targetTask, quantMEProperties.forEach((propertyEntry) => { let entryId = propertyEntry.id; let entry = sourceTask[entryId]; - entry = entry !== undefined && entry.includes(",") ? entry.split(",")[0] : entry; + entry = + entry !== undefined && entry.includes(",") + ? entry.split(",")[0] + : entry; propertyEntries[entryId] = entry; }); console.log("properties", propertyEntries); modeling.updateProperties( - elementRegistry.get(targetTask.id), - propertyEntries + elementRegistry.get(targetTask.id), + propertyEntries ); } } diff --git a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js index dcf81c05..af631f84 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/modeling/properties-provider/QuantMEPropertiesProvider.js @@ -21,7 +21,7 @@ import { ErrorCorrectionTaskEntries, } from "./QuantMETaskProperties"; import { DeploymentModelProps } from "./DeploymentModelProps"; -import {getType} from "../../../../editor/util/ModellingUtilities"; +import { getType } from "../../../../editor/util/ModellingUtilities"; const LOW_PRIORITY = 600; From a1799a7ae223fde7818f749d61a4a581613dcee3 Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 11:50:47 +0200 Subject: [PATCH 59/74] fix space removal bug --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index c3969d65..99e375d3 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -411,7 +411,7 @@ export async function findPatternIdByName(patternType) { // search pattern with given name let filteredPatterns = patterns.filter( (pattern) => - patternName.toUpperCase() === pattern.name.replace(" ", "").toUpperCase() + patternName.toUpperCase() === pattern.name.replaceAll(" ", "").toUpperCase() ); console.log("Patterns with given type: ", filteredPatterns); From e2fed94e4d8c2c46d1c4bd4c83084d886374d28a Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 11:56:40 +0200 Subject: [PATCH 60/74] linting --- .../modeler-component/extensions/pattern/util/PatternUtil.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js index 99e375d3..dd9d03b7 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/util/PatternUtil.js @@ -411,7 +411,8 @@ export async function findPatternIdByName(patternType) { // search pattern with given name let filteredPatterns = patterns.filter( (pattern) => - patternName.toUpperCase() === pattern.name.replaceAll(" ", "").toUpperCase() + patternName.toUpperCase() === + pattern.name.replaceAll(" ", "").toUpperCase() ); console.log("Patterns with given type: ", filteredPatterns); From 620ae4511ca14fcdbecc054f5d690d74bcb1747a Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 11:59:30 +0200 Subject: [PATCH 61/74] Remove solved TODOs --- .../extensions/pattern/replacement/PatternTransformator.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js index 27384b1a..382a164d 100644 --- a/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js +++ b/components/bpmn-q/modeler-component/extensions/pattern/replacement/PatternTransformator.js @@ -212,8 +212,6 @@ export async function startPatternReplacementProcess(xml) { matchingDetectorMap, patternId ); - // TODO: load detector from solution and configure inserted task - // TODO: incorporate augmentation patterns handled above let replacementSuccess = false; if (replacementConstruct.task.$type === constants.CIRCUIT_CUTTING) { From 753ad7180343c8f775d6d0c2d31f8d629d44e6c8 Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 12:06:18 +0200 Subject: [PATCH 62/74] update atlas version in compose --- .github/workflows/run-npm-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index 8cddb579..fa8d08ee 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -50,7 +50,7 @@ jobs: SPRING_PROFILES_ACTIVE: docker qc-atlas: - image: planqk/atlas:v3.1.3 + image: planqk/atlas:v3.1.4 ports: - 6626:6626 env: From feb3e9b5e7976ffba5d3baebec765afc426321ab Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 12:20:23 +0200 Subject: [PATCH 63/74] Check cutting config within pattern test --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 2e1b9230..010873aa 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -54,6 +54,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () chai .expect(element.outgoing[0].target.type) .to.equal(QUANTUM_CIRCUIT_EXECUTION_TASK); + chai.expect(element.cuttingMethod).to.equal("knitting toolbox"); } if (element.type === CUTTING_RESULT_COMBINATION_TASK) { chai.expect(element.incoming.length).to.equal(1); @@ -64,6 +65,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () chai .expect(element.outgoing[0].target.type) .to.equal(READOUT_ERROR_MITIGATION_TASK); + chai.expect(element.cuttingMethod).to.equal("knitting toolbox"); } if (element.type === READOUT_ERROR_MITIGATION_TASK) { chai.expect(element.incoming.length).to.equal(1); From 55524d6c24ca753589f5c187021e0f14b84e2da9 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 12:25:16 +0200 Subject: [PATCH 64/74] Improve logging --- .../bpmn-q/test/tests/pattern/pattern-transformation.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index 010873aa..d51aed1a 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -46,6 +46,7 @@ describe("Test the PatternTransformator of the Pattern extension.", function () .to.equal(QUANTUM_CIRCUIT_LOADING_TASK); } if (element.type === CIRCUIT_CUTTING_TASK) { + console.log("Checking configuration of cutting task: ", element); chai.expect(element.incoming.length).to.equal(1); chai .expect(element.incoming[0].source.type) From c16e72dd197e4dc8a000ade802f893be0886605e Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 12:30:11 +0200 Subject: [PATCH 65/74] Use business object to check correct config --- .../test/tests/pattern/pattern-transformation.spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js index d51aed1a..e5779672 100644 --- a/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js +++ b/components/bpmn-q/test/tests/pattern/pattern-transformation.spec.js @@ -55,7 +55,9 @@ describe("Test the PatternTransformator of the Pattern extension.", function () chai .expect(element.outgoing[0].target.type) .to.equal(QUANTUM_CIRCUIT_EXECUTION_TASK); - chai.expect(element.cuttingMethod).to.equal("knitting toolbox"); + chai + .expect(element.businessObject.cuttingMethod) + .to.equal("knitting toolbox"); } if (element.type === CUTTING_RESULT_COMBINATION_TASK) { chai.expect(element.incoming.length).to.equal(1); @@ -66,7 +68,9 @@ describe("Test the PatternTransformator of the Pattern extension.", function () chai .expect(element.outgoing[0].target.type) .to.equal(READOUT_ERROR_MITIGATION_TASK); - chai.expect(element.cuttingMethod).to.equal("knitting toolbox"); + chai + .expect(element.businessObject.cuttingMethod) + .to.equal("knitting toolbox"); } if (element.type === READOUT_ERROR_MITIGATION_TASK) { chai.expect(element.incoming.length).to.equal(1); From 188ae95b5c28ac4381f8e132d7d76f68d179d47d Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 14:40:19 +0200 Subject: [PATCH 66/74] update qrm retrieval to include patternsolutions --- .../extensions/quantme/qrm-manager/index.js | 11 ++- .../quantme/qrm-manager/qrm-handler.js | 81 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js index d04604ee..ddc2b420 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js @@ -8,6 +8,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ +import {pluginNames} from "../../../editor/EditorConstants"; +import {checkEnabledStatus} from "../../../editor/plugin/PluginHandler"; const qrmHandler = require("./qrm-handler"); @@ -26,14 +28,21 @@ export const getQRMs = function () { */ export const updateQRMs = async function () { console.log("Updating QRMs in backend."); + let QRMs = []; try { QRMs = await qrmHandler.getCurrentQRMs(); console.log("Found " + QRMs.length + " QRMs."); - return QRMs; + } catch (error) { console.log("Error while updating QRMs in backend: " + error); throw error; } + const patternEnabled = checkEnabledStatus(pluginNames.PATTERN); + if (patternEnabled) { + console.log("loadedQRMs", QRMs); + QRMs = QRMs.concat(await qrmHandler.getPatternSolutionQRMs()); + } + return QRMs; }; /** diff --git a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js index 6e47ffe1..072763f9 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ +import {getQcAtlasEndpoint} from "../../pattern/framework-config/config-manager"; +import {fetchDataFromEndpoint} from "../../../editor/util/HttpUtilities"; +import JSZip from "jszip"; +import {saveFileFormats} from "../../../editor/EditorConstants"; const config = require("../../../editor/config/EditorConfigManager"); const gitHandler = require("./git-handler"); @@ -114,3 +118,80 @@ async function getQRM(userName, repoName, qrmUrl, token) { replacement: await gitHandler.getFileContent(replacementUrl), }; } + +export async function getPatternSolutionQRMs(){ + const qcAtlasEndpoint = getQcAtlasEndpoint(); + const qcAtlasSolutionEndpoint = qcAtlasEndpoint + "/atlas/solutions"; + console.log("Retrieving solutions from URL: ", qcAtlasSolutionEndpoint); + let listOfSolutions = await fetchDataFromEndpoint(qcAtlasSolutionEndpoint); + console.log("Retrieved solutions: {}", listOfSolutions); + listOfSolutions = listOfSolutions.content.filter( + (solution) => "QRM" === solution.solutionType + ); + console.log("Retrieved matching solutions: {}", listOfSolutions); + + let QRMs = []; + if (!listOfSolutions || listOfSolutions.length < 1) { + console.log("Unable to find QRM-based solutions in Pattern Repository"); + return []; + } else { + console.log("Found %i solutions", listOfSolutions.length); + for (let solution of listOfSolutions){ + const qrmSolutionEndpoint = + qcAtlasSolutionEndpoint + "/" + solution.id + "/file/content"; + console.log("Retrieving QRM from URL: ", qrmSolutionEndpoint); + const qrm = await fetch(qrmSolutionEndpoint); + let blob = await qrm.blob(); + + console.log("Found QRM with content {}", blob); + let zip = await JSZip.loadAsync(blob); + + // Iterate over each file in the zip + let files = Object.entries(zip.files); + console.log("Zip comprises %i files!", files.length); + + let patternQRMs = await retrievePatternSolutionQRMs(files, [], solution); + console.log("Retrieved the following pattern QRMs", patternQRMs); + QRMs = QRMs.concat(patternQRMs); + } + } + return QRMs; +} + + +async function retrievePatternSolutionQRMs(files, qrmList, solution) { + let filesInDirectory = {}; + for (const [fileName, file] of files) { + console.log("Searching file with name: ", fileName); + if (!file.dir && fileName.endsWith(saveFileFormats.ZIP)) { + console.log("ZIP detected"); + let zip = await JSZip.loadAsync(await file.async("blob")); + qrmList = await retrievePatternSolutionQRMs( + Object.entries(zip.files), + qrmList, + solution + ); + } + if (fileName.endsWith("detector.bpmn")) { + console.log("Identified detector with name ", fileName); + filesInDirectory['detector'] = await file.async("text"); + } + if (fileName.endsWith("replacement.bpmn")) { + console.log("Identified replacement with name ", fileName); + filesInDirectory['replacement'] = await file.async("text"); + } + } + if (filesInDirectory['replacement'] && filesInDirectory['detector']) { + console.log({ + qrmUrl: "QRM from solutions for patternID: " + solution.patternId + ", with Id: " + solution.id, + detector: filesInDirectory['detector'], + replacement: filesInDirectory['replacement'], + }); + qrmList.push({ + qrmUrl: "QRM from solutions for patternID: " + solution.patternId + ", with Id: " + solution.id, + detector: filesInDirectory['detector'], + replacement: filesInDirectory['replacement'], + }); + } + return qrmList; +} From 60460f2931ff73226ba076bf0463f9eb6adfb4f6 Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 14:41:21 +0200 Subject: [PATCH 67/74] refactoring --- .../quantme/qrm-manager/qrm-handler.js | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js index 072763f9..158bff97 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/qrm-handler.js @@ -8,10 +8,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -import {getQcAtlasEndpoint} from "../../pattern/framework-config/config-manager"; -import {fetchDataFromEndpoint} from "../../../editor/util/HttpUtilities"; +import { getQcAtlasEndpoint } from "../../pattern/framework-config/config-manager"; +import { fetchDataFromEndpoint } from "../../../editor/util/HttpUtilities"; import JSZip from "jszip"; -import {saveFileFormats} from "../../../editor/EditorConstants"; +import { saveFileFormats } from "../../../editor/EditorConstants"; const config = require("../../../editor/config/EditorConfigManager"); const gitHandler = require("./git-handler"); @@ -119,14 +119,14 @@ async function getQRM(userName, repoName, qrmUrl, token) { }; } -export async function getPatternSolutionQRMs(){ +export async function getPatternSolutionQRMs() { const qcAtlasEndpoint = getQcAtlasEndpoint(); const qcAtlasSolutionEndpoint = qcAtlasEndpoint + "/atlas/solutions"; console.log("Retrieving solutions from URL: ", qcAtlasSolutionEndpoint); let listOfSolutions = await fetchDataFromEndpoint(qcAtlasSolutionEndpoint); console.log("Retrieved solutions: {}", listOfSolutions); listOfSolutions = listOfSolutions.content.filter( - (solution) => "QRM" === solution.solutionType + (solution) => "QRM" === solution.solutionType ); console.log("Retrieved matching solutions: {}", listOfSolutions); @@ -136,9 +136,9 @@ export async function getPatternSolutionQRMs(){ return []; } else { console.log("Found %i solutions", listOfSolutions.length); - for (let solution of listOfSolutions){ + for (let solution of listOfSolutions) { const qrmSolutionEndpoint = - qcAtlasSolutionEndpoint + "/" + solution.id + "/file/content"; + qcAtlasSolutionEndpoint + "/" + solution.id + "/file/content"; console.log("Retrieving QRM from URL: ", qrmSolutionEndpoint); const qrm = await fetch(qrmSolutionEndpoint); let blob = await qrm.blob(); @@ -158,7 +158,6 @@ export async function getPatternSolutionQRMs(){ return QRMs; } - async function retrievePatternSolutionQRMs(files, qrmList, solution) { let filesInDirectory = {}; for (const [fileName, file] of files) { @@ -167,30 +166,38 @@ async function retrievePatternSolutionQRMs(files, qrmList, solution) { console.log("ZIP detected"); let zip = await JSZip.loadAsync(await file.async("blob")); qrmList = await retrievePatternSolutionQRMs( - Object.entries(zip.files), - qrmList, - solution + Object.entries(zip.files), + qrmList, + solution ); } if (fileName.endsWith("detector.bpmn")) { console.log("Identified detector with name ", fileName); - filesInDirectory['detector'] = await file.async("text"); + filesInDirectory["detector"] = await file.async("text"); } if (fileName.endsWith("replacement.bpmn")) { console.log("Identified replacement with name ", fileName); - filesInDirectory['replacement'] = await file.async("text"); + filesInDirectory["replacement"] = await file.async("text"); } } - if (filesInDirectory['replacement'] && filesInDirectory['detector']) { + if (filesInDirectory["replacement"] && filesInDirectory["detector"]) { console.log({ - qrmUrl: "QRM from solutions for patternID: " + solution.patternId + ", with Id: " + solution.id, - detector: filesInDirectory['detector'], - replacement: filesInDirectory['replacement'], + qrmUrl: + "QRM from solutions for patternID: " + + solution.patternId + + ", with Id: " + + solution.id, + detector: filesInDirectory["detector"], + replacement: filesInDirectory["replacement"], }); qrmList.push({ - qrmUrl: "QRM from solutions for patternID: " + solution.patternId + ", with Id: " + solution.id, - detector: filesInDirectory['detector'], - replacement: filesInDirectory['replacement'], + qrmUrl: + "QRM from solutions for patternID: " + + solution.patternId + + ", with Id: " + + solution.id, + detector: filesInDirectory["detector"], + replacement: filesInDirectory["replacement"], }); } return qrmList; From 32d9d219a5169f44585d7ecd93cb5eeef0fca3ef Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 14:41:39 +0200 Subject: [PATCH 68/74] refactoring --- .../extensions/quantme/qrm-manager/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js index ddc2b420..6c01acd1 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js @@ -8,8 +8,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -import {pluginNames} from "../../../editor/EditorConstants"; -import {checkEnabledStatus} from "../../../editor/plugin/PluginHandler"; +import { pluginNames } from "../../../editor/EditorConstants"; +import { checkEnabledStatus } from "../../../editor/plugin/PluginHandler"; const qrmHandler = require("./qrm-handler"); @@ -32,7 +32,6 @@ export const updateQRMs = async function () { try { QRMs = await qrmHandler.getCurrentQRMs(); console.log("Found " + QRMs.length + " QRMs."); - } catch (error) { console.log("Error while updating QRMs in backend: " + error); throw error; From b1d5fb219eda8cca8196a83a7fcd4f96b49de0eb Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 15:05:47 +0200 Subject: [PATCH 69/74] Only retrieve QRMs from repo within QuantME test --- .../bpmn-q/test/tests/quantme/quantme-transformation.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js index cb3dfc18..b66e14f8 100644 --- a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js +++ b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js @@ -21,6 +21,7 @@ const chai = require("chai"); const { pluginNames, } = require("../../../modeler-component/editor/EditorConstants"); +const { getCurrentQRMs } = require("../../../modeler-component/extensions/quantme/qrm-manager/qrm-handler"); describe("Test the QuantMETransformator of the QuantME extension.", function () { describe("Transformation of QuantME extensions", function () { it("should create a valid native workflow model after two transformations", async function () { @@ -37,7 +38,7 @@ describe("Test the QuantMETransformator of the QuantME extension.", function () ]); this.timeout(60000); - let qrms = await updateQRMs(); + let qrms = await getCurrentQRMs(); chai.expect(qrms.length).to.equal(10); editorConfig.setQRMUserName("UST-QuAntiL"); From 144c0b9c6383f3a4259bb387c9532fb91711b8ad Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 15:08:21 +0200 Subject: [PATCH 70/74] Linter --- .../bpmn-q/test/tests/quantme/quantme-transformation.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js index b66e14f8..f3e5fceb 100644 --- a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js +++ b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js @@ -21,7 +21,9 @@ const chai = require("chai"); const { pluginNames, } = require("../../../modeler-component/editor/EditorConstants"); -const { getCurrentQRMs } = require("../../../modeler-component/extensions/quantme/qrm-manager/qrm-handler"); +const { + getCurrentQRMs, +} = require("../../../modeler-component/extensions/quantme/qrm-manager/qrm-handler"); describe("Test the QuantMETransformator of the QuantME extension.", function () { describe("Transformation of QuantME extensions", function () { it("should create a valid native workflow model after two transformations", async function () { From 985a9e737ac14db4b82f1b4a5625ff7d056e9f3a Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 15:16:32 +0200 Subject: [PATCH 71/74] Fix second invocation of updateQRM --- .../bpmn-q/test/tests/quantme/quantme-transformation.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js index f3e5fceb..85028bc1 100644 --- a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js +++ b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js @@ -5,7 +5,6 @@ const { deployWorkflowToCamunda, } = require("../../../modeler-component/editor/util/IoUtilities"); const { - updateQRMs, resetQRMs, } = require("../../../modeler-component/extensions/quantme/qrm-manager"); const { @@ -47,7 +46,7 @@ describe("Test the QuantMETransformator of the QuantME extension.", function () editorConfig.setQRMRepositoryName("QuantME-UseCases"); editorConfig.setQRMRepositoryPath("2023-icwe/part2"); - let qrmMaxCut = await updateQRMs(); + let qrmMaxCut = await getCurrentQRMs(); chai.expect(qrmMaxCut.length).to.equal(1); let allQrms = qrms.concat(qrmMaxCut); From 6aa346a39538ee7eaa0247d92c736dd66f97b646 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 15:22:59 +0200 Subject: [PATCH 72/74] Add test case loading pattern-based QRMs --- .../bpmn-q/test/tests/pattern/pattern-qrms-spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js diff --git a/components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js b/components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js new file mode 100644 index 00000000..b6fcbc95 --- /dev/null +++ b/components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js @@ -0,0 +1,9 @@ +import chai from "chai"; +import { getPatternSolutionQRMs } from "../../../modeler-component/extensions/quantme/qrm-manager/qrm-handler"; +describe("Test the pattern plugin", function () { + it("Should load solutions as QRMs", async function () { + const patternQRMs = await getPatternSolutionQRMs(); + + chai.expect(patternQRMs.length).to.equal(4); + }); +}); From 458d011fe3f335b6125dc2d2937c8bd0812a548f Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Fri, 17 May 2024 15:27:58 +0200 Subject: [PATCH 73/74] Activite new test file --- components/bpmn-q/karma.conf.js | 1 + .../tests/pattern/{pattern-qrms-spec.js => pattern-qrms.spec.js} | 0 2 files changed, 1 insertion(+) rename components/bpmn-q/test/tests/pattern/{pattern-qrms-spec.js => pattern-qrms.spec.js} (100%) diff --git a/components/bpmn-q/karma.conf.js b/components/bpmn-q/karma.conf.js index 81955a62..eed87b3f 100644 --- a/components/bpmn-q/karma.conf.js +++ b/components/bpmn-q/karma.conf.js @@ -30,6 +30,7 @@ module.exports = function (config) { "test/tests/dataflow/data-flow-palette.spec.js", "test/tests/dataflow/data-flow-replace-menu.spec.js", "test/tests/pattern/pattern-config.spec.js", + "test/tests/pattern/pattern-qrms.spec.js", "test/tests/pattern/pattern-transformation.spec.js", ], diff --git a/components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js b/components/bpmn-q/test/tests/pattern/pattern-qrms.spec.js similarity index 100% rename from components/bpmn-q/test/tests/pattern/pattern-qrms-spec.js rename to components/bpmn-q/test/tests/pattern/pattern-qrms.spec.js From 554c9a955966b9a7cc807721ee43e983d3fae193 Mon Sep 17 00:00:00 2001 From: mbeisel Date: Fri, 17 May 2024 17:27:53 +0200 Subject: [PATCH 74/74] fix visibility of variable --- .../modeler-component/extensions/quantme/qrm-manager/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js index 6c01acd1..a4867b53 100644 --- a/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js +++ b/components/bpmn-q/modeler-component/extensions/quantme/qrm-manager/index.js @@ -28,7 +28,6 @@ export const getQRMs = function () { */ export const updateQRMs = async function () { console.log("Updating QRMs in backend."); - let QRMs = []; try { QRMs = await qrmHandler.getCurrentQRMs(); console.log("Found " + QRMs.length + " QRMs.");