Search in sources :

Example 1 with ExtendedNodeImpl

use of io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl in project automatiko-engine by automatiko-io.

the class ExecutableProcessFactory method linkBoundaryConditionEvent.

private void linkBoundaryConditionEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    String processId = ((ExecutableProcess) nodeContainer).getId();
    String eventType = "RuleFlowStateEvent-" + processId + "-" + ((EventNode) node).getUniqueId() + "-" + attachedTo;
    ((EventTypeFilter) ((EventNode) node).getEventFilters().get(0)).setType(eventType);
    ((ExtendedNodeImpl) attachedNode).setCondition(((EventNode) node).getCondition());
    ((ExtendedNodeImpl) attachedNode).setMetaData("ConditionEventType", eventType);
    boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<ProcessAction>();
        }
        ConsequenceAction consequenceAction = new ConsequenceAction("java", "");
        consequenceAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
        actions.add(consequenceAction);
        ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl)

Example 2 with ExtendedNodeImpl

use of io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl in project automatiko-engine by automatiko-io.

the class ProcessHandler method handleIntermediateOrEndThrowCompensationEvent.

protected void handleIntermediateOrEndThrowCompensationEvent(ExtendedNodeImpl throwEventNode) {
    if (throwEventNode.getMetaData("compensation-activityRef") != null) {
        String activityRef = (String) throwEventNode.getMetaData().remove("compensation-activityRef");
        NodeContainer nodeParent = (NodeContainer) throwEventNode.getParentContainer();
        if (nodeParent instanceof EventSubProcessNode) {
            boolean compensationEventSubProcess = false;
            List<Trigger> startTriggers = ((EventSubProcessNode) nodeParent).findStartNode().getTriggers();
            CESP_CHECK: for (Trigger trigger : startTriggers) {
                if (trigger instanceof EventTrigger) {
                    for (EventFilter filter : ((EventTrigger) trigger).getEventFilters()) {
                        if (((EventTypeFilter) filter).getType().equals("Compensation")) {
                            compensationEventSubProcess = true;
                            break CESP_CHECK;
                        }
                    }
                }
            }
            if (compensationEventSubProcess) {
                // BPMN2 spec, p. 252, p. 248: intermediate and end compensation event
                // visibility scope
                nodeParent = (NodeContainer) ((NodeImpl) nodeParent).getParentContainer();
            }
        }
        String parentId;
        if (nodeParent instanceof ExecutableProcess) {
            parentId = ((ExecutableProcess) nodeParent).getId();
        } else {
            parentId = (String) ((NodeImpl) nodeParent).getMetaData("UniqueId");
        }
        String compensationEvent;
        if (activityRef.length() == 0) {
            // general/implicit compensation
            compensationEvent = CompensationScope.IMPLICIT_COMPENSATION_PREFIX + parentId;
        } else {
            // specific compensation
            compensationEvent = activityRef;
        }
        throwEventNode.setMetaData("CompensationEvent", compensationEvent);
        ConsequenceAction compensationAction = new ConsequenceAction("java", "");
        compensationAction.setMetaData("Action", new ProcessInstanceCompensationAction(compensationEvent));
        if (throwEventNode instanceof ActionNode) {
            ((ActionNode) throwEventNode).setAction(compensationAction);
        } else if (throwEventNode instanceof EndNode) {
            List<ProcessAction> actions = new ArrayList<ProcessAction>();
            actions.add(compensationAction);
            ((EndNode) throwEventNode).setActions(EndNode.EVENT_NODE_ENTER, actions);
        }
        throwEventNode.setMetaData("TriggerType", "Compensation");
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) ProcessInstanceCompensationAction(io.automatiko.engine.workflow.base.instance.impl.actions.ProcessInstanceCompensationAction) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) List(java.util.List) ArrayList(java.util.ArrayList) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger)

Example 3 with ExtendedNodeImpl

use of io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl in project automatiko-engine by automatiko-io.

the class ExtendedNodeInstanceImpl method triggerEvent.

protected void triggerEvent(String type) {
    ExtendedNodeImpl extendedNode = getExtendedNode();
    if (extendedNode == null) {
        return;
    }
    List<ProcessAction> actions = extendedNode.getActions(type);
    if (actions != null) {
        for (ProcessAction processAction : actions) {
            Action action = (Action) processAction.getMetaData(ACTION);
            executeAction(action);
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Action(io.automatiko.engine.workflow.base.instance.impl.Action) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl)

Aggregations

ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)3 ExtendedNodeImpl (io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl)3 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)2 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)2 NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)1 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)1 Action (io.automatiko.engine.workflow.base.instance.impl.Action)1 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)1 ProcessInstanceCompensationAction (io.automatiko.engine.workflow.base.instance.impl.actions.ProcessInstanceCompensationAction)1 NodeImpl (io.automatiko.engine.workflow.process.core.impl.NodeImpl)1 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)1 ConstraintTrigger (io.automatiko.engine.workflow.process.core.node.ConstraintTrigger)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 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)1 Trigger (io.automatiko.engine.workflow.process.core.node.Trigger)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1