Skip to content

Commit

Permalink
#74 rename goal state to termination condition (#89)
Browse files Browse the repository at this point in the history
*  rename goal state to termination condition
  • Loading branch information
Franka-T authored Mar 22, 2023
1 parent 482f082 commit 95405aa
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 283 deletions.
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ <h3 class="focusHeader">Objective Model <i class="material-icons focusHeaderIcon
<div class="content bottom">
<div class="content top">
<div class="content top">
<div id="goalstate-canvas" class="canvas">
<div id="terminationcondition-canvas" class="canvas">
<div class="canvasHeader" style="position:relative">
<h3 class="focusHeader">Goal State <i class="material-icons focusHeaderIcon">photo_size_select_small</i></h3>
<h3 class="focusHeader">Termination Condition <i class="material-icons focusHeaderIcon">photo_size_select_small</i></h3>
<a class="questionButton" href="https://github.com/bptlab/fCM-design-support/wiki/Goal-State" target="_blank">?</a>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -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);



Expand All @@ -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'}));
}

Expand All @@ -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();
}
Expand Down Expand Up @@ -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'});
Expand All @@ -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 => {
Expand All @@ -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();
}
Expand Down
3 changes: 0 additions & 3 deletions app/lib/goalstatemodeler/GoalStateEvents.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/lib/guidelines/Checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions app/lib/guidelines/Guidelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
87 changes: 44 additions & 43 deletions app/lib/mediator/Mediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -228,21 +228,21 @@ 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 + '\" ?'
+ '\n' + 'It would be removed from ' + affectedLiterals.length + ' literal(s) and '+ affectedDataObjectReferences.length + ' data object reference(s) and '+ affectedObjects.length + ' object(s).');
}

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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -635,4 +598,42 @@ Mediator.prototype.OlcModelerHook.$inject = [
'olcModeler'
];

Mediator.prototype.OlcModelerHook.isHook = true;
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
TERMINATIONCONDITION_CHANGED : 'tc.changed',
}
Original file line number Diff line number Diff line change
@@ -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);
}
});
};
Loading

0 comments on commit 95405aa

Please sign in to comment.