Search in sources :

Example 1 with CancelNodeInstanceAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction 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 CancelNodeInstanceAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction 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 3 with CancelNodeInstanceAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction 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)

Example 4 with CancelNodeInstanceAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction in project automatiko-engine by automatiko-io.

the class ProcessHandler method linkBoundaryEscalationEvent.

protected void linkBoundaryEscalationEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
    String escalationCode = (String) node.getMetaData().get("EscalationEvent");
    String escalationStructureRef = (String) node.getMetaData().get("EscalationStructureRef");
    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 variable = ((EventNode) node).getVariableName();
    ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
    ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Escalation-" + attachedTo + "-" + escalationCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
    exceptionHandler.setAction(action);
    exceptionHandler.setFaultVariable(variable);
    exceptionScope.setExceptionHandler(escalationCode, exceptionHandler);
    if (escalationStructureRef != null) {
        exceptionScope.setExceptionHandler(escalationStructureRef, exceptionHandler);
    }
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<ProcessAction>();
        }
        ConsequenceAction cancelAction = new ConsequenceAction("java", "");
        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) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode)

Example 5 with CancelNodeInstanceAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction in project automatiko-engine by automatiko-io.

the class ProcessHandler method linkBoundarySignalEvent.

protected void linkBoundarySignalEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    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 action = createJavaAction(new CancelNodeInstanceAction(attachedTo));
        actions.add(action);
        ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) 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

CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)9 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)9 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)9 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)9 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)5 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)4 ActionExceptionHandler (io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler)4 ExceptionScope (io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope)4 SignalProcessInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction)4 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)3 Timer (io.automatiko.engine.workflow.base.core.timer.Timer)2 StateBasedNode (io.automatiko.engine.workflow.process.core.node.StateBasedNode)2 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)2 Node (io.automatiko.engine.api.definition.process.Node)1 NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)1 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)1 FunctionTagDefinition (io.automatiko.engine.workflow.base.core.FunctionTagDefinition)1 Process (io.automatiko.engine.workflow.base.core.Process)1 StaticTagDefinition (io.automatiko.engine.workflow.base.core.StaticTagDefinition)1 TagDefinition (io.automatiko.engine.workflow.base.core.TagDefinition)1