Skip to content

Commit

Permalink
Enable QRMs as concrete solutions for augmentation and behavioral pat…
Browse files Browse the repository at this point in the history
…terns (#157)

* Improve logs in pattern transformator

* Remove unused code

* Inline pattern declaration

* Add missing variable declaration

* Move pattern removal to utils

* Add docs

* Fix linting

* Remove unused code

* Add utility function to retrieve types in a generic manner

* Add utility method to check for QuantME subprocesses

* Remove redundant code

* Improve logging

* Simplify check for forbidden patterns

* Add constant for pattern prefix

* Switch to direct import

* Fix headings

* Add PatternId to pattern modeling constructs

* Incorporate pattern ID when adding pattern modeling constructs for selected patterns

* Forward pattern ID during transformation

* Remove faulty logging

* Retrieve pattern ID by type

* Add IDs to test

* Add QC atlas to test setup

* Add environment and version for Pattern Atlas container

* Add QC Atlas

* Fix ports for test setup

* Add version for WF engine

* Add database to test setup

* remove unused import

* remove unused import

* Fix equality checks

* Fix unused declarations

* Remove unused code

* Run linter

* Use constant for QuantumCircuitExecutionTask

* Use constant for REM

* Move comment to correct position

* Remove duplicate ajax method

* Remove pattern IDs from test workflow

* Fix port mapping

* Bump DB version

* Add DB env

* Move env to corresct container

* Add endpoint for Latex renderer

* Log status code

* Add log for wf deployment

* Run linter

* Adapt pattern endpoints

* Run linter

* Add additional logging

* Add logging

* Add done statement

* Increase timeout

* Remove done()

* Remove log

* Add TODO for test case

* adding funcitionalty for inserting concrete solutions from qc-atlas for augmentation patterns

* linting

* fix space removal bug

* linting

* Remove solved TODOs

* update atlas version in compose

* Check cutting config within pattern test

* Improve logging

* Use business object to check correct config

* update qrm retrieval to include patternsolutions

* refactoring

* refactoring

* Only retrieve QRMs from repo within QuantME test

* Linter

* Fix second invocation of updateQRM

* Add test case loading pattern-based QRMs

* Activite new test file

* fix visibility of variable

---------

Co-authored-by: mbeisel <beiselmn@gmail.com>
  • Loading branch information
wederbn and mbeisel authored May 17, 2024
1 parent 561fb3e commit 5d53924
Show file tree
Hide file tree
Showing 46 changed files with 743 additions and 448 deletions.
49 changes: 47 additions & 2 deletions .github/workflows/run-npm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,55 @@ 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 ###
db:
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
ports:
- 1977:1977
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
LATEX_RENDERER_HOST_NAME: latex-renderer
LATEX_RENDERER_PORT: 5030
JDBC_DATABASE_NAME: patternatlas
PATTERN_ATLAS_FETCH_INITIAL_DATA: 'true'
HAL_EXPLORER: 'false'
SPRING_PROFILES_ACTIVE: docker

qc-atlas:
image: planqk/atlas:v3.1.4
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
Expand All @@ -27,4 +72,4 @@ jobs:
npm ci
npm run build
npm test
working-directory: ./components/bpmn-q
working-directory: ./components/bpmn-q
1 change: 1 addition & 0 deletions components/bpmn-q/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],

Expand Down
28 changes: 0 additions & 28 deletions components/bpmn-q/modeler-component/editor/ModelerHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions components/bpmn-q/modeler-component/editor/ui/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 28 additions & 2 deletions components/bpmn-q/modeler-component/editor/util/HttpUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
* SPDX-License-Identifier: Apache-2.0
*/

import $ from "jquery";

/**
* Retrieves the Json data from the given endpoint.
*
* @param endpoint the endpoint to retrieve the data form
* @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) {
Expand All @@ -47,3 +53,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);
},
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +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"
);
const response = await fetch(
editorConfig.getCamundaEndpoint() + "/deployment/create",
{
Expand Down
113 changes: 4 additions & 109 deletions components/bpmn-q/modeler-component/editor/util/ModellingUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,117 +7,12 @@ import {
import { is } from "bpmn-js/lib/util/ModelUtil";

/**
* Returns all start events of the workflow defined by the process businessObject
* Get the type of a given element
*
* @param processBo The process businessObject containing the workflow
* @returns {*[]} All found start event elements of the workflow.
* @param element the element to retrieve the type for
*/
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);
export function getType(element) {
return element.$type ? element.$type : element.type;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ 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);

Expand Down
Loading

0 comments on commit 5d53924

Please sign in to comment.