Search in sources :

Example 36 with EventNode

use of io.automatiko.engine.workflow.process.core.node.EventNode in project automatiko-engine by automatiko-io.

the class ExecutableProcessFactory method linkBoundaryTimerEvent.

protected void linkBoundaryTimerEvent(Node node, String attachedTo, Node attachedNode) {
    boolean cancelActivity = (Boolean) node.getMetaData().get(CANCEL_ACTIVITY);
    StateBasedNode compositeNode = (StateBasedNode) attachedNode;
    String timeDuration = (String) node.getMetaData().get(TIME_DURATION);
    String timeCycle = (String) node.getMetaData().get(TIME_CYCLE);
    String timeDate = (String) node.getMetaData().get(TIME_DATE);
    Timer timer = new Timer();
    if (timeDuration != null) {
        timer.setDelay(timeDuration);
        timer.setTimeType(Timer.TIME_DURATION);
        compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId()));
    } else if (timeCycle != null) {
        int index = timeCycle.indexOf("###");
        if (index != -1) {
            String period = timeCycle.substring(index + 3);
            timeCycle = timeCycle.substring(0, index);
            timer.setPeriod(period);
        }
        timer.setDelay(timeCycle);
        timer.setTimeType(Timer.TIME_CYCLE);
        compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId()));
    } else if (timeDate != null) {
        timer.setDate(timeDate);
        timer.setTimeType(Timer.TIME_DATE);
        compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId()));
    }
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<>();
        }
        ConsequenceAction cancelAction = new ConsequenceAction("java", null);
        cancelAction.setMetaData(ACTION, new CancelNodeInstanceAction(attachedTo));
        actions.add(cancelAction);
        ((EventNode) node).setActions(EVENT_NODE_EXIT, actions);
    }
}
Also used : StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)

Example 37 with EventNode

use of io.automatiko.engine.workflow.process.core.node.EventNode in project automatiko-engine by automatiko-io.

the class ExecutableProcessFactory method linkBoundaryEvents.

protected void linkBoundaryEvents(NodeContainer nodeContainer) {
    for (Node node : nodeContainer.getNodes()) {
        if (node instanceof CompositeNode) {
            CompositeNode compositeNode = (CompositeNode) node;
            linkBoundaryEvents(compositeNode.getNodeContainer());
        }
        if (node instanceof EventNode) {
            final String attachedTo = (String) node.getMetaData().get(ATTACHED_TO);
            if (attachedTo != null) {
                Node attachedNode = findNodeByIdOrUniqueIdInMetadata(nodeContainer, attachedTo, "Could not find node to attach to: " + attachedTo);
                for (EventFilter filter : ((EventNode) node).getEventFilters()) {
                    String type = ((EventTypeFilter) filter).getType();
                    if (type.startsWith("Timer-")) {
                        linkBoundaryTimerEvent(node, attachedTo, attachedNode);
                    } else if (node.getMetaData().get(SIGNAL_NAME) != null || type.startsWith("Message-")) {
                        linkBoundarySignalEvent(node, attachedTo);
                    } else if (type.startsWith("Error-")) {
                        linkBoundaryErrorEvent(nodeContainer, node, attachedTo, attachedNode);
                    } else if (type.startsWith("Condition-") || type.startsWith("RuleFlowStateEvent-")) {
                        linkBoundaryConditionEvent(nodeContainer, node, attachedTo, attachedNode);
                    } else if (type.startsWith("Compensation")) {
                        addCompensationScope(getExecutableProcess(), node, nodeContainer, attachedTo);
                    }
                }
            }
        }
    }
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) 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) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter)

Aggregations

EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)37 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)19 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)18 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)18 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)18 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)18 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)17 Node (io.automatiko.engine.api.definition.process.Node)16 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)13 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)13 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)13 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)13 ArrayList (java.util.ArrayList)13 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)11 StateBasedNode (io.automatiko.engine.workflow.process.core.node.StateBasedNode)11 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)10 HumanTaskNode (io.automatiko.engine.workflow.process.core.node.HumanTaskNode)10 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)10