bpmn-moddle 0.10.1 → 0.11.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.
@@ -29,6 +29,10 @@ describe('moddle BPMN 2.0 json', function() {
29
29
  typePrefix: 't'
30
30
  };
31
31
 
32
+ builder.alter('BaseElement#id', {
33
+ isId: true
34
+ });
35
+
32
36
  // perform a translation from
33
37
  //
34
38
  // BaseElement
@@ -149,6 +153,12 @@ describe('moddle BPMN 2.0 json', function() {
149
153
  delete desc.isAttr;
150
154
  });
151
155
 
156
+ // fix missing ResourceAssignmentExpression parent
157
+
158
+ builder.alter('ResourceAssignmentExpression', function(desc) {
159
+ desc.superClass = [ 'BaseElement' ];
160
+ });
161
+
152
162
 
153
163
  // fix positioning of elements
154
164
 
@@ -189,11 +199,60 @@ describe('moddle BPMN 2.0 json', function() {
189
199
  ]);
190
200
  });
191
201
 
202
+
203
+ // fix *Refs -> Ref
204
+
205
+ builder.alter('CallableElement#supportedInterfaceRefs', {
206
+ name: 'supportedInterfaceRef'
207
+ });
208
+
209
+ builder.alter('Participant#interfaceRefs', {
210
+ name: 'interfaceRef'
211
+ });
212
+
213
+ builder.alter('Operation#errorRefs', {
214
+ name: 'errorRef'
215
+ });
216
+
217
+ builder.alter('ThrowEvent#eventDefinitionRefs', {
218
+ name: 'eventDefinitionRef'
219
+ });
220
+
221
+ builder.alter('CatchEvent#eventDefinitionRefs', {
222
+ name: 'eventDefinitionRef'
223
+ });
224
+
225
+ builder.alter('DataInput#inputSetRefs', {
226
+ name: 'inputSetRef'
227
+ });
228
+
229
+ builder.alter('DataOutput#outputSetRefs', {
230
+ name: 'outputSetRef'
231
+ });
232
+
233
+
192
234
  builder.alter('Process', function(desc) {
235
+
236
+ desc.properties.push({
237
+ "name": "laneSets",
238
+ "type": "LaneSet",
239
+ "isMany": true,
240
+ "replaces": "FlowElementsContainer#laneSets"
241
+ });
242
+
243
+ desc.properties.push({
244
+ "name": "flowElements",
245
+ "type": "FlowElement",
246
+ "isMany": true,
247
+ "replaces": "FlowElementsContainer#flowElements"
248
+ });
249
+
193
250
  builder.reorderProperties(desc, [
194
251
  'auditing',
195
252
  'monitoring',
196
253
  'properties',
254
+ 'laneSets',
255
+ 'flowElements',
197
256
  'artifacts',
198
257
  'resources',
199
258
  'correlationSubscriptions',
@@ -232,8 +291,30 @@ describe('moddle BPMN 2.0 json', function() {
232
291
  });
233
292
  });
234
293
 
235
- builder.alter('Lane#childLaneSet', {
236
- xml: { serialize: 'xsi:type' }
294
+ // fix MultiMultiInstanceLoopCharacteristics
295
+
296
+ builder.alter('MultiInstanceLoopCharacteristics#loopDataInputRef', function(desc) {
297
+ delete desc.isAttr;
298
+ });
299
+
300
+ builder.alter('MultiInstanceLoopCharacteristics#loopDataOutputRef', function(desc) {
301
+ delete desc.isAttr;
302
+ });
303
+
304
+ builder.alter('MultiInstanceLoopCharacteristics#inputDataItem', function(desc) {
305
+ desc.xml = { serialize: 'property' };
306
+ });
307
+
308
+ builder.alter('MultiInstanceLoopCharacteristics#outputDataItem', function(desc) {
309
+ desc.xml = { serialize: 'property' };
310
+ });
311
+
312
+ builder.alter('MultiInstanceLoopCharacteristics', function(desc) {
313
+ builder.reorderProperties(desc, [
314
+ 'outputDataItem',
315
+ 'complexBehaviorDefinition',
316
+ 'completionCondition'
317
+ ]);
237
318
  });
238
319
 
239
320
 
@@ -296,6 +377,18 @@ describe('moddle BPMN 2.0 json', function() {
296
377
  name: 'flowNodeRef'
297
378
  });
298
379
 
380
+ builder.alter('Lane#childLaneSet', {
381
+ xml: { serialize: 'xsi:type' }
382
+ });
383
+
384
+ builder.alter('Lane', function(desc) {
385
+ builder.reorderProperties(desc, [
386
+ 'partitionElement',
387
+ 'flowNodeRef',
388
+ 'childLaneSet'
389
+ ]);
390
+ });
391
+
299
392
  builder.alter('Escalation', {
300
393
  superClass: [ 'RootElement' ]
301
394
  });
@@ -371,12 +464,12 @@ describe('moddle BPMN 2.0 json', function() {
371
464
  pkg.associations = [];
372
465
 
373
466
  pkg.types.push({
374
- 'name': 'Extension',
375
- 'properties': [
467
+ name: 'Extension',
468
+ properties: [
376
469
  {
377
- 'name': 'values',
378
- 'type': 'Element',
379
- 'isMany': true
470
+ name: 'values',
471
+ type: 'Element',
472
+ isMany: true
380
473
  }
381
474
  ]
382
475
  });
@@ -384,8 +477,34 @@ describe('moddle BPMN 2.0 json', function() {
384
477
  builder.alter('DiagramElement', function(data) {
385
478
 
386
479
  data.properties.unshift({
387
- 'name': 'extension',
388
- 'type': 'Extension'
480
+ name: 'extension',
481
+ type: 'Extension'
482
+ });
483
+
484
+ data.properties.unshift({
485
+ name: 'id',
486
+ type: 'String',
487
+ isAttr: true,
488
+ isId: true
489
+ });
490
+ });
491
+
492
+ builder.alter('Diagram', function(data) {
493
+ data.properties.unshift({
494
+ name: 'id',
495
+ type: 'String',
496
+ isAttr: true,
497
+ isId: true
498
+ });
499
+ });
500
+
501
+
502
+ builder.alter('Style', function(data) {
503
+ (data.properties = data.properties || []).unshift({
504
+ name: 'id',
505
+ type: 'String',
506
+ isAttr: true,
507
+ isId: true
389
508
  });
390
509
  });
391
510
 
@@ -40,4 +40,37 @@ describe('bpmn-moddle - edit', function() {
40
40
 
41
41
  });
42
42
 
43
+
44
+ describe('dataObjectRef', function() {
45
+
46
+ it('should update', function(done) {
47
+
48
+ fromFile('test/fixtures/bpmn/data-object-reference.bpmn', function(err, result) {
49
+
50
+ // given
51
+ var process = result.rootElements[0],
52
+ dataObjectReference = process.flowElements[0];
53
+
54
+ // when
55
+ // creating new data object
56
+ var dataObject_2 = moddle.create('bpmn:DataObject', { id: 'dataObject_2' });
57
+
58
+ // adding data object to its parent (makes sure it is contained in the XML)
59
+ process.flowElements.push(dataObject_2);
60
+
61
+ // set reference to the new data object
62
+ dataObjectReference.dataObjectRef = dataObject_2;
63
+
64
+ toXML(result, { format: true }, function(err, xml) {
65
+
66
+ // then
67
+ expect(xml).to.contain('<bpmn:dataObject id="dataObject_2" />');
68
+ expect(xml).to.contain('<bpmn:dataObjectReference id="DataObjectReference_1" dataObjectRef="dataObject_2" />');
69
+
70
+ done(err);
71
+ });
72
+
73
+ });
74
+ });
75
+ });
43
76
  });
@@ -740,7 +740,7 @@ describe('bpmn-moddle - read', function() {
740
740
 
741
741
  describe('should import extensions', function() {
742
742
 
743
- it('as attributes', function(done) {
743
+ it('attributes on root', function(done) {
744
744
 
745
745
  // given
746
746
  var xml = '<bpmn:sequenceFlow xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/bpmnModel" ' +
@@ -758,7 +758,7 @@ describe('bpmn-moddle - read', function() {
758
758
  });
759
759
 
760
760
 
761
- it('as elements', function(done) {
761
+ it('elements via bpmn:extensionElements', function(done) {
762
762
 
763
763
  // when
764
764
  fromFile('test/fixtures/bpmn/extension-elements.bpmn', function(err, result) {
@@ -20,15 +20,112 @@ describe('bpmn-moddle - roundtrip', function() {
20
20
 
21
21
  this.timeout(15000);
22
22
 
23
+
23
24
  it('home-made bpmn model', function(done) {
24
25
 
25
26
  var definitions = moddle.create('bpmn:Definitions', { targetNamespace: 'http://foo' });
26
27
 
27
- var process = moddle.create('bpmn:Process');
28
- var serviceTask = moddle.create('bpmn:ServiceTask', { name: 'MyService Task'});
28
+ var processElement = moddle.create('bpmn:Process');
29
+ var serviceTask = moddle.create('bpmn:ServiceTask', { name: 'MyService Task' });
29
30
 
30
- process.get('flowElements').push(serviceTask);
31
- definitions.get('rootElements').push(process);
31
+ processElement.get('flowElements').push(serviceTask);
32
+ definitions.get('rootElements').push(processElement);
33
+
34
+ // when
35
+ toXML(definitions, { format: true }, function(err, xml) {
36
+
37
+ // then
38
+ validate(err, xml, done);
39
+ });
40
+ });
41
+
42
+
43
+ it('obscure ids model', function(done) {
44
+
45
+ var definitions = moddle.create('bpmn:Definitions', {
46
+ 'xmlns:foo': 'http://foo-ns',
47
+ targetNamespace: 'http://foo',
48
+ rootElements: [
49
+ moddle.create('bpmn:Message', { id: 'foo_bar' }),
50
+ moddle.create('bpmn:Message', { id: 'foo-bar' }),
51
+ moddle.create('bpmn:Message', { id: 'foo1bar' }),
52
+ moddle.create('bpmn:Message', { id: 'Foo1bar' }),
53
+ moddle.create('bpmn:Message', { id: '_foo_bar' }),
54
+ moddle.create('bpmn:Message', { id: '_foo-bar' }),
55
+ moddle.create('bpmn:Message', { id: '_11' })
56
+ // invalid
57
+ // moddle.create('bpmn:Message', { id: '-foo-bar' }),
58
+ // moddle.create('bpmn:Message', { id: 'foo:_foo_bar' }),
59
+ // moddle.create('bpmn:Message', { id: '1foo_bar' })
60
+ ]
61
+ });
62
+
63
+ // when
64
+ toXML(definitions, { format: true }, function(err, xml) {
65
+
66
+ // then
67
+ validate(err, xml, done);
68
+ });
69
+ });
70
+
71
+
72
+ it('ioSpecification', function(done) {
73
+
74
+ // given
75
+ var definitions = moddle.create('bpmn:Definitions', { targetNamespace: 'http://foo' });
76
+
77
+ var processElement = moddle.create('bpmn:Process');
78
+
79
+ var dataInput = moddle.create('bpmn:DataInput', { id: 'DataInput_FOO' });
80
+
81
+ var inputSet = moddle.create('bpmn:InputSet', {
82
+ dataInputRefs: [ dataInput ]
83
+ });
84
+
85
+ var outputSet = moddle.create('bpmn:OutputSet');
86
+
87
+ var ioSpecification = moddle.create('bpmn:InputOutputSpecification', {
88
+ inputSets: [ inputSet ],
89
+ outputSets: [ outputSet ],
90
+ dataInputs: [ dataInput ]
91
+ });
92
+
93
+ var serviceTask = moddle.create('bpmn:ServiceTask', {
94
+ name: 'MyService Task',
95
+ ioSpecification: ioSpecification
96
+ });
97
+
98
+ processElement.get('flowElements').push(serviceTask);
99
+ definitions.get('rootElements').push(processElement);
100
+
101
+ // when
102
+ toXML(definitions, { format: true }, function(err, xml) {
103
+
104
+ // then
105
+ validate(err, xml, done);
106
+ });
107
+ });
108
+
109
+
110
+ it('properties', function(done) {
111
+
112
+ // given
113
+ var definitions = moddle.create('bpmn:Definitions', { targetNamespace: 'http://foo' });
114
+
115
+ var processElement = moddle.create('bpmn:Process');
116
+
117
+ var property = moddle.create('bpmn:Property', {
118
+ id: 'Property_112',
119
+ name: '__targetRef_placeholder'
120
+ });
121
+
122
+ var serviceTask = moddle.create('bpmn:ServiceTask', {
123
+ name: 'MyService Task',
124
+ properties: [ property ]
125
+ });
126
+
127
+ processElement.get('flowElements').push(serviceTask);
128
+ definitions.get('rootElements').push(processElement);
32
129
 
33
130
  // when
34
131
  toXML(definitions, { format: true }, function(err, xml) {
@@ -56,6 +153,23 @@ describe('bpmn-moddle - roundtrip', function() {
56
153
  });
57
154
 
58
155
 
156
+ it('multi instance loop characteristics', function(done) {
157
+
158
+ // given
159
+ fromFile('test/fixtures/bpmn/multiInstanceLoopCharacteristics.bpmn', function(err, result) {
160
+
161
+ if (err) {
162
+ return done(err);
163
+ }
164
+
165
+ // when
166
+ toXML(result, { format: true }, function(err, xml) {
167
+ validate(err, xml, done);
168
+ });
169
+ });
170
+ });
171
+
172
+
59
173
  it('documentation / extensionElements order', function(done) {
60
174
 
61
175
  // given
@@ -90,6 +204,23 @@ describe('bpmn-moddle - roundtrip', function() {
90
204
  });
91
205
 
92
206
 
207
+ it('lane children order', function(done) {
208
+
209
+ // given
210
+ fromFile('test/fixtures/bpmn/lane-children.bpmn', function(err, result) {
211
+
212
+ if (err) {
213
+ return done(err);
214
+ }
215
+
216
+ // when
217
+ toXML(result, { format: true }, function(err, xml) {
218
+ validate(err, xml, done);
219
+ });
220
+ });
221
+ });
222
+
223
+
93
224
  it('conversation children order', function(done) {
94
225
 
95
226
  // given
@@ -107,7 +238,7 @@ describe('bpmn-moddle - roundtrip', function() {
107
238
  });
108
239
 
109
240
 
110
- it.skip('process children order', function(done) {
241
+ it('process children order', function(done) {
111
242
 
112
243
  // given
113
244
  fromFile('test/fixtures/bpmn/process-children.bpmn', function(err, result) {
@@ -118,8 +249,6 @@ describe('bpmn-moddle - roundtrip', function() {
118
249
 
119
250
  // when
120
251
  toXML(result, { format: true }, function(err, xml) {
121
- console.log(xml);
122
-
123
252
  validate(err, xml, done);
124
253
  });
125
254
  });
@@ -160,6 +289,23 @@ describe('bpmn-moddle - roundtrip', function() {
160
289
  });
161
290
 
162
291
 
292
+ it('Participant#interfaceRef', function(done) {
293
+
294
+ // given
295
+ fromFile('test/fixtures/bpmn/participant-interfaceRef.bpmn', function(err, result) {
296
+
297
+ if (err) {
298
+ return done(err);
299
+ }
300
+
301
+ // when
302
+ toXML(result, { format: true }, function(err, xml) {
303
+ validate(err, xml, done);
304
+ });
305
+ });
306
+ });
307
+
308
+
163
309
  it('ResourceRole#resourceRef', function(done) {
164
310
 
165
311
  // given
@@ -220,7 +366,7 @@ describe('bpmn-moddle - roundtrip', function() {
220
366
  });
221
367
 
222
368
 
223
- it('complex process / extensionElements', function(done) {
369
+ it('complex processElement / extensionElements', function(done) {
224
370
 
225
371
  // given
226
372
  fromFile('test/fixtures/bpmn/complex.bpmn', function(err, result) {
@@ -259,7 +405,7 @@ describe('bpmn-moddle - roundtrip', function() {
259
405
  });
260
406
 
261
407
 
262
- it('simple process', function(done) {
408
+ it('simple processElement', function(done) {
263
409
 
264
410
  // given
265
411
  fromFile('test/fixtures/bpmn/simple.bpmn', function(err, result) {
@@ -297,13 +443,12 @@ describe('bpmn-moddle - roundtrip', function() {
297
443
 
298
444
  describe('vendor', function() {
299
445
 
300
-
301
446
  describe('signavio', function() {
302
447
 
303
- it('complex process', function(done) {
448
+ it('complex processElement', function(done) {
304
449
 
305
450
  // given
306
- fromFile('test/fixtures/bpmn/complex-no-extensions.bpmn', function(err, result) {
451
+ fromFile('test/fixtures/bpmn/vendor/signavio-complex-no-extensions.bpmn', function(err, result) {
307
452
 
308
453
  if (err) {
309
454
  return done(err);
@@ -324,7 +469,7 @@ describe('bpmn-moddle - roundtrip', function() {
324
469
  it('event definitions', function(done) {
325
470
 
326
471
  // given
327
- fromFile('test/fixtures/bpmn/event-definitions-yaoqiang.bpmn', function(err, result, context) {
472
+ fromFile('test/fixtures/bpmn/vendor/yaoqiang-event-definitions.bpmn', function(err, result, context) {
328
473
 
329
474
  if (err) {
330
475
  return done(err);