bpmn-elements 6.0.1 → 8.0.1
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/CHANGELOG.md +341 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/activity/Activity.js +1105 -916
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +710 -408
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +16 -16
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +914 -776
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
package/src/io/BpmnIO.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
export default function BpmnIO(activity, context) {
|
|
2
|
-
|
|
2
|
+
this.activity = activity;
|
|
3
|
+
this.context = context;
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const {
|
|
6
|
+
ioSpecification: ioSpecificationDef,
|
|
7
|
+
properties: propertiesDef,
|
|
8
|
+
} = activity.behaviour;
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
activate(message) {
|
|
11
|
-
if (bpmnProperties) bpmnProperties.activate(message);
|
|
12
|
-
if (ioSpecification) ioSpecification.activate(message);
|
|
13
|
-
},
|
|
14
|
-
deactivate(message) {
|
|
15
|
-
if (bpmnProperties) bpmnProperties.deactivate(message);
|
|
16
|
-
if (ioSpecification) ioSpecification.deactivate(message);
|
|
17
|
-
},
|
|
18
|
-
};
|
|
10
|
+
this.specification = ioSpecificationDef && new ioSpecificationDef.Behaviour(activity, ioSpecificationDef, context);
|
|
11
|
+
this.properties = propertiesDef && new propertiesDef.Behaviour(activity, propertiesDef, context);
|
|
19
12
|
}
|
|
13
|
+
|
|
14
|
+
BpmnIO.prototype.activate = function activate(message) {
|
|
15
|
+
const properties = this.properties, specification = this.specification;
|
|
16
|
+
if (properties) properties.activate(message);
|
|
17
|
+
if (specification) specification.activate(message);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
BpmnIO.prototype.deactivate = function deactivate(message) {
|
|
21
|
+
const properties = this.properties, specification = this.specification;
|
|
22
|
+
if (properties) properties.deactivate(message);
|
|
23
|
+
if (specification) specification.deactivate(message);
|
|
24
|
+
};
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
export default function EnvironmentDataObject(dataObjectDef, {environment}) {
|
|
2
2
|
const {id, type, name, behaviour, parent} = dataObjectDef;
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.type = type;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.behaviour = behaviour;
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
this.environment = environment;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
11
|
-
const value = environment.variables._data && environment.variables._data[id];
|
|
12
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
13
|
-
},
|
|
14
|
-
write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
15
|
-
environment.variables._data = environment.variables._data || {};
|
|
16
|
-
environment.variables._data[id] = value;
|
|
17
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
11
|
+
EnvironmentDataObject.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
12
|
+
const environment = this.environment;
|
|
13
|
+
const value = environment.variables._data && environment.variables._data[this.id];
|
|
14
|
+
const content = this._createContent(value);
|
|
15
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
16
|
+
};
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
EnvironmentDataObject.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
19
|
+
const environment = this.environment;
|
|
20
|
+
environment.variables._data = environment.variables._data || {};
|
|
21
|
+
environment.variables._data[this.id] = value;
|
|
22
|
+
const content = this._createContent(value);
|
|
23
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
EnvironmentDataObject.prototype._createContent = function createContent(value) {
|
|
27
|
+
return {
|
|
28
|
+
id: this.id,
|
|
29
|
+
type: this.type,
|
|
30
|
+
name: this.name,
|
|
31
|
+
value,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
export default function EnvironmentDataStore(dataStoreDef, {environment}) {
|
|
2
2
|
const {id, type, name, behaviour, parent} = dataStoreDef;
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.type = type;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.behaviour = behaviour;
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
this.environment = environment;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
11
|
-
const value = environment.variables._data && environment.variables._data[id];
|
|
12
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
13
|
-
},
|
|
14
|
-
write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
15
|
-
environment.variables._data = environment.variables._data || {};
|
|
16
|
-
environment.variables._data[id] = value;
|
|
17
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
11
|
+
EnvironmentDataStore.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
12
|
+
const environment = this.environment;
|
|
13
|
+
const value = environment.variables._data && environment.variables._data[this.id];
|
|
14
|
+
const content = this._createContent(value);
|
|
15
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
16
|
+
};
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
EnvironmentDataStore.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
19
|
+
const environment = this.environment;
|
|
20
|
+
environment.variables._data = environment.variables._data || {};
|
|
21
|
+
environment.variables._data[this.id] = value;
|
|
22
|
+
const content = this._createContent(value);
|
|
23
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
EnvironmentDataStore.prototype._createContent = function createContent(value) {
|
|
27
|
+
return {
|
|
28
|
+
id: this.id,
|
|
29
|
+
type: this.type,
|
|
30
|
+
name: this.name,
|
|
31
|
+
value,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
export default function EnvironmentDataStoreReference(
|
|
2
|
-
const {id, type, name, behaviour, parent} =
|
|
1
|
+
export default function EnvironmentDataStoreReference(dataObjectDef, {environment}) {
|
|
2
|
+
const {id, type, name, behaviour, parent} = dataObjectDef;
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.type = type;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.behaviour = behaviour;
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
this.environment = environment;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
11
|
-
const value = environment.variables._data && environment.variables._data[id];
|
|
12
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
13
|
-
},
|
|
14
|
-
write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
15
|
-
environment.variables._data = environment.variables._data || {};
|
|
16
|
-
environment.variables._data[id] = value;
|
|
17
|
-
return broker.publish(exchange, `${routingKeyPrefix}response`, {id, name, type, value}, messageProperties);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
11
|
+
EnvironmentDataStoreReference.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
12
|
+
const environment = this.environment;
|
|
13
|
+
const value = environment.variables._data && environment.variables._data[this.id];
|
|
14
|
+
const content = this._createContent(value);
|
|
15
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
16
|
+
};
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
EnvironmentDataStoreReference.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
19
|
+
const environment = this.environment;
|
|
20
|
+
environment.variables._data = environment.variables._data || {};
|
|
21
|
+
environment.variables._data[this.id] = value;
|
|
22
|
+
const content = this._createContent(value);
|
|
23
|
+
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
EnvironmentDataStoreReference.prototype._createContent = function createContent(value) {
|
|
27
|
+
return {
|
|
28
|
+
id: this.id,
|
|
29
|
+
type: this.type,
|
|
30
|
+
name: this.name,
|
|
31
|
+
value,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,186 +1,184 @@
|
|
|
1
1
|
import getPropertyValue from '../getPropertyValue';
|
|
2
2
|
import {brokerSafeId} from '../shared';
|
|
3
3
|
|
|
4
|
+
const kConsuming = Symbol.for('consuming');
|
|
5
|
+
|
|
4
6
|
export default function IoSpecification(activity, ioSpecificationDef, context) {
|
|
5
7
|
const {id, type = 'iospecification', behaviour = {}} = ioSpecificationDef;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.behaviour = behaviour;
|
|
11
|
+
this.activity = activity;
|
|
12
|
+
this.broker = activity.broker;
|
|
13
|
+
this.context = context;
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
id,
|
|
15
|
-
type,
|
|
16
|
-
behaviour,
|
|
17
|
-
activate,
|
|
18
|
-
deactivate,
|
|
19
|
-
};
|
|
16
|
+
const proto = IoSpecification.prototype;
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
proto.activate = function activate() {
|
|
19
|
+
if (this[kConsuming]) return;
|
|
20
|
+
this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {noAck: true});
|
|
21
|
+
};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
proto.deactivate = function deactivate() {
|
|
24
|
+
if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
|
|
25
|
+
};
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
28
|
+
const {dataInputs, dataOutputs} = this.behaviour;
|
|
29
|
+
if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
|
|
30
|
+
return this._onFormatEnter();
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return formatOnEnter();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (dataOutputs && routingKey === 'activity.execution.completed') {
|
|
38
|
-
formatOnComplete(message);
|
|
39
|
-
}
|
|
33
|
+
if (dataOutputs && routingKey === 'activity.execution.completed') {
|
|
34
|
+
this._onFormatComplete(message);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const {dataObjects, sources} = dataInputs.reduce((result, ioSource, index) => {
|
|
53
|
-
const source = {
|
|
54
|
-
id: ioSource.id,
|
|
55
|
-
type: ioSource.type,
|
|
56
|
-
name: ioSource.name,
|
|
57
|
-
};
|
|
58
|
-
result.sources.push(source);
|
|
59
|
-
|
|
60
|
-
const dataObjectId = getPropertyValue(ioSource, 'behaviour.association.source.dataObject.id');
|
|
61
|
-
if (!dataObjectId) return result;
|
|
62
|
-
const dataObject = context.getDataObjectById(dataObjectId);
|
|
63
|
-
if (!dataObject) return result;
|
|
64
|
-
result.dataObjects.push({index, dataObject});
|
|
65
|
-
return result;
|
|
66
|
-
}, {
|
|
67
|
-
dataObjects: [],
|
|
68
|
-
sources: [],
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (!dataObjects.length) {
|
|
72
|
-
return broker.publish('format', startRoutingKey, {
|
|
73
|
-
ioSpecification: {
|
|
74
|
-
dataInputs: sources,
|
|
75
|
-
dataOutputs: getDataOutputs(),
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const endRoutingKey = `run.onstart.${safeType}.end`;
|
|
81
|
-
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
82
|
-
endRoutingKey,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
proto._onFormatEnter = function onFormatOnEnter() {
|
|
39
|
+
const safeType = brokerSafeId(this.type).toLowerCase();
|
|
40
|
+
const startRoutingKey = `run.onstart.${safeType}`;
|
|
41
|
+
const {dataInputs, dataOutputs} = this.behaviour;
|
|
42
|
+
const broker = this.broker;
|
|
43
|
+
if (!dataInputs) {
|
|
44
|
+
return broker.publish('format', startRoutingKey, {
|
|
83
45
|
ioSpecification: {
|
|
84
|
-
|
|
85
|
-
return {...source};
|
|
86
|
-
}),
|
|
87
|
-
dataOutputs: getDataOutputs(),
|
|
46
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
88
47
|
},
|
|
89
48
|
});
|
|
90
|
-
|
|
91
|
-
return read(broker, dataObjects, (_, responses) => {
|
|
92
|
-
responses.forEach((response) => {
|
|
93
|
-
sources[response.index].value = response.value;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
broker.publish('format', endRoutingKey, {
|
|
97
|
-
ioSpecification: {
|
|
98
|
-
dataInputs: sources,
|
|
99
|
-
dataOutputs: getDataOutputs(),
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
49
|
}
|
|
104
50
|
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
51
|
+
const {dataObjects, sources} = dataInputs.reduce((result, ioSource, index) => {
|
|
52
|
+
const source = {
|
|
53
|
+
id: ioSource.id,
|
|
54
|
+
type: ioSource.type,
|
|
55
|
+
name: ioSource.name,
|
|
56
|
+
};
|
|
57
|
+
result.sources.push(source);
|
|
58
|
+
|
|
59
|
+
const dataObjectId = getPropertyValue(ioSource, 'behaviour.association.source.dataObject.id');
|
|
60
|
+
if (!dataObjectId) return result;
|
|
61
|
+
const dataObject = this.context.getDataObjectById(dataObjectId);
|
|
62
|
+
if (!dataObject) return result;
|
|
63
|
+
result.dataObjects.push({index, dataObject});
|
|
64
|
+
return result;
|
|
65
|
+
}, {
|
|
66
|
+
dataObjects: [],
|
|
67
|
+
sources: [],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!dataObjects.length) {
|
|
71
|
+
return broker.publish('format', startRoutingKey, {
|
|
72
|
+
ioSpecification: {
|
|
73
|
+
dataInputs: sources,
|
|
74
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
75
|
+
},
|
|
128
76
|
});
|
|
77
|
+
}
|
|
129
78
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
79
|
+
const endRoutingKey = `run.onstart.${safeType}.end`;
|
|
80
|
+
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
81
|
+
endRoutingKey,
|
|
82
|
+
ioSpecification: {
|
|
83
|
+
dataInputs: sources.map((source) => {
|
|
84
|
+
return {...source};
|
|
85
|
+
}),
|
|
86
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return read(broker, dataObjects, (_, responses) => {
|
|
91
|
+
for (const response of responses) sources[response.index].value = response.value;
|
|
92
|
+
|
|
93
|
+
broker.publish('format', endRoutingKey, {
|
|
143
94
|
ioSpecification: {
|
|
144
|
-
dataInputs: sources
|
|
145
|
-
|
|
146
|
-
}),
|
|
147
|
-
dataOutputs: getDataOutputs(),
|
|
95
|
+
dataInputs: sources,
|
|
96
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
148
97
|
},
|
|
149
98
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
proto._onFormatComplete = function formatOnComplete(message) {
|
|
103
|
+
const safeType = brokerSafeId(this.type).toLowerCase();
|
|
104
|
+
const messageInputs = getPropertyValue(message, 'content.ioSpecification.dataInputs');
|
|
105
|
+
const messageOutputs = getPropertyValue(message, 'content.output.ioSpecification.dataOutputs') || [];
|
|
106
|
+
const dataOutputs = this.behaviour.dataOutputs;
|
|
107
|
+
const broker = this.broker;
|
|
108
|
+
const context = this.context;
|
|
109
|
+
|
|
110
|
+
const {dataObjects, sources} = dataOutputs.reduce((result, ioSource, index) => {
|
|
111
|
+
const {value} = messageOutputs.find((output) => output.id === ioSource.id) || {};
|
|
112
|
+
const source = {
|
|
113
|
+
id: ioSource.id,
|
|
114
|
+
type: ioSource.type,
|
|
115
|
+
name: ioSource.name,
|
|
116
|
+
value,
|
|
117
|
+
};
|
|
118
|
+
result.sources.push(source);
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const dataObjectId = getPropertyValue(ioSource, 'behaviour.association.target.dataObject.id');
|
|
122
|
+
if (!dataObjectId) return result;
|
|
123
|
+
const dataObject = context.getDataObjectById(dataObjectId);
|
|
124
|
+
if (!dataObject) return result;
|
|
125
|
+
result.dataObjects.push({index, dataObject, value});
|
|
126
|
+
return result;
|
|
127
|
+
}, {
|
|
128
|
+
dataObjects: [],
|
|
129
|
+
sources: [],
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const startRoutingKey = `run.onend.${safeType}`;
|
|
133
|
+
if (!dataObjects.length) {
|
|
134
|
+
return broker.publish('format', startRoutingKey, {
|
|
135
|
+
ioSpecification: {
|
|
136
|
+
dataInputs: messageInputs,
|
|
137
|
+
dataOutputs: sources,
|
|
138
|
+
},
|
|
162
139
|
});
|
|
163
140
|
}
|
|
164
141
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
142
|
+
const endRoutingKey = `run.onend.${safeType}.end`;
|
|
143
|
+
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
144
|
+
endRoutingKey,
|
|
145
|
+
ioSpecification: {
|
|
146
|
+
dataInputs: sources.map((input) => {
|
|
147
|
+
return {...input};
|
|
148
|
+
}),
|
|
149
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return write(broker, dataObjects, (_, responses) => {
|
|
154
|
+
for (const response of responses) sources[response.index].value = response.value;
|
|
155
|
+
|
|
156
|
+
broker.publish('format', endRoutingKey, {
|
|
157
|
+
ioSpecification: {
|
|
158
|
+
dataInputs: sources,
|
|
159
|
+
dataOutputs: this._getDataOutputs(dataOutputs),
|
|
160
|
+
},
|
|
173
161
|
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
proto._getDataOutputs = function getDataOutputs(dataOutputs) {
|
|
166
|
+
if (!dataOutputs) return;
|
|
167
|
+
return dataOutputs.map((dataOutput) => {
|
|
168
|
+
return {
|
|
169
|
+
id: dataOutput.id,
|
|
170
|
+
type: dataOutput.type,
|
|
171
|
+
name: dataOutput.name,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
};
|
|
176
175
|
|
|
177
176
|
function read(broker, dataObjectRefs, callback) {
|
|
178
177
|
const responses = [];
|
|
179
178
|
let count = 0;
|
|
180
179
|
const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataObjectResponse, {noAck: true});
|
|
181
180
|
|
|
182
|
-
for (
|
|
183
|
-
const {dataObject} = dataObjectRefs[i];
|
|
181
|
+
for (const {dataObject} of dataObjectRefs) {
|
|
184
182
|
dataObject.read(broker, 'data', 'data.read.');
|
|
185
183
|
}
|
|
186
184
|
|
|
@@ -200,22 +198,21 @@ function read(broker, dataObjectRefs, callback) {
|
|
|
200
198
|
function write(broker, dataObjectRefs, callback) {
|
|
201
199
|
const responses = [];
|
|
202
200
|
let count = 0;
|
|
203
|
-
|
|
201
|
+
broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {noAck: true});
|
|
204
202
|
|
|
205
|
-
for (
|
|
206
|
-
const {dataObject, value} = dataObjectRefs[i];
|
|
203
|
+
for (const {dataObject, value} of dataObjectRefs) {
|
|
207
204
|
dataObject.write(broker, 'data', 'data.write.', value);
|
|
208
205
|
}
|
|
209
206
|
|
|
210
207
|
function onDataObjectResponse(routingKey, message) {
|
|
211
|
-
const idx = dataObjectRefs.findIndex((
|
|
212
|
-
responses[idx] = message.content;
|
|
208
|
+
const idx = dataObjectRefs.findIndex(({dataObject}) => dataObject.id === message.content.id);
|
|
209
|
+
responses[idx] = {index: idx, ...message.content};
|
|
213
210
|
|
|
214
211
|
++count;
|
|
215
212
|
|
|
216
213
|
if (count < dataObjectRefs.length) return;
|
|
217
214
|
|
|
218
|
-
|
|
215
|
+
broker.cancel(message.fields.consumerTag);
|
|
219
216
|
return callback(null, responses);
|
|
220
217
|
}
|
|
221
218
|
}
|