Search in sources :

Example 1 with ProcessAction

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

the class DefinitionsHandler method postProcessNodes.

protected void postProcessNodes(NodeContainer nodeContainer, List<Variable> parentVariables, ExtensibleXmlParser parser) throws SAXException {
    for (Node node : nodeContainer.getNodes()) {
        List<Variable> variables = new LinkedList<>(parentVariables);
        VariableScope variableScope = (VariableScope) ((ContextContainer) nodeContainer).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        if (variableScope != null) {
            variables.addAll(variableScope.getVariables());
        }
        if (node instanceof NodeContainer) {
            postProcessNodes((NodeContainer) node, variables, parser);
        } else {
            if (node instanceof ActionNode) {
                ActionNode actionNode = (ActionNode) node;
                ProcessAction action = actionNode.getAction();
                if (action instanceof ConsequenceAction) {
                    ConsequenceAction consequenceAction = (ConsequenceAction) action;
                    switch(consequenceAction.getDialect()) {
                        case "java":
                            if (actionNode.getAction().getMetaData("Action") == null) {
                                actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
                            }
                            break;
                        case "mvel":
                            if (actionNode.getAction().getMetaData("Action") == null) {
                                actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
                            }
                            break;
                        default:
                    }
                }
            }
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) Node(io.automatiko.engine.api.definition.process.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) LinkedList(java.util.LinkedList) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 2 with ProcessAction

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

the class ServerlessWorkflowFactory method compensationEventNode.

public ActionNode compensationEventNode(long id, String name, NodeContainer nodeContainer, ExecutableProcess process) {
    ActionNode compensationEventNode = new ActionNode();
    compensationEventNode.setId(id);
    compensationEventNode.setName(name);
    compensationEventNode.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
    ProcessInstanceCompensationAction pic = new ProcessInstanceCompensationAction("implicit:" + process.getId());
    ProcessAction processAction = new ProcessAction();
    processAction.setMetaData(ACTION, pic);
    compensationEventNode.setAction(processAction);
    compensationEventNode.setMetaData(Metadata.TRIGGER_TYPE, "Compensation");
    compensationEventNode.setMetaData("NodeType", "IntermediateThrowEvent-None");
    compensationEventNode.setMetaData("CompensationEvent", "implicit:" + process.getId());
    nodeContainer.addNode(compensationEventNode);
    return compensationEventNode;
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) ProcessInstanceCompensationAction(io.automatiko.engine.workflow.base.instance.impl.actions.ProcessInstanceCompensationAction)

Example 3 with ProcessAction

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

the class ServerlessWorkflowFactory method stateDataFilterActionNode.

public ActionNode stateDataFilterActionNode(long id, String name, NodeContainer nodeContainer, String outputFilterString) {
    ActionNode actionNode = new ActionNode();
    actionNode.setId(id);
    actionNode.setName(name);
    String outputFilter = unwrapExpression(outputFilterString);
    ConsequenceAction processAction = new ConsequenceAction(null, "new io.automatiko.engine.workflow.base.instance.impl.jq.OutputJqAssignmentAction(" + escapeExpression(outputFilter) + ").execute(null, context);");
    io.automatiko.engine.workflow.base.instance.impl.Action injectAction = context -> {
        new OutputJqAssignmentAction(outputFilter).execute(null, context);
    };
    processAction.setMetaData(ACTION, injectAction);
    actionNode.setAction(processAction);
    nodeContainer.addNode(actionNode);
    return actionNode;
}
Also used : Arrays(java.util.Arrays) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) Metadata(io.automatiko.engine.workflow.process.executable.core.Metadata) ExecutableProcessValidator(io.automatiko.engine.workflow.process.executable.core.validation.ExecutableProcessValidator) Constants(io.serverlessworkflow.api.workflow.Constants) LoggerFactory(org.slf4j.LoggerFactory) Workflow(io.serverlessworkflow.api.Workflow) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) FunctionTagDefinition(io.automatiko.engine.workflow.base.core.FunctionTagDefinition) NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) ConstraintImpl(io.automatiko.engine.workflow.process.core.impl.ConstraintImpl) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) OnEvents(io.serverlessworkflow.api.events.OnEvents) TagDefinition(io.automatiko.engine.workflow.base.core.TagDefinition) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Set(java.util.Set) JsonVariableScope(io.automatiko.engine.workflow.base.core.context.variable.JsonVariableScope) ErrorDefinition(io.serverlessworkflow.api.error.ErrorDefinition) WorkflowExecTimeout(io.serverlessworkflow.api.timeouts.WorkflowExecTimeout) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) Collectors(java.util.stream.Collectors) TextNode(com.fasterxml.jackson.databind.node.TextNode) List(java.util.List) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) ProcessInstanceCompensationAction(io.automatiko.engine.workflow.base.instance.impl.actions.ProcessInstanceCompensationAction) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) Join(io.automatiko.engine.workflow.process.core.node.Join) StaticTagDefinition(io.automatiko.engine.workflow.base.core.StaticTagDefinition) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) WorkflowUtils(io.serverlessworkflow.utils.WorkflowUtils) Work(io.automatiko.engine.workflow.base.core.Work) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) Action(io.serverlessworkflow.api.actions.Action) ServerlessExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ServerlessExecutableProcess) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) Split(io.automatiko.engine.workflow.process.core.node.Split) HashMap(java.util.HashMap) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) TaskInputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskInputJqAssignmentAction) ProduceEvent(io.serverlessworkflow.api.produce.ProduceEvent) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) OutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.OutputJqAssignmentAction) TaskOutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskOutputJqAssignmentAction) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) FunctionDefinition(io.serverlessworkflow.api.functions.FunctionDefinition) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) ACTION(io.automatiko.engine.workflow.process.executable.core.Metadata.ACTION) Connection(io.automatiko.engine.api.definition.process.Connection) LinkedHashSet(java.util.LinkedHashSet) ActionDataFilter(io.serverlessworkflow.api.filters.ActionDataFilter) Logger(org.slf4j.Logger) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) Iterator(java.util.Iterator) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) DateTimeUtils(io.automatiko.engine.workflow.base.core.timer.DateTimeUtils) EventDefinition(io.serverlessworkflow.api.events.EventDefinition) RetryDefinition(io.serverlessworkflow.api.retry.RetryDefinition) End(io.serverlessworkflow.api.end.End) EventDataFilter(io.serverlessworkflow.api.filters.EventDataFilter) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) ServerlessFunctions(io.automatiko.engine.workflow.sw.ServerlessFunctions) Process(io.automatiko.engine.workflow.base.core.Process) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) Collections(java.util.Collections) JsonNodeDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.JsonNodeDataType) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) OutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.OutputJqAssignmentAction) TaskOutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskOutputJqAssignmentAction)

Example 4 with ProcessAction

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

the class AbstractNodeHandler method handleAction.

protected void handleAction(final ExtendedNodeImpl node, final Element element, String type) {
    NodeList nodeList = element.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        org.w3c.dom.Node xmlNode = nodeList.item(i);
        String nodeName = xmlNode.getNodeName();
        if (nodeName.equals(type)) {
            List<ProcessAction> actions = new ArrayList<ProcessAction>();
            NodeList subNodeList = xmlNode.getChildNodes();
            for (int j = 0; j < subNodeList.getLength(); j++) {
                Element subXmlNode = (Element) subNodeList.item(j);
                ProcessAction action = extractAction(subXmlNode);
                actions.add(action);
            }
            node.setActions(type, actions);
            return;
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 5 with ProcessAction

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

the class ExceptionHandlerHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    ContextContainer contextContainer = (ContextContainer) parser.getParent();
    final String type = element.getAttribute("type");
    emptyAttributeCheck(localName, "type", type, parser);
    final String faultName = element.getAttribute("faultName");
    emptyAttributeCheck(localName, "faultName", type, parser);
    final String faultVariable = element.getAttribute("faultVariable");
    ActionExceptionHandler exceptionHandler = null;
    if ("action".equals(type)) {
        exceptionHandler = new ActionExceptionHandler();
        org.w3c.dom.Node xmlNode = element.getFirstChild();
        if (xmlNode instanceof Element) {
            Element actionXml = (Element) xmlNode;
            ProcessAction action = ActionNodeHandler.extractAction(actionXml);
            ((ActionExceptionHandler) exceptionHandler).setAction(action);
        }
    } else {
        throw new SAXParseException("Unknown exception handler type " + type, parser.getLocator());
    }
    if (faultVariable != null && faultVariable.length() > 0) {
        exceptionHandler.setFaultVariable(faultVariable);
    }
    ExceptionScope exceptionScope = (ExceptionScope) contextContainer.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope == null) {
        exceptionScope = new ExceptionScope();
        contextContainer.addContext(exceptionScope);
        contextContainer.setDefaultContext(exceptionScope);
    }
    for (String error : faultName.split(",")) {
        exceptionScope.setExceptionHandler(error, exceptionHandler);
    }
    return null;
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope)

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