@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,678 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inherits = require('inherits');
|
|
4
|
+
|
|
5
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
6
|
+
|
|
7
|
+
var forEach = require('min-dash').forEach,
|
|
8
|
+
flatten = require('min-dash').flatten,
|
|
9
|
+
groupBy = require('min-dash').groupBy,
|
|
10
|
+
map = require('min-dash').map,
|
|
11
|
+
some = require('min-dash').some;
|
|
12
|
+
|
|
13
|
+
var ModelUtil = require('../../../util/ModelUtil'),
|
|
14
|
+
is = ModelUtil.is,
|
|
15
|
+
isCasePlanModel = ModelUtil.isCasePlanModel,
|
|
16
|
+
getSentry = ModelUtil.getSentry,
|
|
17
|
+
getBusinessObject = ModelUtil.getBusinessObject,
|
|
18
|
+
getDefinition = ModelUtil.getDefinition,
|
|
19
|
+
getStandardEvents = ModelUtil.getStandardEvents;
|
|
20
|
+
|
|
21
|
+
var getParent = require('../util/ModelingUtil').getParent;
|
|
22
|
+
|
|
23
|
+
var PlanItemDefinitionUtil = require('../util/PlanItemDefinitionUtil'),
|
|
24
|
+
isItemCapable = PlanItemDefinitionUtil.isItemCapable,
|
|
25
|
+
getAllDiscretionaryItems = PlanItemDefinitionUtil.getAllDiscretionaryItems,
|
|
26
|
+
getDirectItemCapables = PlanItemDefinitionUtil.getDirectItemCapables,
|
|
27
|
+
isHumanTask = PlanItemDefinitionUtil.isHumanTask;
|
|
28
|
+
|
|
29
|
+
var VERY_LOW_PRIORITY = 300;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A handler responsible for adding, moving and deleting sentries.
|
|
33
|
+
* These changes are reflected to the underlying CMMN 1.1 XML.
|
|
34
|
+
*/
|
|
35
|
+
function SentryUpdater(eventBus, modeling, itemRegistry, cmmnReplace, cmmnFactory) {
|
|
36
|
+
|
|
37
|
+
var self = this;
|
|
38
|
+
|
|
39
|
+
CommandInterceptor.call(this, eventBus);
|
|
40
|
+
|
|
41
|
+
var containment = 'sentries';
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// CONNECTIONS ////////////////////////////////////////////////////////////
|
|
45
|
+
|
|
46
|
+
this.postExecuted('connection.create', function(context) {
|
|
47
|
+
|
|
48
|
+
var connection = context.connection;
|
|
49
|
+
|
|
50
|
+
if (!isOnPartConnection(connection)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var onPart = getOnPart(connection),
|
|
55
|
+
criterion = connection.target,
|
|
56
|
+
host = criterion.host,
|
|
57
|
+
sentry = getSentry(criterion);
|
|
58
|
+
|
|
59
|
+
if (!sentry) {
|
|
60
|
+
sentry = createSentry(criterion);
|
|
61
|
+
modeling.updateSemanticParent(sentry, getSentryParent(host), 'sentries');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
modeling.updateSemanticParent(onPart, sentry, 'onParts', connection);
|
|
65
|
+
|
|
66
|
+
}, true);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
this.preExecuted('connection.delete', function(context) {
|
|
70
|
+
|
|
71
|
+
var connection = context.connection;
|
|
72
|
+
|
|
73
|
+
if (!isOnPartConnection(connection)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var source = connection.source,
|
|
78
|
+
onPart = getOnPart(connection);
|
|
79
|
+
|
|
80
|
+
if (existsAnotherConnection(source, connection)) {
|
|
81
|
+
onPart = cloneOnPart(onPart);
|
|
82
|
+
setCmmnElementRef(connection, onPart);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
modeling.updateSemanticParent(onPart, null, 'onParts', connection);
|
|
86
|
+
|
|
87
|
+
}, true);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
this.preExecuted('connection.reconnectStart', function(context) {
|
|
91
|
+
|
|
92
|
+
var connection = context.connection,
|
|
93
|
+
source = connection.source;
|
|
94
|
+
|
|
95
|
+
if (!isOnPartConnection(connection)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var onPart = getOnPart(connection),
|
|
100
|
+
criterion = connection.target,
|
|
101
|
+
sentry = getSentry(criterion);
|
|
102
|
+
|
|
103
|
+
if (existsAnotherConnection(source, connection)) {
|
|
104
|
+
onPart = cloneOnPart(onPart);
|
|
105
|
+
setCmmnElementRef(connection, onPart);
|
|
106
|
+
modeling.updateSemanticParent(onPart, sentry, 'onParts', connection);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}, true);
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
this.preExecuted('connection.reconnectEnd', function(context) {
|
|
113
|
+
|
|
114
|
+
var connection = context.connection,
|
|
115
|
+
source = connection.source;
|
|
116
|
+
|
|
117
|
+
if (!isOnPartConnection(connection)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var onPart = getOnPart(connection),
|
|
122
|
+
oldCriterion = connection.target,
|
|
123
|
+
oldSentry = getSentry(oldCriterion),
|
|
124
|
+
newCriterion = context.newTarget,
|
|
125
|
+
newSentry = getSentry(newCriterion);
|
|
126
|
+
|
|
127
|
+
if (oldSentry === newSentry) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!newSentry) {
|
|
132
|
+
newSentry = createSentry(newCriterion);
|
|
133
|
+
modeling.updateSemanticParent(newSentry, getSentryParent(newCriterion.host), 'sentries');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (existsAnotherConnection(source, connection)) {
|
|
137
|
+
onPart = cloneOnPart(onPart);
|
|
138
|
+
setCmmnElementRef(connection, onPart);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
modeling.updateSemanticParent(onPart, newSentry, 'onParts', connection);
|
|
142
|
+
|
|
143
|
+
}, true);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
this.postExecuted([ 'connection.create', 'connection.reconnectStart'], function(context) {
|
|
147
|
+
|
|
148
|
+
var connection = context.connection;
|
|
149
|
+
|
|
150
|
+
if (!isOnPartConnection(connection)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
var onPart = getOnPart(connection),
|
|
155
|
+
standardEvent;
|
|
156
|
+
|
|
157
|
+
if (!isValidStandardEvent(connection)) {
|
|
158
|
+
standardEvent = getDefaultStandardEvent(connection);
|
|
159
|
+
modeling.updateProperties(onPart, {
|
|
160
|
+
standardEvent: standardEvent
|
|
161
|
+
}, connection);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}, true);
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// CREATE //////////////////////////////////////////////////////////////////
|
|
168
|
+
|
|
169
|
+
this.postExecuted('element.updateAttachment', function(context) {
|
|
170
|
+
|
|
171
|
+
var shape = context.shape;
|
|
172
|
+
|
|
173
|
+
if (!isCriterion(shape)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (shape.host) {
|
|
178
|
+
self.updateSentriesSemanticParent([ shape ]);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
self.deleteSentry(shape);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
}, true);
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// DELETE /////////////////////////////////////////////////////////////
|
|
188
|
+
|
|
189
|
+
this.preExecuted('shape.delete', function(context) {
|
|
190
|
+
|
|
191
|
+
var definition = getDefinition(context.shape);
|
|
192
|
+
|
|
193
|
+
if (!isHumanTask(definition)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// get remaining discretionary items
|
|
198
|
+
context.discretionaryItems = context.discretionaryItems || getAllDiscretionaryItems(definition);
|
|
199
|
+
|
|
200
|
+
}, true);
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
this.postExecuted('shape.delete', VERY_LOW_PRIORITY, function(context) {
|
|
204
|
+
|
|
205
|
+
var discretionaryItems = context.discretionaryItems,
|
|
206
|
+
attachers;
|
|
207
|
+
|
|
208
|
+
attachers = getAttachersRecurse(discretionaryItems);
|
|
209
|
+
|
|
210
|
+
if (attachers && attachers.length) {
|
|
211
|
+
self.updateSentriesSemanticParent(attachers);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}, true);
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
// MOVING /////////////////////////////////////////////////////////////
|
|
218
|
+
|
|
219
|
+
this.postExecuted([
|
|
220
|
+
'connection.create',
|
|
221
|
+
'connection.delete',
|
|
222
|
+
'connection.reconnectEnd',
|
|
223
|
+
'connection.reconnectStart'
|
|
224
|
+
], VERY_LOW_PRIORITY, function(context) {
|
|
225
|
+
|
|
226
|
+
var connection = context.connection,
|
|
227
|
+
source = context.newSource || context.source || connection.source,
|
|
228
|
+
target = context.newTarget || context.target || connection.target,
|
|
229
|
+
shapes = [],
|
|
230
|
+
attachers;
|
|
231
|
+
|
|
232
|
+
if (!isDiscretionaryConnection(connection, source, target)) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (connection.target) {
|
|
237
|
+
shapes.push(connection.target);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (!connection.target && context.target) {
|
|
241
|
+
shapes.push(context.target);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (context.oldTarget) {
|
|
245
|
+
shapes.push(context.oldTarget);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
attachers = getAttachersRecurse(shapes);
|
|
249
|
+
|
|
250
|
+
if (attachers && attachers.length) {
|
|
251
|
+
self.updateSentriesSemanticParent(attachers);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
}, true);
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
this.postExecuted('elements.move', VERY_LOW_PRIORITY, function(context) {
|
|
258
|
+
|
|
259
|
+
var shapes = context.shapes,
|
|
260
|
+
newParent = context.newParent,
|
|
261
|
+
oldParent = context.hints && context.hints.oldParent,
|
|
262
|
+
attachers;
|
|
263
|
+
|
|
264
|
+
if (oldParent === newParent) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
attachers = getAttachersRecurse(shapes);
|
|
269
|
+
|
|
270
|
+
if (attachers && attachers.length) {
|
|
271
|
+
self.updateSentriesSemanticParent(attachers);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}, true);
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
// API //////////////////////////////////////////////////////
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Deletes by given criteria referenced sentries, if the
|
|
282
|
+
* the sentry is not referenced by any other criterion.
|
|
283
|
+
*
|
|
284
|
+
* @param {Object} criteria deleted criteria
|
|
285
|
+
*/
|
|
286
|
+
this.deleteSentry = function(criterion) {
|
|
287
|
+
|
|
288
|
+
var sentry = getSentry(criterion),
|
|
289
|
+
references;
|
|
290
|
+
|
|
291
|
+
if (sentry) {
|
|
292
|
+
references = itemRegistry.getReferences(sentry);
|
|
293
|
+
|
|
294
|
+
if (references.length <= 1) {
|
|
295
|
+
modeling.updateSemanticParent(sentry, null, containment);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Updates the parent of by given criteria referenced sentries.
|
|
304
|
+
*
|
|
305
|
+
* If the sentry is referenced by multiple criteria and only
|
|
306
|
+
* a part of them has been moved, then the sentry is duplicated.
|
|
307
|
+
*
|
|
308
|
+
* @param {Object} criteria updated criteria
|
|
309
|
+
*/
|
|
310
|
+
this.updateSentriesSemanticParent = function(criteria) {
|
|
311
|
+
|
|
312
|
+
var groupedCriteria = groupBySentry(criteria),
|
|
313
|
+
replacements = {};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Returns true if the given element is replaced
|
|
317
|
+
*/
|
|
318
|
+
function isReplaced(elem) {
|
|
319
|
+
return !!replacements[elem.id];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Set the given old element as replaced
|
|
324
|
+
* with the given new element.
|
|
325
|
+
*/
|
|
326
|
+
function replace(oldElem, newElem) {
|
|
327
|
+
replacements[oldElem.id] = newElem;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Returns the replacement of the given element.
|
|
332
|
+
* If no replacement is available the given element
|
|
333
|
+
* itself is returned.
|
|
334
|
+
*/
|
|
335
|
+
function getReplacement(elem) {
|
|
336
|
+
return replacements[elem.id] || elem;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Returns true if the sentry should be replaced.
|
|
341
|
+
*/
|
|
342
|
+
function shouldReplace(sentry, newParent) {
|
|
343
|
+
var references = itemRegistry.getReferences(sentry),
|
|
344
|
+
criteria = (groupedCriteria[sentry.id] || []),
|
|
345
|
+
referencesLength = itemRegistry.getReferences(sentry).length,
|
|
346
|
+
criteriaLength = criteria.length;
|
|
347
|
+
|
|
348
|
+
if (referencesLength > criteriaLength) {
|
|
349
|
+
|
|
350
|
+
if (!newParent) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return some(references, function(criterion) {
|
|
355
|
+
var criterionShape = itemRegistry.getShape(criterion);
|
|
356
|
+
return criterionShape && newParent !== getSentryParent(criterionShape.host);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
handleEachElement(criteria, function(criterion) {
|
|
366
|
+
|
|
367
|
+
var sentry = getSentry(criterion);
|
|
368
|
+
|
|
369
|
+
if (sentry) {
|
|
370
|
+
|
|
371
|
+
var newParent = getSentryParent(criterion.host);
|
|
372
|
+
|
|
373
|
+
if (!newParent) {
|
|
374
|
+
var parent = getParent(getBusinessObject(criterion));
|
|
375
|
+
newParent = parent && getSentryParent(parent);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (sentry.$parent === newParent) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (!isReplaced(sentry) && shouldReplace(sentry, newParent)) {
|
|
383
|
+
var newSentry = cmmnReplace.replaceSentry(sentry);
|
|
384
|
+
replace(sentry, newSentry);
|
|
385
|
+
|
|
386
|
+
forEach(criterion.incoming, function(con) {
|
|
387
|
+
|
|
388
|
+
var cmmnElement = con.businessObject.cmmnElementRef;
|
|
389
|
+
if (cmmnElement && is(cmmnElement, 'cmmn:OnPart')) {
|
|
390
|
+
replace(cmmnElement, cloneOnPart(cmmnElement));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
sentry = getReplacement(sentry);
|
|
397
|
+
|
|
398
|
+
if (getSentry(criterion) !== sentry) {
|
|
399
|
+
setSentryRef(criterion, sentry);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
forEach(criterion.incoming, function(con) {
|
|
403
|
+
|
|
404
|
+
var cmmnElement = con.businessObject.cmmnElementRef;
|
|
405
|
+
if (cmmnElement && is(cmmnElement, 'cmmn:OnPart')) {
|
|
406
|
+
|
|
407
|
+
var replaceBy = getReplacement(cmmnElement);
|
|
408
|
+
|
|
409
|
+
if (replaceBy && cmmnElement !== replaceBy) {
|
|
410
|
+
setCmmnElementRef(con, replaceBy);
|
|
411
|
+
modeling.updateSemanticParent(replaceBy, sentry, 'onParts');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
modeling.updateSemanticParent(sentry, newParent, containment);
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
// UTILITIES /////////////////////////////////////////////////////////////////
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
function getAttachersRecurse(shapes) {
|
|
431
|
+
|
|
432
|
+
var attachers = getAttachers(shapes);
|
|
433
|
+
|
|
434
|
+
handleEachElement(shapes, function(shape) {
|
|
435
|
+
|
|
436
|
+
var definition = getDefinition(shape);
|
|
437
|
+
|
|
438
|
+
if (isHumanTask(definition)) {
|
|
439
|
+
|
|
440
|
+
var items = getAllDiscretionaryItems(shape);
|
|
441
|
+
|
|
442
|
+
if (items && items.length) {
|
|
443
|
+
attachers = attachers.concat(getAttachers(items));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return items;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return getDirectItemCapables(shape);
|
|
450
|
+
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
return flatten(attachers);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
function handleEachElement(shapes, fn) {
|
|
458
|
+
|
|
459
|
+
var handledElements = {};
|
|
460
|
+
|
|
461
|
+
function handled(element) {
|
|
462
|
+
handledElements[element.id] = element;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function isHandled(element) {
|
|
466
|
+
return !!handledElements[element.id];
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function eachElement(elements, isRoot) {
|
|
470
|
+
forEach(elements, function(element) {
|
|
471
|
+
|
|
472
|
+
if (!isHandled(element)) {
|
|
473
|
+
handled(element);
|
|
474
|
+
|
|
475
|
+
element = itemRegistry.getShape(element.id) || element;
|
|
476
|
+
|
|
477
|
+
var children = fn(element);
|
|
478
|
+
|
|
479
|
+
if (children && children.length) {
|
|
480
|
+
eachElement(children);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (isRoot) {
|
|
485
|
+
handledElements = {};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
eachElement(shapes, true);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function createSentry(criterion) {
|
|
495
|
+
var sentry = cmmnFactory.createSentry();
|
|
496
|
+
setSentryRef(criterion, sentry);
|
|
497
|
+
return sentry;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function setSentryRef(criterion, sentry) {
|
|
501
|
+
modeling.updateProperties(criterion, {
|
|
502
|
+
sentryRef: sentry
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function setCmmnElementRef(connection, ref) {
|
|
507
|
+
modeling.updateProperties(connection, {
|
|
508
|
+
cmmnElementRef: ref
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function cloneOnPart(onPart) {
|
|
513
|
+
var attrs = {
|
|
514
|
+
name: onPart.name,
|
|
515
|
+
sourceRef: onPart.sourceRef,
|
|
516
|
+
standardEvent: onPart.standardEvent
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
if (is(onPart, 'cmmn:PlanItemOnPart')) {
|
|
520
|
+
attrs.exitCriterionRef = onPart.exitCriterionRef;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return cmmnFactory.create(onPart.$type, attrs);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
function isOnPartConnection(connection) {
|
|
528
|
+
var cmmnElement = connection.businessObject.cmmnElementRef;
|
|
529
|
+
return is(cmmnElement, 'cmmn:OnPart');
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function isDiscretionaryConnection(connection, source, target) {
|
|
533
|
+
return !connection.businessObject.cmmnElementRef;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
SentryUpdater.$inject = [
|
|
539
|
+
'eventBus',
|
|
540
|
+
'modeling',
|
|
541
|
+
'itemRegistry',
|
|
542
|
+
'cmmnReplace',
|
|
543
|
+
'cmmnFactory'
|
|
544
|
+
];
|
|
545
|
+
|
|
546
|
+
inherits(SentryUpdater, CommandInterceptor);
|
|
547
|
+
|
|
548
|
+
module.exports = SentryUpdater;
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Returns based on the given host the parent
|
|
553
|
+
* for a sentry.
|
|
554
|
+
*
|
|
555
|
+
* @param {djs.model.Base} host
|
|
556
|
+
*
|
|
557
|
+
* @result {ModdleElement} parent
|
|
558
|
+
*/
|
|
559
|
+
function getSentryParent(host) {
|
|
560
|
+
|
|
561
|
+
if (isCasePlanModel(host)) {
|
|
562
|
+
return getBusinessObject(host);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (isItemCapable(host)) {
|
|
566
|
+
var bo = getBusinessObject(host);
|
|
567
|
+
return getParent(bo, 'cmmn:PlanFragment');
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Returns all attachers for the given shapes.
|
|
575
|
+
*
|
|
576
|
+
* @param {Array<djs.model.Base>} shapes
|
|
577
|
+
*
|
|
578
|
+
* @result {Array<djs.model.Base>} attachers
|
|
579
|
+
*/
|
|
580
|
+
function getAttachers(shapes) {
|
|
581
|
+
return flatten(map(shapes, function(s) {
|
|
582
|
+
var attachers = [];
|
|
583
|
+
|
|
584
|
+
if (s.attachers) {
|
|
585
|
+
attachers = s.attachers;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
var bo = getBusinessObject(s);
|
|
589
|
+
|
|
590
|
+
var exitCriteria = bo.get('exitCriteria');
|
|
591
|
+
forEach(exitCriteria, function(criterion) {
|
|
592
|
+
attachers.push(criterion);
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
var entryCriteria = bo.get('entryCriteria');
|
|
596
|
+
forEach(entryCriteria, function(criterion) {
|
|
597
|
+
attachers.push(criterion);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return attachers || [];
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Groups given criteria by sentry.
|
|
608
|
+
*
|
|
609
|
+
* @param {Object} criteria group by id
|
|
610
|
+
*
|
|
611
|
+
* @result {Object} criteria grouped by sentry
|
|
612
|
+
*/
|
|
613
|
+
function groupBySentry(criteria) {
|
|
614
|
+
return groupBy(criteria, function(criterion) {
|
|
615
|
+
var sentry = getSentry(criterion);
|
|
616
|
+
return sentry && sentry.id;
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Returns true if the given element is a criterion.
|
|
623
|
+
*
|
|
624
|
+
* @param {djs.model.Base} element
|
|
625
|
+
*
|
|
626
|
+
* @return {boolean}
|
|
627
|
+
*/
|
|
628
|
+
function isCriterion(element) {
|
|
629
|
+
return is(element, 'cmmn:Criterion');
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function existsAnotherConnection(source, connection) {
|
|
633
|
+
var onPart = getOnPart(connection);
|
|
634
|
+
return some(source.outgoing, function(con) {
|
|
635
|
+
return connection !== con && onPart === getOnPart(con);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function getOnPart(connection) {
|
|
640
|
+
connection = getBusinessObject(connection);
|
|
641
|
+
return connection.cmmnElementRef;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function isValidStandardEvent(connection) {
|
|
645
|
+
|
|
646
|
+
var onPart = getOnPart(connection),
|
|
647
|
+
standardEvent = onPart.standardEvent,
|
|
648
|
+
possibleStandardEvents = getStandardEvents(onPart);
|
|
649
|
+
|
|
650
|
+
return standardEvent && possibleStandardEvents.indexOf(standardEvent) !== -1;
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function getDefaultStandardEvent(element) {
|
|
655
|
+
|
|
656
|
+
element = getOnPart(element);
|
|
657
|
+
|
|
658
|
+
if (is(element.sourceRef, 'cmmn:CaseFileItem')) {
|
|
659
|
+
return 'update';
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (is(element.exitCriterionRef, 'cmmn:ExitCriterion')) {
|
|
663
|
+
return 'exit';
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (is(element.sourceRef, 'cmmn:PlanItem')) {
|
|
667
|
+
|
|
668
|
+
var definition = getDefinition(element.sourceRef);
|
|
669
|
+
if (is(definition, 'cmmn:EventListener') || is(definition, 'cmmn:Milestone')) {
|
|
670
|
+
return 'occur';
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
return 'complete';
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var forEach = require('min-dash').forEach;
|
|
4
|
+
|
|
5
|
+
var inherits = require('inherits');
|
|
6
|
+
|
|
7
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
8
|
+
|
|
9
|
+
function UnclaimIdBehavior(eventBus, modeling) {
|
|
10
|
+
|
|
11
|
+
CommandInterceptor.call(this, eventBus);
|
|
12
|
+
|
|
13
|
+
this.preExecute('elements.delete', function(event) {
|
|
14
|
+
var context = event.context,
|
|
15
|
+
elements = context.elements;
|
|
16
|
+
|
|
17
|
+
forEach(elements, function(element) {
|
|
18
|
+
modeling.unclaimId(element.businessObject.id, element.businessObject);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
inherits(UnclaimIdBehavior, CommandInterceptor);
|
|
25
|
+
|
|
26
|
+
UnclaimIdBehavior.$inject = [ 'eventBus', 'modeling' ];
|
|
27
|
+
|
|
28
|
+
module.exports = UnclaimIdBehavior;
|