-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attach policies to QuantME tasks (#127)
* attach policies to quantme * Use inline transformation as default * fix replace option * remove copy paste * Attach policies to ServiceTasks and Subprocesses during transformation * Fix typo in subprocess check * Retrieve relevant tasks within subprocess for policy attachment * Copy policies for subprocesses * add ondemand attribute to quantme tasks * add entry for ondemand * Fix layouting issues for policies * Always expand subprocesses during transformation * Only move policies if defined at tasks * Layout policies * update size of policy icons * fix for layouting when transforming qrms that contain a subprocess * add createLayoutedShape function * linting --------- Co-authored-by: LaviniaStiliadou <livia_16@live.de> Co-authored-by: mbeisel <beiselmn@gmail.com>
- Loading branch information
1 parent
8ac82a1
commit f38e4ad
Showing
15 changed files
with
556 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCASVGMap.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
components/bpmn-q/modeler-component/extensions/quantme/modeling/QuantMERules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/** | ||
* 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 RuleProvider from "diagram-js/lib/features/rules/RuleProvider"; | ||
import * as consts from "../Constants"; | ||
import { getModeler } from "../../../editor/ModelerHandler"; | ||
import * as openToscaConsts from "../../opentosca/Constants"; | ||
|
||
export default class QuantMERules extends RuleProvider { | ||
constructor(eventBus, modeling) { | ||
super(eventBus); | ||
this.modeling = modeling; | ||
|
||
this.addRule("shape.create", 11000, function (context) { | ||
var shape = context.shape, | ||
target = context.target; | ||
|
||
if ( | ||
shape.type.includes("Policy") && | ||
!consts.QUANTME_TASKS.includes(target.type) | ||
) { | ||
return false; | ||
} | ||
}); | ||
|
||
function canMove(context) { | ||
var target = context.target; | ||
|
||
if (target != undefined) { | ||
if (context.shapes[0].type.includes("Policy")) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
this.addRule("elements.move", 4000, function (context) { | ||
return canMove(context); | ||
}); | ||
|
||
this.addRule("shape.replace", function (context) { | ||
if (context.element.type.includes("Policy")) { | ||
if (context.element.type === openToscaConsts.DEDICATED_HOSTING_POLICY) { | ||
getModeler().get("modeling").updateProperties(context.element, { | ||
"opentosca:dedicatedHosting": "true", | ||
}); | ||
} | ||
return false; | ||
} | ||
}); | ||
this.addRule("shape.append", function (context) { | ||
if (context.element.type.includes("Policy")) { | ||
return false; | ||
} | ||
}); | ||
|
||
this.addRule("connection.create", 2000, function (context) { | ||
if (context.target.type.includes("Policy")) { | ||
return false; | ||
} | ||
if (context.source.type.includes("Policy")) { | ||
return false; | ||
} | ||
}); | ||
|
||
this.addRule("connection.reconnect", 2000, function (context) { | ||
const source = context.source, | ||
target = context.target; | ||
|
||
if (source.type.includes("Policy") || target.type.includes("Policy")) { | ||
return false; | ||
} | ||
}); | ||
|
||
this.addRule("shape.attach", 5000, function (context) { | ||
let shapeToAttach = context.shape; | ||
let target = context.target; | ||
|
||
if ( | ||
shapeToAttach.type.includes("Policy") && | ||
consts.QUANTME_TASKS.includes(target.type) | ||
) { | ||
let specificPolicies = openToscaConsts.POLICIES; | ||
specificPolicies = specificPolicies.filter( | ||
(policy) => policy !== openToscaConsts.POLICY | ||
); | ||
specificPolicies = specificPolicies.filter( | ||
(policy) => policy !== openToscaConsts.ON_DEMAND_POLICY | ||
); | ||
let attachedElementTypesWithPolicy = 0; | ||
for (let i = 0; i < target.attachers.length; i++) { | ||
if ( | ||
target.attachers[i].type.includes("Policy") && | ||
target.attachers[i].type !== openToscaConsts.ON_DEMAND_POLICY | ||
) { | ||
attachedElementTypesWithPolicy++; | ||
} | ||
if (specificPolicies.includes(target.attachers[i].type)) { | ||
specificPolicies = specificPolicies.filter( | ||
(policy) => policy !== target.attachers[i].type | ||
); | ||
} | ||
} | ||
|
||
for (let i = 0; i < target.attachers.length; i++) { | ||
if (specificPolicies.includes(target.attachers[i].type)) { | ||
specificPolicies = specificPolicies.filter( | ||
(policy) => policy !== target.attachers[i].type | ||
); | ||
} | ||
} | ||
if ( | ||
attachedElementTypesWithPolicy === | ||
openToscaConsts.POLICIES.length - 2 | ||
) { | ||
return false; | ||
} | ||
|
||
// If the specific policies are included, prevent attaching another policy | ||
if (specificPolicies.length === 0) { | ||
return false; | ||
} | ||
for (let i = 0; i < target.attachers.length; i++) { | ||
let boundaryElement = target.attachers[i]; | ||
|
||
if ( | ||
boundaryElement.type === openToscaConsts.DEDICATED_HOSTING_POLICY && | ||
shapeToAttach.type === openToscaConsts.DEDICATED_HOSTING_POLICY | ||
) { | ||
return false; | ||
} | ||
|
||
if ( | ||
boundaryElement.type === openToscaConsts.ON_DEMAND_POLICY && | ||
shapeToAttach.type === openToscaConsts.ON_DEMAND_POLICY | ||
) { | ||
return false; | ||
} | ||
|
||
if ( | ||
boundaryElement.type === openToscaConsts.LOCATION_POLICY && | ||
shapeToAttach.type === openToscaConsts.LOCATION_POLICY | ||
) { | ||
return false; | ||
} | ||
|
||
if ( | ||
boundaryElement.type === | ||
openToscaConsts.CLOUD_DEPLOYMENT_MODEL_POLICY && | ||
shapeToAttach.type === openToscaConsts.CLOUD_DEPLOYMENT_MODEL_POLICY | ||
) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
QuantMERules.$inject = ["eventBus", "modeling"]; |
Oops, something went wrong.