Search in sources :

Example 6 with ConsequenceAction

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

the class AbstractNodeHandler method extractAction.

public static ProcessAction extractAction(Element xmlNode) {
    String actionType = xmlNode.getAttribute("type");
    if ("expression".equals(actionType)) {
        String consequence = xmlNode.getTextContent();
        ConsequenceAction action = new ConsequenceAction(xmlNode.getAttribute("dialect"), consequence);
        return action;
    } else {
        throw new IllegalArgumentException("Unknown action type " + actionType);
    }
}
Also used : ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)

Example 7 with ConsequenceAction

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

the class ActionNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    ActionNode actionNode = (ActionNode) node;
    writeNode("actionNode", actionNode, xmlDump, includeMeta);
    ConsequenceAction action = (ConsequenceAction) actionNode.getAction();
    if (action != null || (includeMeta && containsMetaData(actionNode))) {
        xmlDump.append(">" + EOL);
        if (action != null) {
            writeAction(action, xmlDump);
        }
        if (includeMeta) {
            writeMetaData(actionNode, xmlDump);
        }
        endNode("actionNode", xmlDump);
    } else {
        endNode(xmlDump);
    }
}
Also used : ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode)

Example 8 with ConsequenceAction

use of io.automatiko.engine.workflow.process.core.impl.ConsequenceAction 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 9 with ConsequenceAction

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

the class ExecutableProcessFactory method linkBoundaryErrorEvent.

private static void linkBoundaryErrorEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    ContextContainer compositeNode = (ContextContainer) attachedNode;
    ExceptionScope exceptionScope = (ExceptionScope) compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope == null) {
        exceptionScope = new ExceptionScope();
        compositeNode.addContext(exceptionScope);
        compositeNode.setDefaultContext(exceptionScope);
    }
    String errorCode = (String) node.getMetaData().get("ErrorEvent");
    boolean hasErrorCode = (Boolean) node.getMetaData().get("HasErrorEvent");
    String errorStructureRef = (String) node.getMetaData().get("ErrorStructureRef");
    ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
    String variable = ((EventNode) node).getVariableName();
    ConsequenceAction action = new ConsequenceAction("java", null);
    action.setMetaData(ACTION, new SignalProcessInstanceAction("Error-" + attachedTo + "-" + errorCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
    exceptionHandler.setAction(action);
    exceptionHandler.setFaultVariable(variable);
    exceptionHandler.setRetryAfter((Integer) node.getMetaData().get("ErrorRetry"));
    exceptionHandler.setRetryIncrement((Integer) node.getMetaData().get("ErrorRetryIncrement"));
    if (node.getMetaData().get("ErrorRetryIncrementMultiplier") != null) {
        exceptionHandler.setRetryIncrementMultiplier(((Number) node.getMetaData().get("ErrorRetryIncrementMultiplier")).floatValue());
    }
    exceptionHandler.setRetryLimit((Integer) node.getMetaData().get("ErrorRetryLimit"));
    if (hasErrorCode) {
        for (String error : errorCode.split(",")) {
            exceptionScope.setExceptionHandler(error, exceptionHandler);
        }
    } else {
        exceptionScope.setExceptionHandler(null, exceptionHandler);
    }
    if (errorStructureRef != null) {
        exceptionScope.setExceptionHandler(errorStructureRef, exceptionHandler);
    }
    List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
    if (actions == null) {
        actions = new ArrayList<ProcessAction>();
    }
    ConsequenceAction cancelAction = new ConsequenceAction("java", null);
    cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
    actions.add(cancelAction);
    ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode)

Example 10 with ConsequenceAction

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

the class ExecutableProcessFactory method linkBoundarySignalEvent.

protected void linkBoundarySignalEvent(Node node, String attachedTo) {
    boolean cancelActivity = (Boolean) node.getMetaData().get(CANCEL_ACTIVITY);
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<>();
        }
        ConsequenceAction action = new ConsequenceAction("java", null);
        action.setMetaData(ACTION, new CancelNodeInstanceAction(attachedTo));
        actions.add(action);
        ((EventNode) node).setActions(EVENT_NODE_EXIT, actions);
    }
}
Also used : 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) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)

Aggregations

ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)49 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)30 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)25 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)18 ArrayList (java.util.ArrayList)17 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)16 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)15 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)14 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)11 Action (io.automatiko.engine.workflow.base.instance.impl.Action)10 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)10 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)10 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)10 Timer (io.automatiko.engine.workflow.base.core.timer.Timer)9 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)9 Map (java.util.Map)9 Node (io.automatiko.engine.api.definition.process.Node)8 ProcessContext (io.automatiko.engine.api.runtime.process.ProcessContext)8 ActionExceptionHandler (io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler)8