bpmn-elements 6.0.0 → 8.0.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/CHANGELOG.md +335 -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 +1106 -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 +15 -15
- 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 +915 -775
- 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/dist/src/Api.js
CHANGED
|
@@ -4,106 +4,107 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ActivityApi = ActivityApi;
|
|
7
|
+
exports.Api = Api;
|
|
7
8
|
exports.DefinitionApi = DefinitionApi;
|
|
8
|
-
exports.ProcessApi = ProcessApi;
|
|
9
9
|
exports.FlowApi = FlowApi;
|
|
10
|
-
exports.
|
|
10
|
+
exports.ProcessApi = ProcessApi;
|
|
11
11
|
|
|
12
12
|
var _messageHelper = require("./messageHelper");
|
|
13
13
|
|
|
14
14
|
var _shared = require("./shared");
|
|
15
15
|
|
|
16
16
|
function ActivityApi(broker, apiMessage, environment) {
|
|
17
|
-
return Api('activity', broker, apiMessage, environment);
|
|
17
|
+
return new Api('activity', broker, apiMessage, environment);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function DefinitionApi(broker, apiMessage, environment) {
|
|
21
|
-
return Api('definition', broker, apiMessage, environment);
|
|
21
|
+
return new Api('definition', broker, apiMessage, environment);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function ProcessApi(broker, apiMessage, environment) {
|
|
25
|
-
return Api('process', broker, apiMessage, environment);
|
|
25
|
+
return new Api('process', broker, apiMessage, environment);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function FlowApi(broker, apiMessage, environment) {
|
|
29
|
-
return Api('flow', broker, apiMessage, environment);
|
|
29
|
+
return new Api('flow', broker, apiMessage, environment);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function Api(pfx, broker, sourceMessage, environment) {
|
|
33
33
|
if (!sourceMessage) throw new Error('Api requires message');
|
|
34
34
|
const apiMessage = (0, _messageHelper.cloneMessage)(sourceMessage);
|
|
35
|
-
const apiContent = apiMessage.content;
|
|
36
35
|
const {
|
|
37
|
-
id,
|
|
38
|
-
type,
|
|
39
|
-
name
|
|
40
|
-
} = apiContent;
|
|
41
|
-
const executionId = apiContent.executionId;
|
|
42
|
-
const owner = broker.owner;
|
|
43
|
-
environment = environment || broker.owner.environment;
|
|
44
|
-
return {
|
|
45
36
|
id,
|
|
46
37
|
type,
|
|
47
38
|
name,
|
|
48
|
-
executionId
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
discard() {
|
|
65
|
-
sendApiMessage('discard');
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
signal(message, options) {
|
|
69
|
-
sendApiMessage('signal', {
|
|
70
|
-
message
|
|
71
|
-
}, options);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
stop() {
|
|
75
|
-
sendApiMessage('stop');
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
resolveExpression(expression) {
|
|
79
|
-
return environment.resolveExpression(expression, apiMessage, broker.owner);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
sendApiMessage,
|
|
83
|
-
createMessage,
|
|
84
|
-
getPostponed
|
|
85
|
-
};
|
|
39
|
+
executionId
|
|
40
|
+
} = apiMessage.content;
|
|
41
|
+
this.id = id;
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.name = name;
|
|
44
|
+
this.executionId = executionId;
|
|
45
|
+
this.environment = environment || broker.owner.environment;
|
|
46
|
+
this.content = apiMessage.content;
|
|
47
|
+
this.fields = apiMessage.fields;
|
|
48
|
+
this.messageProperties = apiMessage.properties;
|
|
49
|
+
this.broker = broker;
|
|
50
|
+
this.owner = broker.owner;
|
|
51
|
+
this.messagePrefix = pfx;
|
|
52
|
+
}
|
|
86
53
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
54
|
+
const proto = Api.prototype;
|
|
55
|
+
|
|
56
|
+
proto.cancel = function cancel(message, options) {
|
|
57
|
+
this.sendApiMessage('cancel', {
|
|
58
|
+
message
|
|
59
|
+
}, options);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
proto.discard = function discard() {
|
|
63
|
+
this.sendApiMessage('discard');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
proto.fail = function fail(error) {
|
|
67
|
+
this.sendApiMessage('error', {
|
|
68
|
+
error
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
proto.signal = function signal(message, options) {
|
|
73
|
+
this.sendApiMessage('signal', {
|
|
74
|
+
message
|
|
75
|
+
}, options);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
proto.stop = function stop() {
|
|
79
|
+
this.sendApiMessage('stop');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
proto.resolveExpression = function resolveExpression(expression) {
|
|
83
|
+
return this.environment.resolveExpression(expression, {
|
|
84
|
+
fields: this.fields,
|
|
85
|
+
content: this.content,
|
|
86
|
+
properties: this.messageProperties
|
|
87
|
+
}, this.owner);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
proto.sendApiMessage = function sendApiMessage(action, content, options) {
|
|
91
|
+
const correlationId = options && options.correlationId || (0, _shared.getUniqueId)(`${this.id || this.messagePrefix}_signal`);
|
|
92
|
+
let key = `${this.messagePrefix}.${action}`;
|
|
93
|
+
if (this.executionId) key += `.${this.executionId}`;
|
|
94
|
+
this.broker.publish('api', key, this.createMessage(content), { ...options,
|
|
95
|
+
correlationId,
|
|
96
|
+
type: action
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
proto.getPostponed = function getPostponed(...args) {
|
|
101
|
+
if (this.owner.getPostponed) return this.owner.getPostponed(...args);
|
|
102
|
+
if (this.owner.isSubProcess && this.owner.execution) return this.owner.execution.getPostponed(...args);
|
|
103
|
+
return [];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
proto.createMessage = function createMessage(content) {
|
|
107
|
+
return { ...this.content,
|
|
108
|
+
...content
|
|
109
|
+
};
|
|
110
|
+
};
|
package/dist/src/Context.js
CHANGED
|
@@ -14,8 +14,8 @@ var _shared = require("./shared");
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
function Context(definitionContext, environment) {
|
|
17
|
-
environment = environment ? environment.clone() :
|
|
18
|
-
return ContextInstance(definitionContext, environment);
|
|
17
|
+
environment = environment ? environment.clone() : new _Environment.default();
|
|
18
|
+
return new ContextInstance(definitionContext, environment);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function ContextInstance(definitionContext, environment) {
|
|
@@ -25,180 +25,184 @@ function ContextInstance(definitionContext, environment) {
|
|
|
25
25
|
type = 'context'
|
|
26
26
|
} = definitionContext;
|
|
27
27
|
const sid = (0, _shared.getUniqueId)(id);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
getActivities,
|
|
46
|
-
getActivityById,
|
|
47
|
-
getAssociations,
|
|
48
|
-
getExecutableProcesses,
|
|
49
|
-
getDataObjectById,
|
|
50
|
-
getDataStoreById,
|
|
51
|
-
getInboundAssociations,
|
|
52
|
-
getInboundSequenceFlows,
|
|
53
|
-
getMessageFlows,
|
|
54
|
-
getOutboundSequenceFlows,
|
|
55
|
-
getOutboundAssociations,
|
|
56
|
-
getProcessById,
|
|
57
|
-
getProcesses,
|
|
58
|
-
getSequenceFlowById,
|
|
59
|
-
getSequenceFlows,
|
|
60
|
-
getStartActivities,
|
|
61
|
-
loadExtensions
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.type = type;
|
|
31
|
+
this.sid = sid;
|
|
32
|
+
this.definitionContext = definitionContext;
|
|
33
|
+
this.environment = environment;
|
|
34
|
+
this.extensionsMapper = (0, _ExtensionsMapper.default)(this);
|
|
35
|
+
this.refs = {
|
|
36
|
+
activityRefs: {},
|
|
37
|
+
associationRefs: [],
|
|
38
|
+
dataObjectRefs: {},
|
|
39
|
+
dataStoreRefs: {},
|
|
40
|
+
messageFlows: [],
|
|
41
|
+
processes: [],
|
|
42
|
+
processRefs: {},
|
|
43
|
+
sequenceFlowRefs: {},
|
|
44
|
+
sequenceFlows: []
|
|
62
45
|
};
|
|
63
|
-
|
|
64
|
-
return context;
|
|
65
|
-
|
|
66
|
-
function getActivityById(activityId) {
|
|
67
|
-
const activityInstance = activityRefs[activityId];
|
|
68
|
-
if (activityInstance) return activityInstance;
|
|
69
|
-
const activity = definitionContext.getActivityById(activityId);
|
|
70
|
-
if (!activity) return null;
|
|
71
|
-
return upsertActivity(activity);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function upsertActivity(activityDef) {
|
|
75
|
-
let activityInstance = activityRefs[activityDef.id];
|
|
76
|
-
if (activityInstance) return activityInstance;
|
|
77
|
-
activityInstance = activityRefs[activityDef.id] = activityDef.Behaviour(activityDef, context);
|
|
78
|
-
return activityInstance;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function getSequenceFlowById(sequenceFlowId) {
|
|
82
|
-
const flowInstance = sequenceFlowRefs[sequenceFlowId];
|
|
83
|
-
if (flowInstance) return flowInstance;
|
|
84
|
-
const flowDef = definitionContext.getSequenceFlowById(sequenceFlowId);
|
|
85
|
-
if (!flowDef) return null;
|
|
86
|
-
return upsertSequenceFlow(flowDef);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function getInboundSequenceFlows(activityId) {
|
|
90
|
-
return (definitionContext.getInboundSequenceFlows(activityId) || []).map(flow => upsertSequenceFlow(flow));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getOutboundSequenceFlows(activityId) {
|
|
94
|
-
return (definitionContext.getOutboundSequenceFlows(activityId) || []).map(flow => upsertSequenceFlow(flow));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function getInboundAssociations(activityId) {
|
|
98
|
-
return (definitionContext.getInboundAssociations(activityId) || []).map(association => upsertAssociation(association));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getOutboundAssociations(activityId) {
|
|
102
|
-
return (definitionContext.getOutboundAssociations(activityId) || []).map(association => upsertAssociation(association));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getActivities(scopeId) {
|
|
106
|
-
return (definitionContext.getActivities(scopeId) || []).map(activityDef => upsertActivity(activityDef));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getSequenceFlows(scopeId) {
|
|
110
|
-
return (definitionContext.getSequenceFlows(scopeId) || []).map(flow => upsertSequenceFlow(flow));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function upsertSequenceFlow(flowDefinition) {
|
|
114
|
-
let flowInstance = sequenceFlowRefs[flowDefinition.id];
|
|
115
|
-
if (flowInstance) return flowInstance;
|
|
116
|
-
flowInstance = sequenceFlowRefs[flowDefinition.id] = flowDefinition.Behaviour(flowDefinition, context);
|
|
117
|
-
sequenceFlows.push(flowInstance);
|
|
118
|
-
return flowInstance;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getAssociations(scopeId) {
|
|
122
|
-
return (definitionContext.getAssociations(scopeId) || []).map(association => upsertAssociation(association));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function upsertAssociation(associationDefinition) {
|
|
126
|
-
let instance = associationRefs[associationDefinition.id];
|
|
127
|
-
if (instance) return instance;
|
|
128
|
-
instance = associationRefs[associationDefinition.id] = associationDefinition.Behaviour(associationDefinition, context);
|
|
129
|
-
return instance;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function clone(newEnvironment) {
|
|
133
|
-
return ContextInstance(definitionContext, newEnvironment || environment);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function getProcessById(processId) {
|
|
137
|
-
let processInstance = processRefs[processId];
|
|
138
|
-
if (processInstance) return processInstance;
|
|
139
|
-
const processDefinition = definitionContext.getProcessById(processId);
|
|
140
|
-
if (!processDefinition) return null;
|
|
141
|
-
processInstance = processRefs[processId] = processDefinition.Behaviour(processDefinition, context);
|
|
142
|
-
processes.push(processInstance);
|
|
143
|
-
return processInstance;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getProcesses() {
|
|
147
|
-
return definitionContext.getProcesses().map(({
|
|
148
|
-
id: processId
|
|
149
|
-
}) => getProcessById(processId));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function getExecutableProcesses() {
|
|
153
|
-
return definitionContext.getExecutableProcesses().map(({
|
|
154
|
-
id: processId
|
|
155
|
-
}) => getProcessById(processId));
|
|
156
|
-
}
|
|
46
|
+
}
|
|
157
47
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
48
|
+
const proto = ContextInstance.prototype;
|
|
49
|
+
|
|
50
|
+
proto.getActivityById = function getActivityById(activityId) {
|
|
51
|
+
const activityInstance = this.refs.activityRefs[activityId];
|
|
52
|
+
if (activityInstance) return activityInstance;
|
|
53
|
+
const activity = this.definitionContext.getActivityById(activityId);
|
|
54
|
+
if (!activity) return null;
|
|
55
|
+
return this.upsertActivity(activity);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
proto.upsertActivity = function upsertActivity(activityDef) {
|
|
59
|
+
let activityInstance = this.refs.activityRefs[activityDef.id];
|
|
60
|
+
if (activityInstance) return activityInstance;
|
|
61
|
+
activityInstance = this.refs.activityRefs[activityDef.id] = new activityDef.Behaviour(activityDef, this);
|
|
62
|
+
return activityInstance;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
proto.getSequenceFlowById = function getSequenceFlowById(sequenceFlowId) {
|
|
66
|
+
const flowInstance = this.refs.sequenceFlowRefs[sequenceFlowId];
|
|
67
|
+
if (flowInstance) return flowInstance;
|
|
68
|
+
const flowDef = this.definitionContext.getSequenceFlowById(sequenceFlowId);
|
|
69
|
+
if (!flowDef) return null;
|
|
70
|
+
return this.upsertSequenceFlow(flowDef);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
proto.getInboundSequenceFlows = function getInboundSequenceFlows(activityId) {
|
|
74
|
+
return (this.definitionContext.getInboundSequenceFlows(activityId) || []).map(flow => this.upsertSequenceFlow(flow));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
proto.getOutboundSequenceFlows = function getOutboundSequenceFlows(activityId) {
|
|
78
|
+
return (this.definitionContext.getOutboundSequenceFlows(activityId) || []).map(flow => this.upsertSequenceFlow(flow));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
proto.getInboundAssociations = function getInboundAssociations(activityId) {
|
|
82
|
+
return (this.definitionContext.getInboundAssociations(activityId) || []).map(association => this.upsertAssociation(association));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
proto.getOutboundAssociations = function getOutboundAssociations(activityId) {
|
|
86
|
+
return (this.definitionContext.getOutboundAssociations(activityId) || []).map(association => this.upsertAssociation(association));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
proto.getActivities = function getActivities(scopeId) {
|
|
90
|
+
return (this.definitionContext.getActivities(scopeId) || []).map(activityDef => this.upsertActivity(activityDef));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
proto.getSequenceFlows = function getSequenceFlows(scopeId) {
|
|
94
|
+
return (this.definitionContext.getSequenceFlows(scopeId) || []).map(flow => this.upsertSequenceFlow(flow));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
proto.upsertSequenceFlow = function upsertSequenceFlow(flowDefinition) {
|
|
98
|
+
const refs = this.refs.sequenceFlowRefs;
|
|
99
|
+
let flowInstance = refs[flowDefinition.id];
|
|
100
|
+
if (flowInstance) return flowInstance;
|
|
101
|
+
flowInstance = refs[flowDefinition.id] = new flowDefinition.Behaviour(flowDefinition, this);
|
|
102
|
+
this.refs.sequenceFlows.push(flowInstance);
|
|
103
|
+
return flowInstance;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
proto.getAssociations = function getAssociations(scopeId) {
|
|
107
|
+
return (this.definitionContext.getAssociations(scopeId) || []).map(association => this.upsertAssociation(association));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
proto.upsertAssociation = function upsertAssociation(associationDefinition) {
|
|
111
|
+
const refs = this.refs.associationRefs;
|
|
112
|
+
let instance = refs[associationDefinition.id];
|
|
113
|
+
if (instance) return instance;
|
|
114
|
+
instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
|
|
115
|
+
return instance;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
proto.clone = function clone(newEnvironment) {
|
|
119
|
+
return new ContextInstance(this.definitionContext, newEnvironment || this.environment);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
proto.getProcessById = function getProcessById(processId) {
|
|
123
|
+
const refs = this.refs.processRefs;
|
|
124
|
+
let bp = this.refs.processRefs[processId];
|
|
125
|
+
if (bp) return bp;
|
|
126
|
+
const processDefinition = this.definitionContext.getProcessById(processId);
|
|
127
|
+
if (!processDefinition) return null;
|
|
128
|
+
const bpContext = this.clone(this.environment.clone());
|
|
129
|
+
bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
|
|
130
|
+
this.refs.processes.push(bp);
|
|
131
|
+
return bp;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
proto.getNewProcessById = function getNewProcessById(processId) {
|
|
135
|
+
if (!this.getProcessById(processId)) return null;
|
|
136
|
+
const bpDef = this.definitionContext.getProcessById(processId);
|
|
137
|
+
const bp = new bpDef.Behaviour(bpDef, this.clone(this.environment.clone()));
|
|
138
|
+
return bp;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
proto.getProcesses = function getProcesses() {
|
|
142
|
+
return this.definitionContext.getProcesses().map(({
|
|
143
|
+
id: processId
|
|
144
|
+
}) => this.getProcessById(processId));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
proto.getExecutableProcesses = function getExecutableProcesses() {
|
|
148
|
+
return this.definitionContext.getExecutableProcesses().map(({
|
|
149
|
+
id: processId
|
|
150
|
+
}) => this.getProcessById(processId));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
proto.getMessageFlows = function getMessageFlows(sourceId) {
|
|
154
|
+
if (!this.refs.messageFlows.length) {
|
|
155
|
+
const flows = this.definitionContext.getMessageFlows() || [];
|
|
156
|
+
this.refs.messageFlows.push(...flows.map(flow => new flow.Behaviour(flow, this)));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return this.refs.messageFlows.filter(flow => flow.source.processId === sourceId);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
proto.getDataObjectById = function getDataObjectById(referenceId) {
|
|
163
|
+
let dataObject;
|
|
164
|
+
if (dataObject = this.refs.dataObjectRefs[referenceId]) return dataObject;
|
|
165
|
+
const dataObjectDef = this.definitionContext.getDataObjectById(referenceId);
|
|
166
|
+
if (!dataObjectDef) return;
|
|
167
|
+
dataObject = this.refs.dataObjectRefs[dataObjectDef.id] = new dataObjectDef.Behaviour(dataObjectDef, this);
|
|
168
|
+
return dataObject;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
proto.getDataStoreById = function getDataStoreById(referenceId) {
|
|
172
|
+
let dataStore;
|
|
173
|
+
if (dataStore = this.refs.dataStoreRefs[referenceId]) return dataStore;
|
|
174
|
+
const dataStoreDef = this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
|
|
175
|
+
if (!dataStoreDef) return;
|
|
176
|
+
dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
|
|
177
|
+
return dataStore;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
proto.getStartActivities = function getStartActivities(filterOptions, scopeId) {
|
|
181
|
+
const {
|
|
182
|
+
referenceId,
|
|
183
|
+
referenceType = 'unknown'
|
|
184
|
+
} = filterOptions || {};
|
|
185
|
+
const result = [];
|
|
186
|
+
|
|
187
|
+
for (const activity of this.getActivities()) {
|
|
188
|
+
if (!activity.isStart) continue;
|
|
189
|
+
if (scopeId && activity.parent.id !== scopeId) continue;
|
|
190
|
+
|
|
191
|
+
if (!filterOptions) {
|
|
192
|
+
result.push(activity);
|
|
193
|
+
continue;
|
|
162
194
|
}
|
|
163
195
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function getDataObjectById(referenceId) {
|
|
168
|
-
let dataObject;
|
|
169
|
-
if (dataObject = dataObjectRefs[referenceId]) return dataObject;
|
|
170
|
-
const dataObjectDef = definitionContext.getDataObjectById(referenceId);
|
|
171
|
-
if (!dataObjectDef) return;
|
|
172
|
-
dataObject = dataObjectRefs[dataObjectDef.id] = dataObjectDef.Behaviour(dataObjectDef, context);
|
|
173
|
-
return dataObject;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function getDataStoreById(referenceId) {
|
|
177
|
-
let dataStore;
|
|
178
|
-
if (dataStore = dataStoreRefs[referenceId]) return dataStore;
|
|
179
|
-
const dataStoreDef = definitionContext.getDataStoreById(referenceId) || definitionContext.getDataStoreReferenceById(referenceId);
|
|
180
|
-
if (!dataStoreDef) return;
|
|
181
|
-
dataStore = dataStoreRefs[dataStoreDef.id] = dataStoreDef.Behaviour(dataStoreDef, context);
|
|
182
|
-
return dataStore;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function getStartActivities(filterOptions, scopeId) {
|
|
186
|
-
const {
|
|
187
|
-
referenceId,
|
|
188
|
-
referenceType = 'unknown'
|
|
189
|
-
} = filterOptions || {};
|
|
190
|
-
return getActivities().filter(activity => {
|
|
191
|
-
if (!activity.isStart) return false;
|
|
192
|
-
if (scopeId && activity.parent.id !== scopeId) return false;
|
|
193
|
-
if (!filterOptions) return true;
|
|
194
|
-
if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) return false;
|
|
195
|
-
return activity.eventDefinitions.some(ed => {
|
|
196
|
-
return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
|
|
197
|
-
});
|
|
196
|
+
if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) continue;
|
|
197
|
+
const ref = activity.eventDefinitions.some(ed => {
|
|
198
|
+
return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
|
|
198
199
|
});
|
|
200
|
+
if (ref) result.push(activity);
|
|
199
201
|
}
|
|
200
202
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
return result;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
proto.loadExtensions = function loadExtensions(activity) {
|
|
207
|
+
return this.extensionsMapper.get(activity);
|
|
208
|
+
};
|