Search in sources :

Example 1 with ExecutableProcess

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

the class DmnDecisionInProcessTest method createProcess.

private ExecutableProcess createProcess(String namespace, String modelName, String decisionName) {
    DMNRuntime dmnRuntime = DmnRuntimeProvider.fromClassPath("PersonDecisions.dmn");
    DmnDecisionModel dmnDecisionModel = new DmnDecisionModel(dmnRuntime, namespace, modelName);
    ExecutableProcess process = new ExecutableProcess();
    process.setId("process");
    process.setName("Process");
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable1 = new Variable();
    variable1.setName("person");
    variable1.setType(new ObjectDataType(Person.class));
    variables.add(variable1);
    Variable variable2 = new Variable();
    variable2.setName("isAdult");
    variable2.setType(new BooleanDataType());
    variables.add(variable2);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    RuleSetNode ruleSetNode = new RuleSetNode();
    ruleSetNode.setName("RuleSetNode");
    ruleSetNode.setId(2);
    ruleSetNode.setRuleType(RuleSetNode.RuleType.decision(namespace, modelName, null));
    ruleSetNode.setLanguage(RuleSetNode.DMN_LANG);
    ruleSetNode.setDecisionModel(() -> dmnDecisionModel);
    ruleSetNode.addInMapping("Person", "person");
    ruleSetNode.addOutMapping("isAdult", "isAdult");
    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);
    connect(startNode, ruleSetNode);
    connect(ruleSetNode, endNode);
    process.addNode(startNode);
    process.addNode(ruleSetNode);
    process.addNode(endNode);
    return process;
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) DmnDecisionModel(io.automatiko.engine.decision.dmn.DmnDecisionModel) ArrayList(java.util.ArrayList) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 2 with ExecutableProcess

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

the class LightProcessRuntime method initStartTimers.

public void initStartTimers() {
    Collection<Process> processes = runtimeContext.getProcesses();
    for (Process process : processes) {
        ExecutableProcess p = (ExecutableProcess) process;
        List<StartNode> startNodes = p.getTimerStart();
        if (startNodes != null && !startNodes.isEmpty()) {
            for (StartNode startNode : startNodes) {
                if (startNode != null && startNode.getTimer() != null) {
                    jobService.scheduleProcessJob(ProcessJobDescription.of(createTimerInstance(startNode.getTimer()), p.getId(), p.getVersion()));
                }
            }
        }
    }
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Example 3 with ExecutableProcess

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

the class LightProcessRuntime method initProcessEventListener.

private void initProcessEventListener(Process process) {
    if (process instanceof ExecutableProcess) {
        for (Node node : ((ExecutableProcess) process).getNodes()) {
            if (node instanceof StartNode) {
                StartNode startNode = (StartNode) node;
                if (startNode != null) {
                    List<Trigger> triggers = startNode.getTriggers();
                    if (triggers != null) {
                        for (Trigger trigger : triggers) {
                            if (trigger instanceof EventTrigger) {
                                final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
                                String type = null;
                                for (EventFilter filter : filters) {
                                    if (filter instanceof EventTypeFilter) {
                                        type = ((EventTypeFilter) filter).getType();
                                    }
                                }
                                StartProcessEventListener listener = new StartProcessEventListener(process.getId(), filters, trigger.getInMappings(), startNode.getEventTransformer());
                                signalManager.addEventListener(type, listener);
                                ((ExecutableProcess) process).getRuntimeMetaData().put("StartProcessEventType", type);
                                ((ExecutableProcess) process).getRuntimeMetaData().put("StartProcessEventListener", listener);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) Node(io.automatiko.engine.api.definition.process.Node) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger)

Example 4 with ExecutableProcess

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

the class IntermediateCatchEventHandler method handleLinkNode.

protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    node.setName(element.getAttribute("name"));
    NamedNodeMap linkAttr = xmlLinkNode.getAttributes();
    String name = linkAttr.getNamedItem("name").getNodeValue();
    String id = element.getAttribute("id");
    node.setMetaData("UniqueId", id);
    node.setMetaData(LINK_NAME, name);
    org.w3c.dom.Node xmlNode = xmlLinkNode.getFirstChild();
    IntermediateLink aLink = new IntermediateLink();
    aLink.setName(name);
    aLink.setUniqueId(id);
    while (null != xmlNode) {
        String nodeName = xmlNode.getNodeName();
        if ("target".equals(nodeName)) {
            String target = xmlNode.getTextContent();
            node.setMetaData("target", target);
            aLink.setTarget(target);
        }
        if ("source".equals(nodeName)) {
            String source = xmlNode.getTextContent();
            node.setMetaData("source", source);
            aLink.addSource(source);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (nodeContainer instanceof ExecutableProcess) {
        ExecutableProcess process = (ExecutableProcess) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) process.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        process.setMetaData(ProcessHandler.LINKS, links);
    } else if (nodeContainer instanceof CompositeNode) {
        CompositeNode subprocess = (CompositeNode) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) subprocess.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        subprocess.setMetaData(ProcessHandler.LINKS, links);
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ArrayList(java.util.ArrayList) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) IntermediateLink(io.automatiko.engine.workflow.bpmn2.core.IntermediateLink) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ExecutableProcess

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

the class AbstractNodeHandler method getErrorIdForErrorCode.

protected String getErrorIdForErrorCode(String errorCode, Node node) {
    io.automatiko.engine.api.definition.process.NodeContainer parent = node.getParentContainer();
    while (!(parent instanceof ExecutableProcess) && parent instanceof Node) {
        parent = ((Node) parent).getParentContainer();
    }
    if (!(parent instanceof ExecutableProcess)) {
        throw new RuntimeException("This should never happen: !(parent instanceof RuleFlowProcess): parent is " + parent.getClass().getSimpleName());
    }
    List<Error> errors = ((Definitions) ((ExecutableProcess) parent).getMetaData("Definitions")).getErrors();
    Error error = null;
    for (Error listError : errors) {
        if (errorCode.equals(listError.getErrorCode())) {
            error = listError;
            break;
        } else if (errorCode.equals(listError.getId())) {
            error = listError;
            break;
        }
    }
    if (error == null) {
        throw new IllegalArgumentException("Could not find error with errorCode " + errorCode);
    }
    return error.getId();
}
Also used : Node(io.automatiko.engine.workflow.process.core.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) Error(io.automatiko.engine.workflow.bpmn2.core.Error) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Aggregations

ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)58 ArrayList (java.util.ArrayList)29 Test (org.junit.jupiter.api.Test)29 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)28 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)26 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)23 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)20 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)16 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)16 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)15 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)14 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 Node (io.automatiko.engine.workflow.process.core.Node)12 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)12 List (java.util.List)12 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)11 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)11 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)10 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)10 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)9