use of io.automatiko.engine.workflow.process.executable.core.factory.EventSubProcessNodeFactory in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method executionTimeout.
public ExecutableProcessFactory executionTimeout(int nodeIdCounter, String timeoutExpression, long... extranodes) {
int nodeId = ++nodeIdCounter;
EventSubProcessNodeFactory eventSubProcessNode4 = eventSubProcessNode(nodeId);
eventSubProcessNode4.name("Execution timeout");
eventSubProcessNode4.metaData("UniqueId", "SubProcess_" + nodeId);
eventSubProcessNode4.metaData("hidden_node", true);
eventSubProcessNode4.keepActive(true);
eventSubProcessNode4.event("Timer-" + nodeId);
eventSubProcessNode4.autoComplete(true);
int startNodeId = ++nodeIdCounter;
StartNodeFactory startNode5 = eventSubProcessNode4.startNode(startNodeId);
startNode5.name("Execution timeout :: start");
startNode5.interrupting(true);
startNode5.metaData("UniqueId", "StartEvent_" + startNodeId);
startNode5.metaData("TriggerType", "Timer");
startNode5.done();
startNode5.timer(timeoutExpression, null, null, 1);
int endNodeId = ++nodeIdCounter;
EndNodeFactory endNode7 = eventSubProcessNode4.endNode(endNodeId);
endNode7.name("Execution timeout :: end");
endNode7.terminate(false);
endNode7.metaData("UniqueId", "EndEvent_" + endNodeId);
endNode7.done();
if (extranodes != null && extranodes.length > 0) {
for (long extraNodId : extranodes) {
Node node = getNodeContainer().getNode(extraNodId);
getNodeContainer().removeNode(node);
eventSubProcessNode4.getNodeContainer().addNode(node);
}
if (extranodes.length == 1) {
eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
eventSubProcessNode4.connection(extranodes[0], endNodeId, "SequenceFlow_e_" + endNodeId);
} else {
eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
int counter = 1;
for (long extraNodId : extranodes) {
if (counter > extranodes.length) {
eventSubProcessNode4.connection(extraNodId, extranodes[counter], "SequenceFlow_e_" + counter);
counter++;
}
}
eventSubProcessNode4.connection(extranodes[extranodes.length - 1], endNodeId, "SequenceFlow_e_" + endNodeId);
}
} else {
eventSubProcessNode4.connection(startNodeId, endNodeId, "SequenceFlow_" + startNodeId);
}
eventSubProcessNode4.done();
return this;
}
Aggregations