Search in sources :

Example 6 with ProcessAction

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

use of io.automatiko.engine.workflow.process.core.ProcessAction 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 8 with ProcessAction

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

the class ExecutableProcessFactory method timerAction.

protected ProcessAction timerAction(String type) {
    ProcessAction signal = new ProcessAction();
    Action action = kcontext -> kcontext.getProcessInstance().signalEvent(type, kcontext.getNodeInstance().getId());
    signal.wire(action);
    return signal;
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SIGNAL_NAME(io.automatiko.engine.workflow.process.executable.core.Metadata.SIGNAL_NAME) Arrays(java.util.Arrays) CompensationHandler(io.automatiko.engine.workflow.base.core.context.exception.CompensationHandler) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) BiFunction(java.util.function.BiFunction) ExecutableProcessValidator(io.automatiko.engine.workflow.process.executable.core.validation.ExecutableProcessValidator) LoggerFactory(org.slf4j.LoggerFactory) DataType(io.automatiko.engine.api.workflow.datatype.DataType) FunctionTagDefinition(io.automatiko.engine.workflow.base.core.FunctionTagDefinition) Action(io.automatiko.engine.workflow.base.instance.impl.Action) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) Map(java.util.Map) CANCEL_ACTIVITY(io.automatiko.engine.workflow.process.executable.core.Metadata.CANCEL_ACTIVITY) TagDefinition(io.automatiko.engine.workflow.base.core.TagDefinition) Swimlane(io.automatiko.engine.workflow.base.core.context.swimlane.Swimlane) Collection(java.util.Collection) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EVENT_NODE_EXIT(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl.EVENT_NODE_EXIT) TIME_CYCLE(io.automatiko.engine.workflow.process.executable.core.Metadata.TIME_CYCLE) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) VariableFactory(io.automatiko.engine.workflow.process.executable.core.factory.VariableFactory) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) ATTACHED_TO(io.automatiko.engine.workflow.process.executable.core.Metadata.ATTACHED_TO) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) List(java.util.List) TIME_DURATION(io.automatiko.engine.workflow.process.executable.core.Metadata.TIME_DURATION) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) ExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ExceptionHandler) EndNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) EventSubProcessNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EventSubProcessNodeFactory) StaticTagDefinition(io.automatiko.engine.workflow.base.core.StaticTagDefinition) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) UNIQUE_ID(io.automatiko.engine.workflow.process.executable.core.Metadata.UNIQUE_ID) HashMap(java.util.HashMap) ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) ProcessContext(io.automatiko.engine.api.runtime.process.ProcessContext) TIME_DATE(io.automatiko.engine.workflow.process.executable.core.Metadata.TIME_DATE) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) ACTION(io.automatiko.engine.workflow.process.executable.core.Metadata.ACTION) StartNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) Logger(org.slf4j.Logger) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) CompensationScope(io.automatiko.engine.workflow.base.core.context.exception.CompensationScope) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Action(io.automatiko.engine.workflow.base.instance.impl.Action) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)

Example 9 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction 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 10 with ProcessAction

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

the class StateBasedNode method addTimer.

public void addTimer(Timer timer, ProcessAction action) {
    if (timers == null) {
        timers = new HashMap<Timer, ProcessAction>();
    }
    if (timer.getId() == 0) {
        long id = 0;
        for (Timer t : timers.keySet()) {
            if (t.getId() > id) {
                id = t.getId();
            }
        }
        timer.setId(++id);
    }
    timers.put(timer, action);
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer)

Aggregations

ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)47 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)30 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)20 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)18 ArrayList (java.util.ArrayList)18 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)15 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)14 Action (io.automatiko.engine.workflow.base.instance.impl.Action)13 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)13 Timer (io.automatiko.engine.workflow.base.core.timer.Timer)12 ProcessContext (io.automatiko.engine.api.runtime.process.ProcessContext)11 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)11 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)10 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)9 Node (io.automatiko.engine.api.definition.process.Node)8 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)7 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)7 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)7 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)7