Search in sources :

Example 1 with ConnectionImpl

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

the class ServerlessWorkflowFactory method connect.

public Connection connect(long fromId, long toId, String uniqueId, NodeContainer nodeContainer, boolean association) {
    Node from = nodeContainer.getNode(fromId);
    Node to = nodeContainer.getNode(toId);
    ConnectionImpl connection = new ConnectionImpl(from, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, to, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
    connection.setMetaData(UNIQUE_ID_PARAM, uniqueId);
    if (association) {
        connection.setMetaData("association", true);
    }
    return connection;
}
Also used : TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Node(io.automatiko.engine.api.definition.process.Node) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)

Example 2 with ConnectionImpl

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

the class EndNodeInstanceTest method testEndNode.

@Test
public void testEndNode() {
    MockNode mockNode = new MockNode();
    MockNodeInstanceFactory factory = new MockNodeInstanceFactory(new MockNodeInstance(mockNode));
    NodeInstanceFactoryRegistry.getInstance().register(mockNode.getClass(), factory);
    ExecutableProcess process = new ExecutableProcess();
    process.setId("test");
    InternalProcessRuntime processRuntime = createProcessRuntime(process);
    Node endNode = new EndNode();
    endNode.setId(1);
    endNode.setName("end node");
    mockNode.setId(2);
    new ConnectionImpl(mockNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    process.addNode(mockNode);
    process.addNode(endNode);
    ExecutableProcessInstance processInstance = new ExecutableProcessInstance();
    processInstance.setId("1223");
    processInstance.setState(ProcessInstance.STATE_ACTIVE);
    processInstance.setProcess(process);
    processInstance.setProcessRuntime(processRuntime);
    MockNodeInstance mockNodeInstance = (MockNodeInstance) processInstance.getNodeInstance(mockNode);
    mockNodeInstance.triggerCompleted();
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Also used : EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) Node(io.automatiko.engine.workflow.process.core.Node) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 3 with ConnectionImpl

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

the class ExecutableNodeContainerFactory method connection.

public ExecutableNodeContainerFactory connection(long fromId, long toId, String uniqueId, boolean association) {
    Node from = nodeContainer.getNode(fromId);
    Node to = nodeContainer.getNode(toId);
    ConnectionImpl connection = new ConnectionImpl(from, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, to, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
    connection.setMetaData("UniqueId", uniqueId);
    if (association) {
        connection.setMetaData("association", true);
    }
    return this;
}
Also used : Node(io.automatiko.engine.api.definition.process.Node) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)

Example 4 with ConnectionImpl

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

the class CompositeNode method linkOutgoingConnections.

public void linkOutgoingConnections(CompositeNode.NodeAndType outNode, String outType) {
    CompositeNode.NodeAndType oldNodeAndType = outConnectionMap.get(outType);
    if (oldNodeAndType != null) {
        if (oldNodeAndType.equals(outNode)) {
            return;
        } else {
            // remove old end nodes + connections
            List<Connection> oldOutConnections = oldNodeAndType.getNode().getOutgoingConnections(oldNodeAndType.getType());
            for (Connection connection : new ArrayList<Connection>(oldOutConnections)) {
                if (connection.getTo() instanceof CompositeNodeEnd) {
                    removeNode(connection.getTo());
                    ((ConnectionImpl) connection).terminate();
                }
            }
        }
    }
    outConnectionMap.put(outType, outNode);
    if (outNode != null) {
        List<Connection> connections = getOutgoingConnections(outType);
        for (Connection connection : connections) {
            CompositeNodeEnd end = new CompositeNodeEnd(this, connection.getTo(), outType);
            internalAddNode(end);
            if (outNode.getNode() != null) {
                new ConnectionImpl(outNode.getNode(), outNode.getType(), end, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
            }
        }
    }
}
Also used : Connection(io.automatiko.engine.api.definition.process.Connection) ArrayList(java.util.ArrayList) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)

Example 5 with ConnectionImpl

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

the class CompositeNode method linkIncomingConnections.

public void linkIncomingConnections(String inType, CompositeNode.NodeAndType inNode) {
    CompositeNode.NodeAndType oldNodeAndType = inConnectionMap.get(inType);
    if (oldNodeAndType != null) {
        if (oldNodeAndType.equals(inNode)) {
            return;
        } else {
            // remove old start nodes + connections
            List<Connection> oldInConnections = oldNodeAndType.getNode().getIncomingConnections(oldNodeAndType.getType());
            if (oldInConnections != null) {
                for (Connection connection : new ArrayList<Connection>(oldInConnections)) {
                    if (connection.getFrom() instanceof CompositeNodeStart) {
                        removeNode(connection.getFrom());
                        ((ConnectionImpl) connection).terminate();
                    }
                }
            }
        }
    }
    inConnectionMap.put(inType, inNode);
    if (inNode != null) {
        List<Connection> connections = getIncomingConnections(inType);
        for (Connection connection : connections) {
            CompositeNodeStart start = new CompositeNodeStart(this, connection.getFrom(), inType);
            internalAddNode(start);
            if (inNode.getNode() != null) {
                new ConnectionImpl(start, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, inNode.getNode(), inNode.getType());
            }
        }
    }
}
Also used : Connection(io.automatiko.engine.api.definition.process.Connection) ArrayList(java.util.ArrayList) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)

Aggregations

ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)22 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)11 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)11 Node (io.automatiko.engine.api.definition.process.Node)10 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)10 ArrayList (java.util.ArrayList)9 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)7 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)7 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)7 Test (org.junit.jupiter.api.Test)7 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)6 Connection (io.automatiko.engine.api.definition.process.Connection)5 ProcessCompletedEvent (io.automatiko.engine.api.event.process.ProcessCompletedEvent)5 ProcessEventListener (io.automatiko.engine.api.event.process.ProcessEventListener)5 ProcessNodeLeftEvent (io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)5 ProcessNodeTriggeredEvent (io.automatiko.engine.api.event.process.ProcessNodeTriggeredEvent)5 ProcessStartedEvent (io.automatiko.engine.api.event.process.ProcessStartedEvent)5 ProcessVariableChangedEvent (io.automatiko.engine.api.event.process.ProcessVariableChangedEvent)5 ProcessContext (io.automatiko.engine.api.runtime.process.ProcessContext)5 ProcessRuntimeImpl (io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl)5