Search in sources :

Example 6 with SignalProcessInstanceAction

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

the class ProcessHandler method linkBoundaryErrorEvent.

protected 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 = createJavaAction(new SignalProcessInstanceAction("Error-" + attachedTo + "-" + errorCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
    exceptionHandler.setAction(action);
    exceptionHandler.setFaultVariable(variable);
    if (hasErrorCode) {
        for (String error : errorCode.split(",")) {
            exceptionScope.setExceptionHandler(error, exceptionHandler);
        }
    } else {
        exceptionScope.setExceptionHandler(null, exceptionHandler);
    }
    exceptionHandler.setRetryAfter((Integer) node.getMetaData().get("ErrorRetry"));
    exceptionHandler.setRetryLimit((Integer) node.getMetaData().get("ErrorRetryLimit"));
    exceptionHandler.setRetryIncrement((Integer) node.getMetaData().get("ErrorRetryIncrement"));
    if (node.getMetaData().get("ErrorRetryIncrementMultiplier") != null) {
        exceptionHandler.setRetryIncrementMultiplier(((Number) node.getMetaData().get("ErrorRetryIncrementMultiplier")).floatValue());
    }
    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) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode)

Example 7 with SignalProcessInstanceAction

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

the class IntermediateThrowEventHandler method handleSignalNode.

public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataInput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String inputName = ((Element) xmlNode).getAttribute("name");
            dataInputs.put(id, inputName);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, actionNode, parser);
        } else if ("signalEventDefinition".equals(nodeName)) {
            String signalName = ((Element) xmlNode).getAttribute("signalRef");
            String variable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE_KEY), parser);
            signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
            actionNode.setMetaData("EventType", "signal");
            actionNode.setMetaData("Ref", signalName);
            actionNode.setMetaData("Variable", variable);
            actionNode.setMetaData("TriggerType", "Signal");
            // check if signal should be send async
            if (dataInputs.containsValue("async")) {
                signalName = "ASYNC-" + signalName;
            }
            ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, (String) actionNode.getMetaData("customScope"), (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
            actionNode.setAction(action);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) Element(org.w3c.dom.Element) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode)

Example 8 with SignalProcessInstanceAction

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

the class EndEventHandler method handleSignalNode.

public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    EndNode endNode = (EndNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataInput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String inputName = ((Element) xmlNode).getAttribute("name");
            dataInputs.put(id, inputName);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readEndDataInputAssociation(xmlNode, endNode);
        } else if ("signalEventDefinition".equals(nodeName)) {
            String signalName = ((Element) xmlNode).getAttribute("signalRef");
            String variable = (String) endNode.getMetaData("MappingVariable");
            signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
            endNode.setMetaData("EventType", "signal");
            endNode.setMetaData("Ref", signalName);
            endNode.setMetaData("Variable", variable);
            // check if signal should be send async
            if (dataInputs.containsValue("async")) {
                signalName = "ASYNC-" + signalName;
            }
            ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, (String) endNode.getMetaData("customScope"), (Transformation) endNode.getMetaData().get("Transformation")));
            List<ProcessAction> actions = new ArrayList<ProcessAction>();
            actions.add(action);
            endNode.setActions(EndNode.EVENT_NODE_ENTER, actions);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) Element(org.w3c.dom.Element) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ArrayList(java.util.ArrayList)

Aggregations

SignalProcessInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction)8 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)8 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)6 ActionExceptionHandler (io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler)6 ExceptionScope (io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope)6 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)6 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)5 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)5 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)4 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)3 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)3 Node (io.automatiko.engine.api.definition.process.Node)2 NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)2 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)2 FunctionTagDefinition (io.automatiko.engine.workflow.base.core.FunctionTagDefinition)2 Process (io.automatiko.engine.workflow.base.core.Process)2 StaticTagDefinition (io.automatiko.engine.workflow.base.core.StaticTagDefinition)2 TagDefinition (io.automatiko.engine.workflow.base.core.TagDefinition)2 CompensationHandler (io.automatiko.engine.workflow.base.core.context.exception.CompensationHandler)2 CompensationScope (io.automatiko.engine.workflow.base.core.context.exception.CompensationScope)2