Search in sources :

Example 26 with Node

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

the class CompensationTest method testNestedCompensationEventSubProcessSpecific.

@Test
public void testNestedCompensationEventSubProcessSpecific() throws Exception {
    String processId = "org.jbpm.process.compensation.event.nested.subprocess";
    String[] workItemNames = { "kwik", "kwek", "kwak" };
    List<String> eventList = new ArrayList<String>();
    ExecutableProcess process = createNestedCompensationEventSubProcessProcess(processId, workItemNames, eventList);
    Node toCompensateNode = findNode(process, "sub1");
    String compensationEvent = (String) toCompensateNode.getMetaData().get("UniqueId");
    ksession = createProcessRuntime(process);
    runCompensationEventSubProcessSpecificTest(ksession, process, processId, workItemNames, eventList, compensationEvent);
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) Node(io.automatiko.engine.workflow.process.core.Node) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ArrayList(java.util.ArrayList) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest) Test(org.junit.jupiter.api.Test)

Example 27 with Node

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

the class CompensationTest method createNestedCompensationBoundaryEventProcess.

private ExecutableProcess createNestedCompensationBoundaryEventProcess(String processId, String[] workItemNames, final List<String> eventList) throws Exception {
    ExecutableProcess process = new ExecutableProcess();
    process.setAutoComplete(true);
    process.setId(processId);
    process.setName("CESP Process");
    process.setMetaData("Compensation", true);
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName("event");
    ObjectDataType personDataType = new ObjectDataType(java.lang.String.class);
    variable.setType(personDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    NodeCreator<StartNode> startNodeCreator = new NodeCreator<StartNode>(process, StartNode.class);
    NodeCreator<EndNode> endNodeCreator = new NodeCreator<EndNode>(process, EndNode.class);
    NodeCreator<CompositeContextNode> compNodeCreator = new NodeCreator<CompositeContextNode>(process, CompositeContextNode.class);
    // process level
    CompositeContextNode compositeNode = compNodeCreator.createNode("sub0");
    {
        StartNode startNode = startNodeCreator.createNode("start0");
        connect(startNode, compositeNode);
        EndNode endNode = endNodeCreator.createNode("end0");
        connect(compositeNode, endNode);
    }
    // 1rst level nested subprocess (contains compensation visibility scope)
    {
        startNodeCreator.setNodeContainer(compositeNode);
        compNodeCreator.setNodeContainer(compositeNode);
        endNodeCreator.setNodeContainer(compositeNode);
        StartNode startNode = startNodeCreator.createNode("start1");
        CompositeContextNode subCompNode = compNodeCreator.createNode("sub1");
        connect(startNode, subCompNode);
        EndNode endNode = endNodeCreator.createNode("end1");
        connect(subCompNode, endNode);
        compositeNode = subCompNode;
    }
    // 2nd level nested subprocess (contains compensation visibility scope)
    NodeCreator<WorkItemNode> workItemNodeCreator = new NodeCreator<WorkItemNode>(compositeNode, WorkItemNode.class);
    {
        startNodeCreator.setNodeContainer(compositeNode);
        compNodeCreator.setNodeContainer(compositeNode);
        endNodeCreator.setNodeContainer(compositeNode);
        StartNode startNode = startNodeCreator.createNode("start2");
        CompositeContextNode subCompNode = compNodeCreator.createNode("sub2");
        connect(startNode, subCompNode);
        WorkItemNode workItemNode = workItemNodeCreator.createNode("work2");
        workItemNode.getWork().setName(workItemNames[2]);
        connect(subCompNode, workItemNode);
        EndNode endNode = endNodeCreator.createNode("end2");
        connect(workItemNode, endNode);
        createBoundaryEventCompensationHandler(compositeNode, workItemNode, eventList, "2");
        compositeNode = subCompNode;
    }
    // Fill 3rd level with process with compensation
    {
        startNodeCreator.setNodeContainer(compositeNode);
        workItemNodeCreator.setNodeContainer(compositeNode);
        endNodeCreator.setNodeContainer(compositeNode);
        StartNode startNode = startNodeCreator.createNode("start");
        Node lastNode = startNode;
        WorkItemNode[] workItemNodes = new WorkItemNode[3];
        for (int i = 0; i < 2; ++i) {
            workItemNodes[i] = workItemNodeCreator.createNode("work-comp-" + (i + 1));
            workItemNodes[i].getWork().setName(workItemNames[i]);
            connect(lastNode, workItemNodes[i]);
            lastNode = workItemNodes[i];
        }
        EndNode endNode = endNodeCreator.createNode("end");
        connect(workItemNodes[1], endNode);
        // Compensation (boundary event) handlers
        for (int i = 0; i < 2; ++i) {
            createBoundaryEventCompensationHandler(compositeNode, workItemNodes[i], eventList, "" + i + 1);
        }
    }
    return process;
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) Node(io.automatiko.engine.workflow.process.core.Node) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) NodeCreator(io.automatiko.engine.workflow.process.test.NodeCreator) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Example 28 with Node

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

the class CompensationTest method findNode.

private Node findNode(ExecutableProcess process, String nodeName) {
    Node found = null;
    Queue<io.automatiko.engine.api.definition.process.Node> nodes = new LinkedList<io.automatiko.engine.api.definition.process.Node>();
    nodes.addAll(Arrays.asList(process.getNodes()));
    while (!nodes.isEmpty()) {
        io.automatiko.engine.api.definition.process.Node node = nodes.poll();
        if (node.getName().equals(nodeName)) {
            found = (Node) node;
        }
        if (node instanceof NodeContainer) {
            nodes.addAll(Arrays.asList(((NodeContainer) node).getNodes()));
        }
    }
    assertNotNull(found, "Could not find node (" + nodeName + ").");
    return found;
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) Node(io.automatiko.engine.workflow.process.core.Node) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) LinkedList(java.util.LinkedList)

Example 29 with Node

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

the class StateNodeInstance method isCompleted.

private boolean isCompleted() {
    if (getProcessInstance() instanceof ExecutableProcessInstance) {
        ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
        context.setProcessInstance(getProcessInstance());
        context.setNodeInstance(this);
        return getStateNode().isMet(context);
    } else {
        if (((Node) getNode()).getCompletionCheck().isPresent()) {
            if (((Node) getNode()).getCompletionCheck().get().isValid(getProcessInstance().getVariables())) {
                return true;
            }
        }
        return false;
    }
}
Also used : StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) Node(io.automatiko.engine.workflow.process.core.Node) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) ProcessContext(io.automatiko.engine.workflow.base.core.context.ProcessContext)

Example 30 with Node

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

the class CallActivityHandler method end.

@SuppressWarnings("unchecked")
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    handleNode(node, element, uri, localName, parser);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    int uniqueIdGen = 1;
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            String uniqueId = (String) node.getMetaData().get("UniqueId");
            forEachNode.setMetaData("UniqueId", uniqueId);
            node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
            node.setMetaData("hidden", true);
            forEachNode.addNode(node);
            forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            Node orignalNode = node;
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser);
            // running in variable strict mode
            if (orignalNode instanceof SubProcessNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            Map<String, String> dataInputs = (Map<String, String>) orignalNode.getMetaData().remove("DataInputs");
            Map<String, String> dataOutputs = (Map<String, String>) orignalNode.getMetaData().remove("DataOutputs");
            orignalNode.setMetaData("MICollectionOutput", dataOutputs.get(((ForEachNode) node).getMetaData("MICollectionOutput")));
            orignalNode.setMetaData("MICollectionInput", dataInputs.get(((ForEachNode) node).getMetaData("MICollectionInput")));
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : Element(org.w3c.dom.Element) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) Node(io.automatiko.engine.workflow.process.core.Node) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Node (io.automatiko.engine.workflow.process.core.Node)36 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)19 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)19 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)16 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)16 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)15 ArrayList (java.util.ArrayList)14 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)13 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)12 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)11 Element (org.w3c.dom.Element)11 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)10 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)10 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)8 Test (org.junit.jupiter.api.Test)8 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)6 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)6