new ConnectionImpl( start, Node.CONNECTION_DEFAULT_TYPE, timerNode, Node.CONNECTION_DEFAULT_TYPE ); ActionNode actionNode = new ActionNode(); actionNode.setId( 3 ); actionNode.setName( "Action" ); DroolsConsequenceAction action = new DroolsConsequenceAction(); action.setDialect( "java" ); action.setConsequence( "System.out.println(\"Executed action\");" ); new ConnectionImpl( timerNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE ); EndNode end = new EndNode(); end.setId( 6 ); end.setName( "End" ); process.addNode( end ); new ConnectionImpl( actionNode, Node.CONNECTION_DEFAULT_TYPE, end,
ConnectionImpl connection = new ConnectionImpl(fromNode, fromType,toNode, toType); connection.setMetaData("bendpoints", bendpoints);
private static void insertNodeInBetween(RuleFlowProcess process, long startNodeId, long endNodeId, NodeImpl node) { if (process == null) { throw new IllegalArgumentException("Process may not be null"); } NodeImpl selectedNode = (NodeImpl) process.getNode(startNodeId); if (selectedNode == null) { throw new IllegalArgumentException("Node " + startNodeId + " not found in process " + process.getId()); } for (Connection connection: selectedNode.getDefaultOutgoingConnections()) { if (connection.getTo().getId() == endNodeId) { process.addNode(node); NodeImpl endNode = (NodeImpl) connection.getTo(); ((ConnectionImpl) connection).terminate(); new ConnectionImpl(selectedNode, NodeImpl.CONNECTION_DEFAULT_TYPE, node, NodeImpl.CONNECTION_DEFAULT_TYPE); new ConnectionImpl(node, NodeImpl.CONNECTION_DEFAULT_TYPE, endNode, NodeImpl.CONNECTION_DEFAULT_TYPE); return; } } throw new IllegalArgumentException("Connection to node " + endNodeId + " not found in process " + process.getId()); }
if (connection.getTo() instanceof CompositeNodeEnd) { removeNode(connection.getTo()); ((ConnectionImpl) connection).terminate(); internalAddNode(end); if (outNode.getNode() != null) { new ConnectionImpl( outNode.getNode(), outNode.getType(), end, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
split.setMetaData("height", 4); split.setType(Split.TYPE_XOR); Connection connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE); Constraint constraint = new ConstraintImpl(); constraint.setName("constraint1 ><&&"); constraint.setConstraint("constraint-text1"); split.setConstraint(connection, constraint); connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, ruleSetNode, Node.CONNECTION_DEFAULT_TYPE); constraint = new ConstraintImpl(); constraint.setName("constraint2"); new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, split, Node.CONNECTION_DEFAULT_TYPE); new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE); new ConnectionImpl(ruleSetNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE); new ConnectionImpl(eventNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE); connection = new ConnectionImpl(join, Node.CONNECTION_DEFAULT_TYPE, milestone, Node.CONNECTION_DEFAULT_TYPE); connection.setMetaData("bendpoints", "[10,10;20,20]"); connection = new ConnectionImpl(milestone, Node.CONNECTION_DEFAULT_TYPE, subProcess, Node.CONNECTION_DEFAULT_TYPE); connection.setMetaData("bendpoints", "[10,10]"); connection = new ConnectionImpl(subProcess, Node.CONNECTION_DEFAULT_TYPE, workItemNode, Node.CONNECTION_DEFAULT_TYPE); connection.setMetaData("bendpoints", "[]"); connection = new ConnectionImpl(workItemNode, Node.CONNECTION_DEFAULT_TYPE, humanTaskNode, Node.CONNECTION_DEFAULT_TYPE);
@Test public void testCompositeNodeNoStart() throws Exception { RuleFlowProcess process = new RuleFlowProcess(); process.setId("org.drools.core.process.process"); process.setName("Process"); StartNode startNode = new StartNode(); startNode.setName("Start"); startNode.setId(1); process.addNode(startNode); EndNode endNode = new EndNode(); endNode.setName("EndNode"); endNode.setId(2); process.addNode(endNode); CompositeNode compositeNode = new CompositeNode(); compositeNode.setId(3); process.addNode(compositeNode); new org.jbpm.workflow.core.impl.ConnectionImpl( startNode, Node.CONNECTION_DEFAULT_TYPE, Node.CONNECTION_DEFAULT_TYPE ); new org.jbpm.workflow.core.impl.ConnectionImpl( compositeNode, Node.CONNECTION_DEFAULT_TYPE,
NodeInstanceFactoryRegistry.getInstance(ksession.getEnvironment()).register( mockNode.getClass(), mockNodeFactory ); RuleFlowProcess process = new RuleFlowProcess(); StartNode startNode = new StartNode(); startNode.setId( 1 ); startNode.setName( "start node" ); new ConnectionImpl( startNode, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, mockNode, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); process.addNode( startNode ); process.addNode( mockNode );
private void connect(Node sourceNode, Node targetNode) { new ConnectionImpl (sourceNode, Node.CONNECTION_DEFAULT_TYPE, targetNode, Node.CONNECTION_DEFAULT_TYPE); }
Node endNode = new EndNode(); endNode.setId( 1 ); endNode.setName( "end node" ); new ConnectionImpl(mockNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
public void removeIncomingConnection(String type, Connection connection) { super.removeIncomingConnection(type, connection); CompositeNode.NodeAndType nodeAndType = internalGetLinkedIncomingNode(type); if (nodeAndType != null) { for (Connection inConnection: nodeAndType.getNode().getIncomingConnections(nodeAndType.getType())) { if (((CompositeNodeStart) inConnection.getFrom()).getInNodeId() == connection.getFrom().getId()) { Node compositeNodeStart = inConnection.getFrom(); ((ConnectionImpl) inConnection).terminate(); internalRemoveNode(compositeNodeStart); return; } } throw new IllegalArgumentException( "Could not find internal incoming connection for node"); } }
private boolean processConnectionInfo(ConnectionInfo connectionInfo, Node[] nodes) { for (Node node: nodes) { for (List<Connection> connections: node.getOutgoingConnections().values()) { for (Connection connection: connections) { String id = (String) connection.getMetaData().get("UniqueId"); if (id != null && id.equals(connectionInfo.getElementRef())) { ((ConnectionImpl) connection).setMetaData( "bendpoints", connectionInfo.getBendpoints()); return true; } } } if (node instanceof NodeContainer) { boolean found = processConnectionInfo(connectionInfo, ((NodeContainer) node).getNodes()); if (found) { return true; } } } return false; }
this.to = to; this.toType = toType; connect();
RuleFlowProcess process = new RuleFlowProcess(); process.setId("org.drools.core.process.event"); process.setName("Event Process"); StartNode startNode = new StartNode(); startNode.setName("Start"); startNode.setId(1); process.addNode(startNode); EndNode endNode = new EndNode(); endNode.setName("End"); endNode.setId(3); process.addNode(endNode); new ConnectionImpl( startNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE
private void connect(Node sourceNode, Node targetNode) { new ConnectionImpl( sourceNode, Node.CONNECTION_DEFAULT_TYPE, targetNode, Node.CONNECTION_DEFAULT_TYPE ); }
if (connection.getFrom() instanceof CompositeNodeStart) { removeNode(connection.getFrom()); ((ConnectionImpl) connection).terminate(); internalAddNode(start); if (inNode.getNode() != null) { new ConnectionImpl( start, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, inNode.getNode(), inNode.getType());
public void removeOutgoingConnection(String type, Connection connection) { super.removeOutgoingConnection(type, connection); CompositeNode.NodeAndType nodeAndType = internalGetLinkedOutgoingNode(type); if (nodeAndType != null) { for (Connection outConnection: nodeAndType.getNode().getOutgoingConnections(nodeAndType.getType())) { if (((CompositeNodeEnd) outConnection.getTo()).getOutNodeId() == connection.getTo().getId()) { Node compositeNodeEnd = outConnection.getTo(); ((ConnectionImpl) outConnection).terminate(); internalRemoveNode(compositeNodeEnd); return; } } throw new IllegalArgumentException( "Could not find internal outgoing connection for node"); } }
private boolean processConnectionInfo(ConnectionInfo connectionInfo, Node[] nodes) { for (Node node: nodes) { for (List<Connection> connections: node.getOutgoingConnections().values()) { for (Connection connection: connections) { String id = (String) connection.getMetaData().get("UniqueId"); if (id != null && id.equals(connectionInfo.getElementRef())) { ((ConnectionImpl) connection).setMetaData( "bendpoints", connectionInfo.getBendpoints()); return true; } } } if (node instanceof NodeContainer) { boolean found = processConnectionInfo(connectionInfo, ((NodeContainer) node).getNodes()); if (found) { return true; } } } return false; }
this.to = to; this.toType = toType; connect();
new ConnectionImpl( start, Node.CONNECTION_DEFAULT_TYPE, timerNode, Node.CONNECTION_DEFAULT_TYPE ); ActionNode actionNode = new ActionNode(); actionNode.setId( 3 ); actionNode.setName( "Action" ); DroolsConsequenceAction action = new DroolsConsequenceAction(); action.setDialect( "java" ); action.setConsequence( "try { Thread.sleep(1000); } catch (Throwable t) {} System.out.println(\"Executed action\");" ); new ConnectionImpl( timerNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE ); EndNode end = new EndNode(); end.setId( 6 ); end.setName( "End" ); process.addNode( end ); new ConnectionImpl( actionNode, Node.CONNECTION_DEFAULT_TYPE, end,
@Test public void testAsynchronousSubProcess() { RuleFlowProcess process = new RuleFlowProcess(); process.setId("org.drools.core.process.process"); process.setName("Process"); StartNode startNode = new StartNode(); startNode.setName("Start"); startNode.setId(1); process.addNode(startNode); EndNode endNode = new EndNode(); endNode.setName("EndNode"); endNode.setId(2); new ConnectionImpl( startNode, Node.CONNECTION_DEFAULT_TYPE, subProcessNode, Node.CONNECTION_DEFAULT_TYPE ); new ConnectionImpl( subProcessNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE new ConnectionImpl( startNode, Node.CONNECTION_DEFAULT_TYPE, workItemNode, Node.CONNECTION_DEFAULT_TYPE ); new ConnectionImpl( workItemNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE