@jylups/cmmn-js 0.0.0-stage → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/CHANGELOG.md +119 -0
- package/LICENSE +23 -0
- package/README.md +107 -2
- package/dist/assets/cmmn-font/css/cmmn-codes.css +41 -0
- package/dist/assets/cmmn-font/css/cmmn-embedded.css +94 -0
- package/dist/assets/cmmn-font/css/cmmn.css +97 -0
- package/dist/assets/cmmn-font/font/cmmn.eot +0 -0
- package/dist/assets/cmmn-font/font/cmmn.svg +90 -0
- package/dist/assets/cmmn-font/font/cmmn.ttf +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff2 +0 -0
- package/dist/assets/diagram-js.css +713 -0
- package/dist/cmmn-modeler.development.js +44817 -0
- package/dist/cmmn-modeler.production.min.js +2 -0
- package/dist/cmmn-navigated-viewer.development.js +18131 -0
- package/dist/cmmn-navigated-viewer.production.min.js +2 -0
- package/dist/cmmn-viewer.development.js +17599 -0
- package/dist/cmmn-viewer.production.min.js +2 -0
- package/index.js +1 -0
- package/lib/Modeler.js +222 -0
- package/lib/NavigatedViewer.js +28 -0
- package/lib/Viewer.js +489 -0
- package/lib/core/ItemRegistry.js +316 -0
- package/lib/core/index.js +7 -0
- package/lib/draw/CmmnRenderer.js +1235 -0
- package/lib/draw/PathMap.js +335 -0
- package/lib/draw/index.js +5 -0
- package/lib/features/auto-resize/CmmnAutoResizeProvider.js +57 -0
- package/lib/features/auto-resize/index.js +7 -0
- package/lib/features/context-pad/ContextPadProvider.js +240 -0
- package/lib/features/context-pad/index.js +11 -0
- package/lib/features/editor-actions/CmmnEditorActions.js +105 -0
- package/lib/features/editor-actions/index.js +10 -0
- package/lib/features/keyboard/CmmnKeyboardBindings.js +159 -0
- package/lib/features/keyboard/index.js +7 -0
- package/lib/features/label-editing/LabelEditingProvider.js +221 -0
- package/lib/features/label-editing/LabelUtil.js +95 -0
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +63 -0
- package/lib/features/label-editing/index.js +9 -0
- package/lib/features/modeling/CmmnFactory.js +166 -0
- package/lib/features/modeling/CmmnLayouter.js +49 -0
- package/lib/features/modeling/CmmnUpdater.js +511 -0
- package/lib/features/modeling/ElementFactory.js +215 -0
- package/lib/features/modeling/Modeling.js +185 -0
- package/lib/features/modeling/behavior/AttachCriterionBehavior.js +58 -0
- package/lib/features/modeling/behavior/CaseFileItemUpdater.js +324 -0
- package/lib/features/modeling/behavior/LabelBehavior.js +139 -0
- package/lib/features/modeling/behavior/PlanItemDefinitionUpdater.js +449 -0
- package/lib/features/modeling/behavior/PlanningTableUpdater.js +620 -0
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +320 -0
- package/lib/features/modeling/behavior/ReplaceElementBehavior.js +395 -0
- package/lib/features/modeling/behavior/ResizeCasePlanModelBehavior.js +108 -0
- package/lib/features/modeling/behavior/SentryUpdater.js +678 -0
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +28 -0
- package/lib/features/modeling/behavior/index.js +24 -0
- package/lib/features/modeling/cmd/AppendShapeHandler.js +52 -0
- package/lib/features/modeling/cmd/IdClaimHandler.js +38 -0
- package/lib/features/modeling/cmd/ReconnectConnectionHandler.js +57 -0
- package/lib/features/modeling/cmd/ReplaceShapeHandler.js +46 -0
- package/lib/features/modeling/cmd/UpdateControlsHandler.js +221 -0
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +240 -0
- package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +94 -0
- package/lib/features/modeling/index.js +20 -0
- package/lib/features/modeling/util/ModelingUtil.js +138 -0
- package/lib/features/modeling/util/PlanItemDefinitionUtil.js +183 -0
- package/lib/features/ordering/CmmnOrderingProvider.js +146 -0
- package/lib/features/ordering/index.js +4 -0
- package/lib/features/outline/Outline.js +47 -0
- package/lib/features/outline/index.js +6 -0
- package/lib/features/palette/PaletteProvider.js +171 -0
- package/lib/features/palette/index.js +12 -0
- package/lib/features/popup-menu/ReplaceMenuProvider.js +448 -0
- package/lib/features/popup-menu/index.js +4 -0
- package/lib/features/replace/CmmnReplace.js +355 -0
- package/lib/features/replace/ReplaceOptions.js +241 -0
- package/lib/features/replace/index.js +8 -0
- package/lib/features/replace-preview/CmmnReplacePreview.js +247 -0
- package/lib/features/replace-preview/index.js +7 -0
- package/lib/features/rules/CmmnRules.js +1040 -0
- package/lib/features/rules/index.js +7 -0
- package/lib/features/search/CmmnSearchProvider.js +129 -0
- package/lib/features/search/index.js +7 -0
- package/lib/features/snapping/CmmnConnectSnapping.js +110 -0
- package/lib/features/snapping/CmmnCreateMoveSnapping.js +148 -0
- package/lib/features/snapping/CmmnResizeSnapping.js +42 -0
- package/lib/features/snapping/CmmnSnappingUtil.js +76 -0
- package/lib/features/snapping/index.js +17 -0
- package/lib/import/CmmnImporter.js +251 -0
- package/lib/import/CmmnTreeWalker.js +410 -0
- package/lib/import/Importer.js +73 -0
- package/lib/import/Util.js +9 -0
- package/lib/import/index.js +3 -0
- package/lib/util/DiUtil.js +39 -0
- package/lib/util/LabelUtil.js +124 -0
- package/lib/util/ModelUtil.js +257 -0
- package/lib/util/PoweredByUtil.js +91 -0
- package/package.json +88 -4
- package/test/helper/index.js +231 -0
- package/test/util/KeyEvents.js +23 -0
- package/test/util/MockEvents.js +55 -0
- package/test/util/custom-rules/CustomRules.js +19 -0
- package/test/util/custom-rules/index.js +4 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inherits = require('inherits');
|
|
4
|
+
|
|
5
|
+
var forEach = require('min-dash').forEach,
|
|
6
|
+
unionBy = require('min-dash').unionBy,
|
|
7
|
+
filter = require('min-dash').filter;
|
|
8
|
+
|
|
9
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
10
|
+
|
|
11
|
+
var ModelUtil = require('../../../util/ModelUtil'),
|
|
12
|
+
is = ModelUtil.is,
|
|
13
|
+
getDefinition = ModelUtil.getDefinition,
|
|
14
|
+
getBusinessObject = ModelUtil.getBusinessObject;
|
|
15
|
+
|
|
16
|
+
var ModelingUtil = require('../util/ModelingUtil'),
|
|
17
|
+
getParents = ModelingUtil.getParents,
|
|
18
|
+
getParent = ModelingUtil.getParent,
|
|
19
|
+
getCase = ModelingUtil.getCase,
|
|
20
|
+
isLabel = ModelingUtil.isLabel;
|
|
21
|
+
|
|
22
|
+
var PlanItemDefinitionUtil = require('../util/PlanItemDefinitionUtil'),
|
|
23
|
+
getAllDiscretionaryItems = PlanItemDefinitionUtil.getAllDiscretionaryItems,
|
|
24
|
+
getDirectItemCapables = PlanItemDefinitionUtil.getDirectItemCapables,
|
|
25
|
+
isItemCapable = PlanItemDefinitionUtil.isItemCapable,
|
|
26
|
+
isHumanTask = PlanItemDefinitionUtil.isHumanTask;
|
|
27
|
+
|
|
28
|
+
var LOW_PRIORITY = 400;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A handler responsible for updating the parent relation of a plan item definition
|
|
32
|
+
* to the underlying CMMN 1.1 XML once changes on the diagram happen.
|
|
33
|
+
*/
|
|
34
|
+
function PlanItemDefinitionUpdater(
|
|
35
|
+
eventBus,
|
|
36
|
+
modeling,
|
|
37
|
+
cmmnReplace,
|
|
38
|
+
itemRegistry
|
|
39
|
+
) {
|
|
40
|
+
|
|
41
|
+
this._modeling = modeling;
|
|
42
|
+
this._cmmnReplace = cmmnReplace;
|
|
43
|
+
this._itemRegistry = itemRegistry;
|
|
44
|
+
|
|
45
|
+
var self = this;
|
|
46
|
+
|
|
47
|
+
CommandInterceptor.call(this, eventBus);
|
|
48
|
+
|
|
49
|
+
var containment = 'planItemDefinitions';
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// CREATION //////////////////////////////////////////////////////////
|
|
53
|
+
|
|
54
|
+
this.postExecuted('shape.create', function(context) {
|
|
55
|
+
|
|
56
|
+
var shape = context.shape;
|
|
57
|
+
|
|
58
|
+
if (!isItemCapable(shape)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var item = getBusinessObject(shape),
|
|
63
|
+
definition = getDefinition(item),
|
|
64
|
+
parent = getParentStage(item);
|
|
65
|
+
|
|
66
|
+
if (!getParent(definition)) {
|
|
67
|
+
modeling.updateSemanticParent(definition, parent, containment);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}, true);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
this.postExecuted('shape.replace', function(context) {
|
|
74
|
+
|
|
75
|
+
var newShape = context.newShape;
|
|
76
|
+
|
|
77
|
+
if (!isItemCapable(newShape)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
self.updatePlanItemDefinitions([ newShape ]);
|
|
82
|
+
|
|
83
|
+
}, true);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// DELETION //////////////////////////////////////////////////////////
|
|
87
|
+
|
|
88
|
+
this.postExecuted('shape.delete', function(context) {
|
|
89
|
+
|
|
90
|
+
var shape = context.shape,
|
|
91
|
+
definition,
|
|
92
|
+
update = {};
|
|
93
|
+
|
|
94
|
+
if (!isItemCapable(shape) || isLabel(shape)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
definition = getDefinition(shape);
|
|
99
|
+
update[definition.id] = definition;
|
|
100
|
+
self.deletePlanItemDefinitions(update);
|
|
101
|
+
|
|
102
|
+
}, true);
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
this.preExecuted('shape.delete', function(context) {
|
|
106
|
+
|
|
107
|
+
var shape = context.shape,
|
|
108
|
+
definition = getDefinition(shape);
|
|
109
|
+
|
|
110
|
+
if (!isHumanTask(definition) || definition.$parent) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// get remaining discretionary items
|
|
115
|
+
context.discretionaryItems = context.discretionaryItems || getAllDiscretionaryItems(definition);
|
|
116
|
+
|
|
117
|
+
}, true);
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
this.postExecuted('shape.delete', LOW_PRIORITY, function(context) {
|
|
121
|
+
|
|
122
|
+
var discretionaryItems = context.discretionaryItems,
|
|
123
|
+
shapes = [];
|
|
124
|
+
|
|
125
|
+
forEach(discretionaryItems, function(item) {
|
|
126
|
+
var shapeItem = itemRegistry.getShape(item.id);
|
|
127
|
+
|
|
128
|
+
if (shapeItem) {
|
|
129
|
+
shapes.push(shapeItem);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (shapes && shapes.length) {
|
|
135
|
+
self.updatePlanItemDefinitions(shapes);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}, true);
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// MOVING //////////////////////////////////////////////////////////////
|
|
142
|
+
|
|
143
|
+
this.preExecuted('elements.move', function(context) {
|
|
144
|
+
|
|
145
|
+
var allShapes = context.closure.allShapes,
|
|
146
|
+
newParent = context.newParent,
|
|
147
|
+
hints = context.hints,
|
|
148
|
+
oldParent = hints && hints.primaryShape && hints.primaryShape.parent,
|
|
149
|
+
replacements = {},
|
|
150
|
+
shapes, // array of moved item capables
|
|
151
|
+
movedItemCapables = {}, // grouped by definition
|
|
152
|
+
newTargetCase;
|
|
153
|
+
|
|
154
|
+
if (!newParent || oldParent === newParent) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
newTargetCase = getCase(newParent);
|
|
159
|
+
|
|
160
|
+
shapes = filter(allShapes, function(shape) {
|
|
161
|
+
|
|
162
|
+
if (isItemCapable(shape) && !isLabel(shape) && getCase(shape) !== newTargetCase) {
|
|
163
|
+
|
|
164
|
+
var definition = getDefinition(shape);
|
|
165
|
+
movedItemCapables[definition.id] = movedItemCapables[definition.id] || [];
|
|
166
|
+
movedItemCapables[definition.id].push(shape);
|
|
167
|
+
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return false;
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
forEach(shapes, function(shape) {
|
|
176
|
+
|
|
177
|
+
var definition = getDefinition(shape),
|
|
178
|
+
referencedBy,
|
|
179
|
+
movedShapes,
|
|
180
|
+
newDefinition;
|
|
181
|
+
|
|
182
|
+
if (replacements[definition.id]) {
|
|
183
|
+
newDefinition = replacements[definition.id];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
else {
|
|
187
|
+
|
|
188
|
+
referencedBy = itemRegistry.getReferences(definition.id);
|
|
189
|
+
movedShapes = movedItemCapables[definition.id];
|
|
190
|
+
|
|
191
|
+
if (referencedBy.length > movedShapes.length) {
|
|
192
|
+
newDefinition = replacements[definition.id] = cmmnReplace.replacePlanItemDefinition(definition);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (newDefinition && newDefinition !== definition) {
|
|
198
|
+
modeling.updateProperties(shape, {
|
|
199
|
+
definitionRef: newDefinition
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// remember replacement of definitions
|
|
206
|
+
context.definitionReplacements = replacements;
|
|
207
|
+
|
|
208
|
+
}, true);
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
this.postExecuted('elements.move', LOW_PRIORITY, function(context) {
|
|
212
|
+
|
|
213
|
+
var shapes = context.shapes,
|
|
214
|
+
newParent = context.newParent,
|
|
215
|
+
oldParent = (context.hints && context.hints.oldParent);
|
|
216
|
+
|
|
217
|
+
if (!newParent || oldParent === newParent) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
shapes = filter(shapes, function(shape) {
|
|
222
|
+
return isItemCapable(shape) && !isLabel(shape);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
if (shapes && shapes.length) {
|
|
226
|
+
self.updatePlanItemDefinitions(shapes);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}, true);
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
// CONNECTIONS //////////////////////////////////////////////////////////////
|
|
233
|
+
|
|
234
|
+
this.postExecuted([
|
|
235
|
+
'connection.create',
|
|
236
|
+
'connection.delete',
|
|
237
|
+
'connection.reconnectEnd',
|
|
238
|
+
'connection.reconnectStart'
|
|
239
|
+
], LOW_PRIORITY, function(context) {
|
|
240
|
+
|
|
241
|
+
var connection = context.connection,
|
|
242
|
+
source = context.newSource || context.source || connection.source,
|
|
243
|
+
target = context.newTarget || context.target || connection.target,
|
|
244
|
+
shapes = [];
|
|
245
|
+
|
|
246
|
+
if (!isDiscretionaryConnection(connection, source, target)) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (connection.target) {
|
|
251
|
+
shapes.push(connection.target);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (!connection.target && context.target) {
|
|
255
|
+
shapes.push(context.target);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (context.oldTarget) {
|
|
259
|
+
shapes.push(context.oldTarget);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (shapes && shapes.length) {
|
|
263
|
+
self.updatePlanItemDefinitions(shapes);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
}, true);
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
// API ////////////////////////////////////////////////////////
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Deletes the given plan item definitions.
|
|
273
|
+
*
|
|
274
|
+
* A plan item definition is deleted when it is not
|
|
275
|
+
* referenced by a plan item or a discretionary item.
|
|
276
|
+
*
|
|
277
|
+
* @param {Array<ModdleElement>} definitions to delete
|
|
278
|
+
*/
|
|
279
|
+
this.deletePlanItemDefinitions = function(definitions) {
|
|
280
|
+
var references;
|
|
281
|
+
|
|
282
|
+
forEach(definitions, function(definition) {
|
|
283
|
+
references = itemRegistry.getReferences(definition);
|
|
284
|
+
if (!references.length) {
|
|
285
|
+
modeling.updateSemanticParent(definition, null, containment);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Rearrange the plan item definitions of the given shapes.
|
|
294
|
+
*
|
|
295
|
+
* @param {Array<djs.model.Base>} shapes
|
|
296
|
+
*/
|
|
297
|
+
this.updatePlanItemDefinitions = function(shapes) {
|
|
298
|
+
|
|
299
|
+
handleEachItemCapable(shapes, function(shape) {
|
|
300
|
+
|
|
301
|
+
var item = getBusinessObject(shape),
|
|
302
|
+
definition = getDefinition(item),
|
|
303
|
+
references = itemRegistry.getReferences(definition),
|
|
304
|
+
sharedParent = getSharedParent(references);
|
|
305
|
+
|
|
306
|
+
if (!sharedParent) {
|
|
307
|
+
sharedParent = getCasePlanModel(item);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (sharedParent && sharedParent !== definition.$parent) {
|
|
311
|
+
modeling.updateSemanticParent(definition, sharedParent, containment);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
var itemCapables = getDirectItemCapables(definition),
|
|
315
|
+
children = [];
|
|
316
|
+
|
|
317
|
+
if (is(definition, 'cmmn:PlanFragment') && shape.children && shape.children.length) {
|
|
318
|
+
forEach(shape.children, function(child) {
|
|
319
|
+
var bo = getBusinessObject(child);
|
|
320
|
+
if (isItemCapable(bo) && !isLabel(bo) && itemCapables.indexOf(bo) === -1) {
|
|
321
|
+
children.push(bo);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return unionBy('id', itemCapables, children);
|
|
328
|
+
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
// UTILITIES ///////////////////////////////////////////////////////////////
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
function handleEachItemCapable(elements, fn) {
|
|
338
|
+
|
|
339
|
+
var handledElements = {};
|
|
340
|
+
|
|
341
|
+
function handled(element) {
|
|
342
|
+
handledElements[element.id] = element;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function isHandled(element) {
|
|
346
|
+
return !!handledElements[element.id];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function eachElement(elements, isRoot) {
|
|
350
|
+
forEach(elements, function(element) {
|
|
351
|
+
|
|
352
|
+
if (!isHandled(element)) {
|
|
353
|
+
handled(element);
|
|
354
|
+
|
|
355
|
+
element = itemRegistry.getShape(element.id) || element;
|
|
356
|
+
var children = fn(element);
|
|
357
|
+
|
|
358
|
+
if (children && children.length) {
|
|
359
|
+
eachElement(children);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (isRoot) {
|
|
364
|
+
handledElements = {};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
eachElement(elements, true);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
PlanItemDefinitionUpdater.$inject = [
|
|
376
|
+
'eventBus',
|
|
377
|
+
'modeling',
|
|
378
|
+
'cmmnReplace',
|
|
379
|
+
'itemRegistry'
|
|
380
|
+
];
|
|
381
|
+
|
|
382
|
+
inherits(PlanItemDefinitionUpdater, CommandInterceptor);
|
|
383
|
+
|
|
384
|
+
module.exports = PlanItemDefinitionUpdater;
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Utilities
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
function getSharedParent(elements) {
|
|
392
|
+
|
|
393
|
+
var sharedParent,
|
|
394
|
+
first;
|
|
395
|
+
|
|
396
|
+
if (elements.length) {
|
|
397
|
+
|
|
398
|
+
first = elements.splice(0, 1)[0];
|
|
399
|
+
|
|
400
|
+
if (!elements.length) {
|
|
401
|
+
sharedParent = getParentStage(first);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
var candidates = getParentStages(first);
|
|
405
|
+
forEach(elements, function(e) {
|
|
406
|
+
candidates = intersection(candidates, getParentStages(e));
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
sharedParent = candidates[0];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return sharedParent;
|
|
415
|
+
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
function getParentStage(element) {
|
|
420
|
+
element = getBusinessObject(element);
|
|
421
|
+
return getParent(element, 'cmmn:Stage');
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
function getParentStages(element) {
|
|
426
|
+
element = getBusinessObject(element);
|
|
427
|
+
return getParents(element, 'cmmn:Stage');
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
function getCasePlanModel(element) {
|
|
432
|
+
var _case = getParent(element, 'cmmn:Case');
|
|
433
|
+
return _case && _case.casePlanModel;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
function isDiscretionaryConnection(connection, source, target) {
|
|
438
|
+
return !connection.businessObject.cmmnElementRef;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
// helpers /////////////////
|
|
443
|
+
|
|
444
|
+
function intersection(a, b) {
|
|
445
|
+
|
|
446
|
+
return filter(a, function(e) {
|
|
447
|
+
return b.indexOf(e) !== -1;
|
|
448
|
+
});
|
|
449
|
+
}
|