Skip to content

Commit

Permalink
Add policies (#123)
Browse files Browse the repository at this point in the history
* add policies

* add deployment policy

* add deploymentStrategy to task

* fix props for deployment policy

* remove paths

* checkbox, change icon

* add palette

* change base shape

* change onDemand of task

* add constants

* move policies to opentosca

* remove privacy policy

split into location, dedicatedHosting, cloudDeploymentMode

* fix display of properties

* add transformation into service deployment

* remove on-demand modal from deploy workflow

* update service task ids

* adjust height & position

* change icons of policies

* adjust blue box

* sync between task & policy

* fix lint

* add icons for palette & replace menu

* change quantme to opentosca

* update palette

* add replace rule

* Add missing header

* remove entries from contextpad

* restrict number of policies

* update connect rule

* add header

* Update docs

* update rule of reconnect

* remove checkbox from ondemandpolicy, fix icons

* remove checkbox for dedicated hosting policy

* fix flag

* remove on-demand policy when on-demand task is transformed

---------

Co-authored-by: Benjamin Weder <benjamin.weder@iaas.uni-stuttgart.de>
  • Loading branch information
LaviniaStiliadou and wederbn authored Nov 20, 2023
1 parent bf5414d commit 3758f64
Show file tree
Hide file tree
Showing 34 changed files with 2,677 additions and 216 deletions.
42 changes: 3 additions & 39 deletions components/bpmn-q/modeler-component/editor/ui/DeploymentButton.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React, { Fragment, useState } from "react";
import React, { Fragment } from "react";
import NotificationHandler from "./notifications/NotificationHandler";
import { deployWorkflowToCamunda } from "../util/IoUtilities";
import { getCamundaEndpoint } from "../config/EditorConfigManager";
import { getRootProcess } from "../util/ModellingUtilities";
import { getServiceTasksToDeploy } from "../../extensions/opentosca/deployment/DeploymentUtils";
import { createTempModelerFromXml, getModeler } from "../ModelerHandler";
import OnDemandDeploymentModal from "./OnDemandDeploymentModal";
import { startOnDemandReplacementProcess } from "../../extensions/opentosca/replacement/OnDemandTransformator";
import { createTempModelerFromXml } from "../ModelerHandler";

// eslint-disable-next-line no-unused-vars
const defaultState = {
Expand All @@ -21,31 +18,8 @@ const defaultState = {
* @constructor
*/
export default function DeploymentButton(props) {
const [windowOpenOnDemandDeployment, setWindowOpenOnDemandDeployment] =
useState(false);

const { modeler } = props;

/**
* Handle result of the on demand deployment dialog
*
* @param result the result from the dialog
*/
async function handleOnDemandDeployment(result) {
if (result && result.hasOwnProperty("onDemand")) {
// get XML of the current workflow
let xml = (await modeler.saveXML({ format: true })).xml;
console.log("XML", xml);
if (result.onDemand === true) {
xml = await startOnDemandReplacementProcess(xml);
}
// deploy in any case
deploy(xml);
}
// handle cancellation (don't deploy)
setWindowOpenOnDemandDeployment(false);
}

/**
* Deploy the current workflow to the Camunda engine
*/
Expand Down Expand Up @@ -116,14 +90,7 @@ export default function DeploymentButton(props) {
}

async function onClick() {
let csarsToDeploy = getServiceTasksToDeploy(
getRootProcess(getModeler().getDefinitions())
);
if (csarsToDeploy.length > 0) {
setWindowOpenOnDemandDeployment(true);
} else {
deploy((await modeler.saveXML({ format: true })).xml);
}
deploy((await modeler.saveXML({ format: true })).xml);
}

return (
Expand All @@ -138,9 +105,6 @@ export default function DeploymentButton(props) {
<span className="qwm-indent">Deploy Workflow</span>
</span>
</button>
{windowOpenOnDemandDeployment && (
<OnDemandDeploymentModal onClose={(e) => handleOnDemandDeployment(e)} />
)}
</Fragment>
);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class CustomRulesProvider extends BpmnRules {
/**
* Fired during creation of a new connection (while you selected the target of a connection)
*/
this.addRule("connection.create", 200000, function (context) {
this.addRule("connection.create", 200, function (context) {
const source = context.source,
target = context.target;

Expand All @@ -43,7 +43,7 @@ export default class CustomRulesProvider extends BpmnRules {
/**
* Fired when a connection between two elements is drawn again, e.g. after dragging an element
*/
this.addRule("connection.reconnect", 200000000000, function (context) {
this.addRule("connection.reconnect", 200, function (context) {
const source = context.source,
target = context.target;

Expand All @@ -57,7 +57,7 @@ export default class CustomRulesProvider extends BpmnRules {
/**
* Fired when a new shape for an element is created
*/
this.addRule("shape.create", 200000000000, function (context) {
this.addRule("shape.create", 200, function (context) {
return canCreate(
context.shape,
context.target,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
export const POLICY = "opentosca:Policy";
export const CLOUD_DEPLOYMENT_MODEL_POLICY =
"opentosca:CloudDeploymentModelPolicy";
export const ON_DEMAND_POLICY = "opentosca:OnDemandPolicy";
export const LOCATION_POLICY = "opentosca:LocationPolicy";
export const DEDICATED_HOSTING_POLICY = "opentosca:DedicatedHostingPolicy";

export const ON_DEMAND = "onDemand";
export const DEDICATED_HOSTING = "dedicatedHosting";
export const CLOUD_TYPE = "cloudType";
export const LOCATION = "location";

export const POLICIES = [
POLICY,
CLOUD_DEPLOYMENT_MODEL_POLICY,
DEDICATED_HOSTING_POLICY,
LOCATION_POLICY,
ON_DEMAND_POLICY,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
import inherits from "inherits";

import ContextPadProvider from "bpmn-js/lib/features/context-pad/ContextPadProvider";

import { bind } from "min-dash";

import * as consts from "../Constants";

export default function OpenTOSCAContextPadProvider(injector) {
injector.invoke(ContextPadProvider, this);
bind(this.getContextPadEntries, this);

const _getContextPadEntries =
ContextPadProvider.prototype.getContextPadEntries;
ContextPadProvider.prototype.getContextPadEntries = function (element) {
const entries = _getContextPadEntries.apply(this, [element]);
if (consts.POLICIES.includes(element.type)) {
delete entries["append.end-event"];
delete entries["append.intermediate-event"];
delete entries["append.gateway"];
delete entries["append.append-task"];
delete entries["append.text-annotation"];
delete entries["connect"];
if (element.type === consts.ON_DEMAND_POLICY) {
delete entries["delete"];
delete entries["replace"];
}
}
return entries;
};
}

inherits(OpenTOSCAContextPadProvider, ContextPadProvider);

OpenTOSCAContextPadProvider.$inject = ["injector", "connect", "translate"];
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import * as consts from "../Constants";

export default class OpenTOSCAPaletteProvider {
constructor(bpmnFactory, create, elementFactory, palette, translate) {
this.bpmnFactory = bpmnFactory;
this.create = create;
this.elementFactory = elementFactory;
this.translate = translate;

palette.registerProvider(this);
}

getPaletteEntries() {
return this.createPolicyEntry();
}

createPolicyEntry() {
const { bpmnFactory, create, elementFactory, translate } = this;

function createPolicy(event) {
const businessObject = bpmnFactory.create(consts.POLICY);
let shape = elementFactory.createShape({
type: consts.POLICY,
businessObject: businessObject,
});
create.start(event, shape);
}

return {
// add separator line to delimit the new group
"opentosca-separator": {
group: "opentosca",
separator: true,
},
"create.opentosca-policy": {
group: "opentosca",
className: "qwm opentosca-icon-policy-palette",
title: translate("Creates a policy"),
action: {
click: createPolicy,
dragstart: createPolicy,
},
},
};
}
}

OpenTOSCAPaletteProvider.$inject = [
"bpmnFactory",
"create",
"elementFactory",
"palette",
"translate",
];
Loading

0 comments on commit 3758f64

Please sign in to comment.