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;
}
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());
}
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;
}
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);
}
}
}
}
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());
}
}
}
}
Aggregations