Search in sources :

Example 1 with EventSubProcessNodeFactory

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;
}
Also used : EventSubProcessNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EventSubProcessNodeFactory) StartNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EndNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory)

Aggregations

Node (io.automatiko.engine.api.definition.process.Node)1 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)1 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)1 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)1 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)1 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 StateBasedNode (io.automatiko.engine.workflow.process.core.node.StateBasedNode)1 EndNodeFactory (io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory)1 EventSubProcessNodeFactory (io.automatiko.engine.workflow.process.executable.core.factory.EventSubProcessNodeFactory)1 StartNodeFactory (io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory)1