From 95405aa33aa7b7e2f794f92170169fe7f542fb93 Mon Sep 17 00:00:00 2001 From: Franka-T <77068560+Franka-T@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:46:14 +0100 Subject: [PATCH] #74 rename goal state to termination condition (#89) * rename goal state to termination condition --- app/index.html | 4 +- app/index.js | 22 +-- app/lib/goalstatemodeler/GoalStateEvents.js | 3 - app/lib/guidelines/Checker.js | 4 +- app/lib/guidelines/Guidelines.js | 8 +- app/lib/mediator/Mediator.js | 87 ++++++------ .../TerminationConditionEvents.js | 3 + .../TerminationConditionModdle.js} | 74 +++++----- .../TerminationConditionModeler.js} | 122 ++++++++-------- .../tc.json} | 110 +++++++-------- .../terminationconditionmodeler.less} | 130 +++++++++--------- ...goalState.xml => terminationCondition.xml} | 0 12 files changed, 284 insertions(+), 283 deletions(-) delete mode 100644 app/lib/goalstatemodeler/GoalStateEvents.js create mode 100644 app/lib/terminationconditionmodeler/TerminationConditionEvents.js rename app/lib/{goalstatemodeler/GoalStateModdle.js => terminationconditionmodeler/TerminationConditionModdle.js} (60%) rename app/lib/{goalstatemodeler/GoalStateModeler.js => terminationconditionmodeler/TerminationConditionModeler.js} (69%) rename app/lib/{goalstatemodeler/gs.json => terminationconditionmodeler/tc.json} (92%) rename app/lib/{goalstatemodeler/goalstatemodeler.less => terminationconditionmodeler/terminationconditionmodeler.less} (54%) rename resources/conferenceModel/{goalState.xml => terminationCondition.xml} (100%) diff --git a/app/index.html b/app/index.html index 5be13b6f..2a2c4507 100644 --- a/app/index.html +++ b/app/index.html @@ -69,9 +69,9 @@

Objective Model
-
+
-

Goal State photo_size_select_small

+

Termination Condition photo_size_select_small

?
diff --git a/app/index.js b/app/index.js index d4ffafc6..89da60ac 100644 --- a/app/index.js +++ b/app/index.js @@ -2,7 +2,7 @@ import FragmentModeler from './lib/fragmentmodeler/FragmentModeler'; import diagramXML from '../resources/newDiagram.bpmn'; import newDatamodel from '../resources/emptyBoard.bpmn'; import OlcModeler from './lib/olcmodeler/OlcModeler'; -import GoalStateModeler from './lib/goalstatemodeler/GoalStateModeler'; +import TerminationConditionModeler from './lib/terminationconditionmodeler/TerminationConditionModeler'; import DataModelModeler from './lib/datamodelmodeler/Modeler'; import ObjectiveModeler from './lib/objectivemodeler/OmModeler'; import DependencyModeler from './lib/dependencymodeler/DependencyModeler'; @@ -16,7 +16,7 @@ import { download, upload } from './lib/util/FileUtil'; import conferenceProcess from '../resources/conferenceModel/process.bpmn'; import conferenceDataModel from '../resources/conferenceModel/datamodel.xml'; import conferenceOLC from '../resources/conferenceModel/olc.xml'; -import conferenceGoalState from '../resources/conferenceModel/goalState.xml'; +import conferenceTerminationCondition from '../resources/conferenceModel/terminationCondition.xml'; import Zip from 'jszip'; @@ -80,10 +80,10 @@ var fragmentModeler = new FragmentModeler({ }] }); -var goalStateModeler = new GoalStateModeler( - '#goalstate-canvas' +var terminationConditionModeler = new TerminationConditionModeler( + '#terminationcondition-canvas' ); -new mediator.GoalStateModelerHook(goalStateModeler); +new mediator.TerminationConditionModelerHook(terminationConditionModeler); @@ -96,7 +96,7 @@ async function loadDebugData() { zip.file('fragments.bpmn', conferenceProcess); zip.file('dataModel.xml', conferenceDataModel); zip.file('olcs.xml', conferenceOLC); - zip.file('goalState.xml', conferenceGoalState); + zip.file('terminationCondition.xml', conferenceTerminationCondition); await importFromZip(zip.generateAsync({type : 'base64'})); } @@ -108,7 +108,7 @@ async function createNewDiagram() { await dataModeler.importXML(newDatamodel); await objectiveModeler.createDiagram(); await dependencyModeler.createNew(); - goalStateModeler.createNew(); + terminationConditionModeler.createNew(); if (LOAD_DUMMY) { await loadDebugData(); } @@ -144,8 +144,8 @@ async function exportToZip () { zip.file('objectiveModel.xml', objectiveModel); const olcs = (await olcModeler.saveXML({ format: true })).xml; zip.file('olcs.xml', olcs); - const goalState = (await goalStateModeler.saveXML({ format: true })).xml; - zip.file('goalState.xml', goalState); + const terminationCondition = (await terminationConditionModeler.saveXML({ format: true })).xml; + zip.file('terminationCondition.xml', terminationCondition); const dependencyModel = (await dependencyModeler.saveXML({ format: true })).xml; zip.file('dependencyModel.xml', dependencyModel); return zip.generateAsync({type : 'base64'}); @@ -159,7 +159,7 @@ async function importFromZip (zipData) { dataModel: zip.file('dataModel.xml'), objectiveModel: zip.file('objectiveModel.xml'), olcs: zip.file('olcs.xml'), - goalState: zip.file('goalState.xml'), + terminationCondition: zip.file('terminationCondition.xml'), dependencyModel: zip.file('dependencyModel.xml') }; Object.keys(files).forEach(key => { @@ -171,7 +171,7 @@ async function importFromZip (zipData) { await objectiveModeler.importXML(await files.objectiveModel.async("string")); await olcModeler.importXML(await files.olcs.async("string")); await fragmentModeler.importXML(await files.fragments.async("string")); - await goalStateModeler.importXML(await files.goalState.async("string")); + await terminationConditionModeler.importXML(await files.terminationCondition.async("string")); await dependencyModeler.importXML(await files.dependencyModel.async("string")); checker.activate(); } diff --git a/app/lib/goalstatemodeler/GoalStateEvents.js b/app/lib/goalstatemodeler/GoalStateEvents.js deleted file mode 100644 index 1797fa71..00000000 --- a/app/lib/goalstatemodeler/GoalStateEvents.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - GOALSTATE_CHANGED : 'gs.changed', -} \ No newline at end of file diff --git a/app/lib/guidelines/Checker.js b/app/lib/guidelines/Checker.js index 6fc9a6d0..c11f09e2 100644 --- a/app/lib/guidelines/Checker.js +++ b/app/lib/guidelines/Checker.js @@ -4,7 +4,7 @@ import Guidelines from "./Guidelines"; import { SEVERITY } from "./Guidelines"; import getDropdown from "../util/Dropdown"; import OlcEvents from '../olcmodeler/OlcEvents'; -import GoalStateEvents from "../goalstatemodeler/GoalStateEvents"; +import TerminationConditionEvents from "../terminationconditionmodeler/TerminationConditionEvents"; import { openAsOverlay } from "../util/HtmlUtil"; import { makeGuidelineLink, makeQuickFixDiv } from "./ErrorBar"; @@ -19,7 +19,7 @@ export default class Checker { mediator.executed(['shape.create', 'shape.delete', 'element.updateLabel', 'connection.create', 'connection.delete', 'element.updateProperties'], event => { this.evaluateAll(); }); - mediator.on([OlcEvents.SELECTED_OLC_CHANGED, GoalStateEvents.GOALSTATE_CHANGED], event => { + mediator.on([OlcEvents.SELECTED_OLC_CHANGED, TerminationConditionEvents.TERMINATIONCONDITION_CHANGED], event => { this.evaluateAll(); }); this.errorBar = errorBar; diff --git a/app/lib/guidelines/Guidelines.js b/app/lib/guidelines/Guidelines.js index b7d8a3d6..92f7b372 100644 --- a/app/lib/guidelines/Guidelines.js +++ b/app/lib/guidelines/Guidelines.js @@ -27,15 +27,15 @@ SEVERITY.filter = function(lambda) { export default [ { - title : 'GS2: Include all relevant data objects in the goal', - id : 'GS2', + title : 'TC2: Include all relevant data objects in the Termination Condition', + id : 'TC2', getViolations(mediator) { - const hook = mediator.goalStateModelerHook; + const hook = mediator.terminationConditionModelerHook; const literals = hook.modeler.getLiterals(); if (literals && literals.length === 0) { return [{ element : hook.getRootObject(), - message : 'Please include at least one data object configuration as literal in the goal state.' + message : 'Please include at least one data object configuration as literal in the termination condition.' }]; } else { return []; diff --git a/app/lib/mediator/Mediator.js b/app/lib/mediator/Mediator.js index 86d560d9..01230359 100644 --- a/app/lib/mediator/Mediator.js +++ b/app/lib/mediator/Mediator.js @@ -141,7 +141,7 @@ Mediator.prototype.addedClass = function (clazz) { } Mediator.prototype.confirmClassDeletion = function (clazz) { - const affectedLiterals = this.goalStateModelerHook.modeler.getLiteralsWithClassId(clazz.id); + const affectedLiterals = this.terminationCondition.modeler.getLiteralsWithClassId(clazz.id); const affectedStates = this.olcModelerHook.modeler.getOlcByClass(clazz).get('Elements').filter(element => is(element, 'olc:State')); const affectedDataObjectReferences = this.fragmentModelerHook.modeler.getDataObjectReferencesOfClass(clazz); const affectedObjects = this.objectiveModelerHook.modeler.getObjectsOfClass(clazz); @@ -203,7 +203,7 @@ Mediator.prototype.createName = function (name, clazz) { // === OLC helpers Mediator.prototype.olcListChanged = function (olcs) { - this.goalStateModelerHook.modeler.handleOlcListChanged(olcs); + this.terminationConditionModelerHook.modeler.handleOlcListChanged(olcs); this.fragmentModelerHook.modeler.handleOlcListChanged(olcs); this.objectiveModelerHook.modeler.handleOlcListChanged(olcs); } @@ -228,7 +228,7 @@ Mediator.prototype.createState = function (name, olc) { } Mediator.prototype.confirmStateDeletion = function (olcState) { - const affectedLiterals = this.goalStateModelerHook.modeler.getLiteralsWithState(olcState); + const affectedLiterals = this.terminationConditionModelerHook.modeler.getLiteralsWithState(olcState); const affectedDataObjectReferences = this.fragmentModelerHook.modeler.getDataObjectReferencesInState(olcState); const affectedObjects = this.objectiveModelerHook.modeler.getObjectsInState(olcState); return confirm('Do you really want to delete state \"' + olcState.name + '\" ?' @@ -236,13 +236,13 @@ Mediator.prototype.confirmStateDeletion = function (olcState) { } Mediator.prototype.deletedState = function (olcState) { - this.goalStateModelerHook.modeler.handleStateDeleted(olcState); + this.terminationConditionModelerHook.modeler.handleStateDeleted(olcState); this.fragmentModelerHook.modeler.handleStateDeleted(olcState); this.objectiveModelerHook.modeler.handleStateDeleted(olcState); } Mediator.prototype.renamedState = function (olcState) { - this.goalStateModelerHook.modeler.handleStateRenamed(olcState); + this.terminationConditionModelerHook.modeler.handleStateRenamed(olcState); this.fragmentModelerHook.modeler.handleStateRenamed(olcState); this.objectiveModelerHook.modeler.handleStateRenamed(olcState); } @@ -419,43 +419,6 @@ Mediator.prototype.FragmentModelerHook.$inject = [ Mediator.prototype.FragmentModelerHook.isHook = true; -// === Goal State Modeler Hook -Mediator.prototype.GoalStateModelerHook = function (goalStateModeler) { - AbstractHook.call(this, goalStateModeler, 'Goal State', 'https://github.com/bptlab/fCM-design-support/wiki/Goal-State'); - this.mediator.goalStateModelerHook = this; - this.eventBus = goalStateModeler.eventBus; - - this.getRootObject = function() { - return this.modeler.getGoalState(); - } - - this.getNamespace = function () { - return this.getRootObject() && namespace(this.getRootObject()); - } - - this.getGraphics = function (element) { - const modeler = this.modeler; - return element !== this.getRootObject() ? - modeler.getStatements().includes(element) && element.element - : modeler._root.closest('.canvas'); - } - - this.eventBus.on('import.parse.complete', ({warnings}) => { - warnings.filter(({message}) => message.startsWith('unresolved reference')).forEach(({property, value, element}) => { - if (property === 'gs:class') { - const olcClass = this.mediator.olcModelerHook.modeler.getOlcById(value); - if (!olcClass) { throw new Error('Could not resolve data class with id '+value); } - element.class = olcClass; - } else if (property === 'gs:states') { - const state = this.mediator.olcModelerHook.modeler.getStateById(value) - if (!state) { throw new Error('Could not resolve olc state with id '+value); } - element.get('states').push(state); - } - }); - }); -} - -Mediator.prototype.GoalStateModelerHook.isHook = true; // === Objective Modeler Hook Mediator.prototype.ObjectiveModelerHook = function (eventBus, objectiveModeler) { @@ -635,4 +598,42 @@ Mediator.prototype.OlcModelerHook.$inject = [ 'olcModeler' ]; -Mediator.prototype.OlcModelerHook.isHook = true; \ No newline at end of file +Mediator.prototype.OlcModelerHook.isHook = true; + +// === Termination Condition Modeler Hook +Mediator.prototype.TerminationConditionModelerHook = function (terminationConditionModeler) { + AbstractHook.call(this, terminationConditionModeler, 'Termination Condition', 'https://github.com/bptlab/fCM-design-support/wiki/Goal-State'); + this.mediator.terminationConditionModelerHook = this; + this.eventBus = terminationConditionModeler.eventBus; + + this.getRootObject = function() { + return this.modeler.getTerminationCondition(); + } + + this.getNamespace = function () { + return this.getRootObject() && namespace(this.getRootObject()); + } + + this.getGraphics = function (element) { + const modeler = this.modeler; + return element !== this.getRootObject() ? + modeler.getStatements().includes(element) && element.element + : modeler._root.closest('.canvas'); + } + + this.eventBus.on('import.parse.complete', ({warnings}) => { + warnings.filter(({message}) => message.startsWith('unresolved reference')).forEach(({property, value, element}) => { + if (property === 'tc:class') { + const olcClass = this.mediator.olcModelerHook.modeler.getOlcById(value); + if (!olcClass) { throw new Error('Could not resolve data class with id '+value); } + element.class = olcClass; + } else if (property === 'tc:states') { + const state = this.mediator.olcModelerHook.modeler.getStateById(value) + if (!state) { throw new Error('Could not resolve olc state with id '+value); } + element.get('states').push(state); + } + }); + }); +} + +Mediator.prototype.TerminationConditionModelerHook.isHook = true; diff --git a/app/lib/terminationconditionmodeler/TerminationConditionEvents.js b/app/lib/terminationconditionmodeler/TerminationConditionEvents.js new file mode 100644 index 00000000..c31bcba1 --- /dev/null +++ b/app/lib/terminationconditionmodeler/TerminationConditionEvents.js @@ -0,0 +1,3 @@ +export default { + TERMINATIONCONDITION_CHANGED : 'tc.changed', +} \ No newline at end of file diff --git a/app/lib/goalstatemodeler/GoalStateModdle.js b/app/lib/terminationconditionmodeler/TerminationConditionModdle.js similarity index 60% rename from app/lib/goalstatemodeler/GoalStateModdle.js rename to app/lib/terminationconditionmodeler/TerminationConditionModdle.js index 863e1d69..29f08392 100644 --- a/app/lib/goalstatemodeler/GoalStateModdle.js +++ b/app/lib/terminationconditionmodeler/TerminationConditionModdle.js @@ -1,38 +1,38 @@ -import { assign } from 'min-dash'; - -import { Moddle } from 'moddle'; - -import { Reader, Writer } from 'moddle-xml'; - -import Descriptor from './gs.json'; - -export default function GoalStateModdle() { - Moddle.call(this, {gs : Descriptor}); -} - -GoalStateModdle.prototype = Object.create(Moddle.prototype); - -GoalStateModdle.prototype.fromXML = function (xmlStr, options) { - var typeName = 'gs:Disjunction'; - var reader = new Reader(assign({ model: this, lax: false }, options)); - var rootHandler = reader.handler(typeName); - - return reader.fromXML(xmlStr, rootHandler); -}; - - -GoalStateModdle.prototype.toXML = function (element, options) { - var writer = new Writer(options); - - return new Promise(function (resolve, reject) { - try { - var result = writer.toXML(element); - - return resolve({ - xml: result - }); - } catch (err) { - return reject(err); - } - }); +import { assign } from 'min-dash'; + +import { Moddle } from 'moddle'; + +import { Reader, Writer } from 'moddle-xml'; + +import Descriptor from './tc.json'; + +export default function TerminationConditionModdle() { + Moddle.call(this, {tc : Descriptor}); +} + +TerminationConditionModdle.prototype = Object.create(Moddle.prototype); + +TerminationConditionModdle.prototype.fromXML = function (xmlStr, options) { + var typeName = 'tc:Disjunction'; + var reader = new Reader(assign({ model: this, lax: false }, options)); + var rootHandler = reader.handler(typeName); + + return reader.fromXML(xmlStr, rootHandler); +}; + + +TerminationConditionModdle.prototype.toXML = function (element, options) { + var writer = new Writer(options); + + return new Promise(function (resolve, reject) { + try { + var result = writer.toXML(element); + + return resolve({ + xml: result + }); + } catch (err) { + return reject(err); + } + }); }; \ No newline at end of file diff --git a/app/lib/goalstatemodeler/GoalStateModeler.js b/app/lib/terminationconditionmodeler/TerminationConditionModeler.js similarity index 69% rename from app/lib/goalstatemodeler/GoalStateModeler.js rename to app/lib/terminationconditionmodeler/TerminationConditionModeler.js index 2df12fe8..df61a084 100644 --- a/app/lib/goalstatemodeler/GoalStateModeler.js +++ b/app/lib/terminationconditionmodeler/TerminationConditionModeler.js @@ -3,20 +3,20 @@ import { without } from 'min-dash'; import { formatStates, type, is } from '../util/Util'; import getDropdown from '../util/Dropdown'; import EventBus from 'diagram-js/lib/core/EventBus' -import GoalStateEvents from './GoalStateEvents'; -import GoalStateModdle from './GoalStateModdle'; +import TerminationConditionEvents from './TerminationConditionEvents'; +import TerminationConditionModdle from './TerminationConditionModdle'; import CommonEvents from '../common/CommonEvents'; -const NAMESPACE = 'gs'; +const NAMESPACE = 'tc'; -export default function GoalStateModeler(container) { +export default function TerminationConditionModeler(container) { container = $(container).get(0); var root = document.createElement('div'); - root.classList.add('gs-root'); + root.classList.add('tc-root'); container.appendChild(root); this._root = root; this.eventBus = new EventBus(); - this.moddle = new GoalStateModdle(); + this.moddle = new TerminationConditionModdle(); this._propagateEvent = event => { this.eventBus.fire('element.' + event.type, { originalEvent : event, element : {} }); @@ -26,31 +26,31 @@ export default function GoalStateModeler(container) { container.addEventListener('mousedown', this._propagateEvent, true); } -GoalStateModeler.prototype.showGoalState = function (goalState) { +TerminationConditionModeler.prototype.showTerminationCondition = function (terminationCondition) { this.clear(); - this._goalState = goalState; - if (!goalState) return; + this._terminationCondition = terminationCondition; + if (!terminationCondition) return; this._handlers = { - 'gs:Disjunction': this.createDisjunctionElement, - 'gs:Conjunction': this.createConjunctionElement, - 'gs:Literal': this.createLiteralElement + 'tc:Disjunction': this.createDisjunctionElement, + 'tc:Conjunction': this.createConjunctionElement, + 'tc:Literal': this.createLiteralElement } - this.handleStatement(this._root, goalState); + this.handleStatement(this._root, terminationCondition); } -GoalStateModeler.prototype.handleStatement = function (parentElement, statement) { +TerminationConditionModeler.prototype.handleStatement = function (parentElement, statement) { var element = this._handlers[statement.$type].call(this, parentElement, statement); statement.element = element; element.statement = statement; return element; } -GoalStateModeler.prototype.createDisjunctionElement = function (parentElement, disjunction) { +TerminationConditionModeler.prototype.createDisjunctionElement = function (parentElement, disjunction) { var element = this.createOperationElement(parentElement, disjunction); var addConjunctionButton = document.createElement('button'); addConjunctionButton.innerHTML = '+'; addConjunctionButton.addEventListener('click', event => { - var newConjunction = this.moddle.create('gs:Conjunction', {operands: [] }); + var newConjunction = this.moddle.create('tc:Conjunction', {operands: [] }); disjunction.operands.push(newConjunction); element.addOperand(newConjunction); this.addLiteral(newConjunction); @@ -59,7 +59,7 @@ GoalStateModeler.prototype.createDisjunctionElement = function (parentElement, d return element; } -GoalStateModeler.prototype.createConjunctionElement = function (parentElement, conjunction) { +TerminationConditionModeler.prototype.createConjunctionElement = function (parentElement, conjunction) { var element = this.createOperationElement(parentElement, conjunction); var addLiteralButton = document.createElement('button'); addLiteralButton.innerHTML = '+'; @@ -68,20 +68,20 @@ GoalStateModeler.prototype.createConjunctionElement = function (parentElement, c return element; } -GoalStateModeler.prototype.addLiteral = function (parentStatement) { - var newLiteral = this.moddle.create('gs:Literal', {class: this.getClassList()[0], states: [] }); +TerminationConditionModeler.prototype.addLiteral = function (parentStatement) { + var newLiteral = this.moddle.create('tc:Literal', {class: this.getClassList()[0], states: [] }); parentStatement.operands.push(newLiteral); parentStatement.element.addOperand(newLiteral); } -GoalStateModeler.prototype.createOperationElement = function (parentElement, operation) { +TerminationConditionModeler.prototype.createOperationElement = function (parentElement, operation) { operation.get('operands'); var element = document.createElement('div'); - element.classList.add('gs-operation'); - element.classList.add('gs-' + type(operation).toLowerCase()); + element.classList.add('tc-operation'); + element.classList.add('tc-' + type(operation).toLowerCase()); var operandsElement = document.createElement('div'); - operandsElement.classList.add('gs-operands'); + operandsElement.classList.add('tc-operands'); element.appendChild(operandsElement); element.operandsElement = operandsElement; @@ -96,20 +96,20 @@ GoalStateModeler.prototype.createOperationElement = function (parentElement, ope this.deleteStatement(operand); }); operandElement.appendChild(deleteButton); - this.eventBus.fire(GoalStateEvents.GOALSTATE_CHANGED, {}); + this.eventBus.fire(TerminationConditionEvents.TERMINATIONCONDITION_CHANGED, {}); } operation.operands.forEach(element.addOperand); parentElement.appendChild(element); return element; } -GoalStateModeler.prototype.createLiteralElement = function (parentElement, literal) { +TerminationConditionModeler.prototype.createLiteralElement = function (parentElement, literal) { var element = document.createElement('div'); - element.classList.add('gs-literal'); - var classElement = makeDiv('', 'gs-dataclass'); + element.classList.add('tc-literal'); + var classElement = makeDiv('', 'tc-dataclass'); element.appendChild(classElement); element.classElement = classElement; - var stateElement = makeDiv('', 'gs-datastate'); + var stateElement = makeDiv('', 'tc-datastate'); element.appendChild(stateElement); element.stateElement = stateElement; parentElement.append(element); @@ -122,7 +122,7 @@ GoalStateModeler.prototype.createLiteralElement = function (parentElement, liter return element; } -GoalStateModeler.prototype.populateLiteral = function (literal, element) { +TerminationConditionModeler.prototype.populateLiteral = function (literal, element) { var { classElement, stateElement } = element; classElement.innerText = literal.class.name; @@ -180,12 +180,12 @@ GoalStateModeler.prototype.populateLiteral = function (literal, element) { stateElement.appendChild(stateElement.dropdown); } -GoalStateModeler.prototype.clear = function () { +TerminationConditionModeler.prototype.clear = function () { var root = this._root; while (root.firstChild) root.removeChild(root.lastChild); } -GoalStateModeler.prototype.changeClass = function (clazz, literal) { +TerminationConditionModeler.prototype.changeClass = function (clazz, literal) { if (literal.class !== clazz) { literal.class = clazz; literal.states = []; @@ -193,7 +193,7 @@ GoalStateModeler.prototype.changeClass = function (clazz, literal) { } } -GoalStateModeler.prototype.toggleState = function (state, literal) { +TerminationConditionModeler.prototype.toggleState = function (state, literal) { if (literal.states.includes(state)) { literal.states = without(literal.states, state); } else { @@ -202,30 +202,30 @@ GoalStateModeler.prototype.toggleState = function (state, literal) { this.populateLiteral(literal, literal.element); } -GoalStateModeler.prototype.deleteStatement = function (statement) { +TerminationConditionModeler.prototype.deleteStatement = function (statement) { var element = statement.element; var parentStatement = statement.$parent; var parentElement = parentStatement.element; parentStatement.operands = without(parentStatement.operands, statement); parentElement.operandsElement.removeChild(element); - this.eventBus.fire(GoalStateEvents.GOALSTATE_CHANGED, {}); + this.eventBus.fire(TerminationConditionEvents.TERMINATIONCONDITION_CHANGED, {}); if (parentStatement.operands.length === 0 && parentStatement.$parent) { this.deleteStatement(parentStatement); } } -GoalStateModeler.prototype.handleStatesChanged = function (clazz, newStates) { +TerminationConditionModeler.prototype.handleStatesChanged = function (clazz, newStates) { //TODO } -GoalStateModeler.prototype.handleOlcListChanged = function (classes) { +TerminationConditionModeler.prototype.handleOlcListChanged = function (classes) { this._classList = classes; if (classes.length === 0) { this._root.classList.add('no-dataclass'); } else { this._root.classList.remove('no-dataclass'); } - if (this._goalState) { + if (this._terminationCondition) { var literalsToDelete = []; this.forEachLiteral(literal => { if (!classes.includes(literal.class)) { @@ -241,7 +241,7 @@ GoalStateModeler.prototype.handleOlcListChanged = function (classes) { } } -GoalStateModeler.prototype.getLiteralsWithClassId = function (id) { +TerminationConditionModeler.prototype.getLiteralsWithClassId = function (id) { var literalsOfClass = []; this.forEachLiteral(literal => { if (literal.class.id === id) { @@ -251,7 +251,7 @@ GoalStateModeler.prototype.getLiteralsWithClassId = function (id) { return literalsOfClass; } -GoalStateModeler.prototype.getLiteralsWithState = function (state) { +TerminationConditionModeler.prototype.getLiteralsWithState = function (state) { const literalsWithState = []; this.forEachLiteral(literal => { if (literal.states.includes(state)) { @@ -261,7 +261,7 @@ GoalStateModeler.prototype.getLiteralsWithState = function (state) { return literalsWithState; } -GoalStateModeler.prototype.handleStateRenamed = function (state) { +TerminationConditionModeler.prototype.handleStateRenamed = function (state) { this.forEachLiteral(literal => { if (literal.states.includes(state)) { this.populateLiteral(literal, literal.element); @@ -269,7 +269,7 @@ GoalStateModeler.prototype.handleStateRenamed = function (state) { }); } -GoalStateModeler.prototype.handleStateDeleted = function (state) { +TerminationConditionModeler.prototype.handleStateDeleted = function (state) { this.forEachLiteral(literal => { if (literal.states.includes(state)) { literal.states = without(literal.states, state); @@ -278,14 +278,14 @@ GoalStateModeler.prototype.handleStateDeleted = function (state) { }); } -GoalStateModeler.prototype.getLiterals = function() { +TerminationConditionModeler.prototype.getLiterals = function() { //TODO refactor to use getStatements - if (!this._goalState) return undefined; - const statementsToVisit = [this._goalState]; + if (!this._terminationCondition) return undefined; + const statementsToVisit = [this._terminationCondition]; const visitedLiterals = []; while (statementsToVisit.length > 0) { var nextStatement = statementsToVisit.shift(); - if (is(nextStatement, 'gs:Literal')) { + if (is(nextStatement, 'tc:Literal')) { visitedLiterals.push(nextStatement); } else { statementsToVisit.push(...nextStatement.operands); @@ -294,46 +294,46 @@ GoalStateModeler.prototype.getLiterals = function() { return visitedLiterals; } -GoalStateModeler.prototype.getStatements = function() { - if (!this._goalState) return undefined; - const statementsToVisit = [this._goalState]; +TerminationConditionModeler.prototype.getStatements = function() { + if (!this._terminationCondition) return undefined; + const statementsToVisit = [this._terminationCondition]; const visitedStatements = []; while (statementsToVisit.length > 0) { var nextStatement = statementsToVisit.shift(); visitedStatements.push(nextStatement); - if (is(nextStatement, 'gs:Operation')) { + if (is(nextStatement, 'tc:Operation')) { statementsToVisit.push(...nextStatement.operands); } } return visitedStatements; } -GoalStateModeler.prototype.forEachLiteral = function(consumer) { +TerminationConditionModeler.prototype.forEachLiteral = function(consumer) { return this.getLiterals().forEach(consumer); } -GoalStateModeler.prototype.getClassList = function () { +TerminationConditionModeler.prototype.getClassList = function () { return this._classList || []; } -GoalStateModeler.prototype.getStateList = function (clazz) { +TerminationConditionModeler.prototype.getStateList = function (clazz) { return clazz.get('Elements').filter(element => is(element, 'olc:State')); } -GoalStateModeler.prototype.getGoalState = function () { - return this._goalState; +TerminationConditionModeler.prototype.getTerminationCondition = function () { + return this._terminationCondition; } -GoalStateModeler.prototype.createNew = function () { - this.showGoalState(this.moddle.create( - 'gs:Disjunction', +TerminationConditionModeler.prototype.createNew = function () { + this.showTerminationCondition(this.moddle.create( + 'tc:Disjunction', { operands: [] } )); } -GoalStateModeler.prototype.saveXML = function (options = {}) { +TerminationConditionModeler.prototype.saveXML = function (options = {}) { return new Promise((resolve, reject) => { - this.moddle.toXML(this._goalState, options).then(function (result) { + this.moddle.toXML(this._terminationCondition, options).then(function (result) { return resolve({ xml: result.xml }); }).catch(function (err) { return reject(err); @@ -341,11 +341,11 @@ GoalStateModeler.prototype.saveXML = function (options = {}) { }); }; -GoalStateModeler.prototype.importXML = function (xml) { +TerminationConditionModeler.prototype.importXML = function (xml) { return new Promise((resolve, reject) => { this.moddle.fromXML(xml).then((result) => { this.eventBus.fire('import.parse.complete', result); - this.showGoalState(result.rootElement); + this.showTerminationCondition(result.rootElement); resolve(); }).catch(function (err) { return reject(err); diff --git a/app/lib/goalstatemodeler/gs.json b/app/lib/terminationconditionmodeler/tc.json similarity index 92% rename from app/lib/goalstatemodeler/gs.json rename to app/lib/terminationconditionmodeler/tc.json index e074d326..db867faa 100644 --- a/app/lib/goalstatemodeler/gs.json +++ b/app/lib/terminationconditionmodeler/tc.json @@ -1,56 +1,56 @@ -{ - "name": "Goal State", - "uri": "http://bptlab/schema/gs", - "prefix": "gs", - "xml": { - "tagAlias": "lowerCase" - }, - "types": [ - { - "name": "Statement", - "isAbstract": true, - "properties": [] - }, - { - "name": "Operation", - "isAbstract": true, - "superClass": ["Statement"], - "properties": [ - { - "name": "operands", - "isMany": true, - "type": "Statement" - } - ] - }, - { - "name": "Conjunction", - "superClass": ["Operation"], - "properties": [] - }, - { - "name": "Disjunction", - "superClass": ["Operation"], - "properties": [] - }, - { - "name": "Literal", - "superClass": ["Statement"], - "properties": [ - { - "name": "class", - "isAttr": true, - "isReference": true, - "type": "od:Class" - }, - { - "name": "states", - "isAttr": true, - "isReference": true, - "type": "olc:State", - "isMany": true - } - ] - } - ] +{ + "name": "Termination State", + "uri": "http://bptlab/schema/gs", + "prefix": "tc", + "xml": { + "tagAlias": "lowerCase" + }, + "types": [ + { + "name": "Statement", + "isAbstract": true, + "properties": [] + }, + { + "name": "Operation", + "isAbstract": true, + "superClass": ["Statement"], + "properties": [ + { + "name": "operands", + "isMany": true, + "type": "Statement" + } + ] + }, + { + "name": "Conjunction", + "superClass": ["Operation"], + "properties": [] + }, + { + "name": "Disjunction", + "superClass": ["Operation"], + "properties": [] + }, + { + "name": "Literal", + "superClass": ["Statement"], + "properties": [ + { + "name": "class", + "isAttr": true, + "isReference": true, + "type": "od:Class" + }, + { + "name": "states", + "isAttr": true, + "isReference": true, + "type": "olc:State", + "isMany": true + } + ] + } + ] } \ No newline at end of file diff --git a/app/lib/goalstatemodeler/goalstatemodeler.less b/app/lib/terminationconditionmodeler/terminationconditionmodeler.less similarity index 54% rename from app/lib/goalstatemodeler/goalstatemodeler.less rename to app/lib/terminationconditionmodeler/terminationconditionmodeler.less index 0c20315f..53e7f042 100644 --- a/app/lib/goalstatemodeler/goalstatemodeler.less +++ b/app/lib/terminationconditionmodeler/terminationconditionmodeler.less @@ -1,66 +1,66 @@ -.gs-root { - padding: 10px; - font-size: 16px; -} - -.gs-root.no-dataclass::before { - content: 'Please create data classes before modeling the goal state'; - color: gray; -} - -.gs-root.no-dataclass * { - visibility: hidden; -} - -.gs-conjunction > .gs-operands > .operand:not(:first-of-type):before { - content: " ∧ "; -} - -.gs-disjunction > .gs-operands > .operand:not(:first-of-type):before { - content: " ∨ " -} - -.gs-literal, .gs-operands { - display: inline; -} - -.gs-literal > button { - background-color: #29487D; - color:white; - border-width: 0px; -} - -.gs-operands { - margin-right: 20px; -} - -.gs-operation > button { - background-color: #29487D; - color: white; - border-width: 0px; - margin-right: 2px; -} - -.gs-operation, .gs-literal { - //border: 1px solid gray; - padding: 1px; - margin: 1px; - margin-top: 5px; - width: fit-content; - background-color: white; -} - -.gs-dataclass, .gs-datastate { - display: inline; - padding: 1px; - position: relative; - cursor: default; -} - -.gs-datastate{ - margin-right:5px; -} - -.gs-dataclass:hover, .gs-datastate:hover { - background-color: lightgray; +.tc-root { + padding: 10px; + font-size: 16px; +} + +.tc-root.no-dataclass::before { + content: 'Please create data classes before modeling the termination condition'; + color: gray; +} + +.tc-root.no-dataclass * { + visibility: hidden; +} + +.tc-conjunction > .tc-operands > .operand:not(:first-of-type):before { + content: " ∧ "; +} + +.tc-disjunction > .tc-operands > .operand:not(:first-of-type):before { + content: " ∨ " +} + +.tc-literal, .tc-operands { + display: inline; +} + +.tc-literal > button { + background-color: #29487D; + color:white; + border-width: 0px; +} + +.tc-operands { + margin-right: 20px; +} + +.tc-operation > button { + background-color: #29487D; + color: white; + border-width: 0px; + margin-right: 2px; +} + +.tc-operation, .tc-literal { + //border: 1px solid gray; + padding: 1px; + margin: 1px; + margin-top: 5px; + width: fit-content; + background-color: white; +} + +.tc-dataclass, .tc-datastate { + display: inline; + padding: 1px; + position: relative; + cursor: default; +} + +.tc-datastate{ + margin-right:5px; +} + +.tc-dataclass:hover, .tc-datastate:hover { + background-color: lightgray; } \ No newline at end of file diff --git a/resources/conferenceModel/goalState.xml b/resources/conferenceModel/terminationCondition.xml similarity index 100% rename from resources/conferenceModel/goalState.xml rename to resources/conferenceModel/terminationCondition.xml