public Collection<org.kie.api.runtime.process.NodeInstance> getNodeInstances() { return new ArrayList<org.kie.api.runtime.process.NodeInstance>(getNodeInstances(false)); }
public void setState(final int state) { this.state = state; if (state == ProcessInstance.STATE_ABORTED) { cancel(); } }
@Override public void signalEvent(String type, Object event) { List<NodeInstance> currentView = new ArrayList<NodeInstance>(this.nodeInstances); super.signalEvent(type, event); for (Node node: getCompositeNode().internalGetNodes()) { if (node instanceof EventNodeInterface) { if (((EventNodeInterface) node).acceptsEvent(type, event)) { if (node instanceof EventNode && ((EventNode) node).getFrom() == null) { EventNodeInstanceInterface eventNodeInstance = (EventNodeInstanceInterface) getNodeInstance(node); eventNodeInstance.signalEvent(type, event); } else if( node instanceof EventSubProcessNode ) { EventNodeInstanceInterface eventNodeInstance = (EventNodeInstanceInterface) getNodeInstance(node); eventNodeInstance.signalEvent(type, event); } else { List<NodeInstance> nodeInstances = getNodeInstances(node.getId(), currentView); if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nodeInstance : nodeInstances) { ((EventNodeInstanceInterface) nodeInstance) .signalEvent(type, event); } } } } } } }
public void triggerCompleted(String outType) { boolean cancelRemainingInstances = getCompositeNode().isCancelRemainingInstances(); ((org.jbpm.workflow.instance.NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(getLevel()); triggerCompleted(outType, cancelRemainingInstances); if (cancelRemainingInstances) { while (!nodeInstances.isEmpty()) { NodeInstance nodeInstance = (NodeInstance) nodeInstances.get(0); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).cancel(); } } }
public String getUniqueId() { String result = "" + getId(); NodeInstanceContainer parent = getNodeInstanceContainer(); while (parent instanceof CompositeNodeInstance) { CompositeNodeInstance nodeInstance = (CompositeNodeInstance) parent; result = nodeInstance.getId() + ":" + result; parent = nodeInstance.getNodeInstanceContainer(); } return result; }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || nodeInstance instanceof EventSubProcessNodeInstance ) { if (getCompositeNode().isAutoComplete()) { if (nodeInstances.isEmpty()) { triggerCompleted( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
public void internalTrigger(final org.kie.api.runtime.process.NodeInstance from, String type) { super.internalTrigger(from, type); if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; CompositeNode.NodeAndType nodeAndType = getCompositeNode().internalGetLinkedIncomingNode(type); if (nodeAndType != null) { List<Connection> connections = nodeAndType.getNode().getIncomingConnections(nodeAndType.getType()); (from == null || ((CompositeNode.CompositeNodeStart) connection.getFrom()).getInNode().getId() == from.getNodeId())) { NodeInstance nodeInstance = getNodeInstance(connection.getFrom()); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, nodeAndType.getType()); return; for (Node node: getCompositeNode().getNodes()) { if (node instanceof StartNode) { StartNode startNode = (StartNode) node; if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) { NodeInstance nodeInstance = getNodeInstance(startNode); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance) .trigger(null, null); if (isLinkedIncomingNodeRequired()) { throw new IllegalArgumentException( "Could not find start for composite node: " + type);
private void registerExternalEventNodeListeners() { for (Node node: getCompositeNode().getNodes()) { if (node instanceof EventNode) { if ("external".equals(((EventNode) node).getScope())) { getProcessInstance().addEventListener( ((EventNode) node).getType(), EMPTY_EVENT_LISTENER, true); } } else if (node instanceof EventSubProcessNode) { List<String> events = ((EventSubProcessNode) node).getEvents(); for (String type : events) { getProcessInstance().addEventListener(type, EMPTY_EVENT_LISTENER, true); } } } }
public NodeInstance getFirstNodeInstance(final long nodeId) { for ( final Iterator<NodeInstance> iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) { final NodeInstance nodeInstance = iterator.next(); if ( nodeInstance.getNodeId() == nodeId && nodeInstance.getLevel() == getCurrentLevel()) { return nodeInstance; } } return null; }
protected CompositeNode getCompositeNode() { return (CompositeNode) getNode(); }
public NodeContainer getNodeContainer() { return getCompositeNode(); }
public void internalTrigger(final org.kie.api.runtime.process.NodeInstance from, String type) { super.internalTrigger(from, type); if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; CompositeNode.NodeAndType nodeAndType = getCompositeNode().internalGetLinkedIncomingNode(type); if (nodeAndType != null) { List<Connection> connections = nodeAndType.getNode().getIncomingConnections(nodeAndType.getType()); (from == null || ((CompositeNode.CompositeNodeStart) connection.getFrom()).getInNode().getId() == from.getNodeId())) { NodeInstance nodeInstance = getNodeInstance(connection.getFrom()); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, nodeAndType.getType()); return; for (Node node: getCompositeNode().getNodes()) { if (node instanceof StartNode) { StartNode startNode = (StartNode) node; if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) { NodeInstance nodeInstance = getNodeInstance(startNode); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance) .trigger(null, null); if (isLinkedIncomingNodeRequired()) { throw new IllegalArgumentException( "Could not find start for composite node: " + type);
public void triggerCompleted(String outType) { boolean cancelRemainingInstances = getCompositeNode().isCancelRemainingInstances(); ((org.jbpm.workflow.instance.NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(getLevel()); triggerCompleted(outType, cancelRemainingInstances); if (cancelRemainingInstances) { while (!nodeInstances.isEmpty()) { NodeInstance nodeInstance = (NodeInstance) nodeInstances.get(0); ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).cancel(); } } }
public String getUniqueId() { String result = "" + getId(); NodeInstanceContainer parent = getNodeInstanceContainer(); while (parent instanceof CompositeNodeInstance) { CompositeNodeInstance nodeInstance = (CompositeNodeInstance) parent; result = nodeInstance.getId() + ":" + result; parent = nodeInstance.getNodeInstanceContainer(); } return result; }
private void registerExternalEventNodeListeners() { for (Node node: getCompositeNode().getNodes()) { if (node instanceof EventNode) { if ("external".equals(((EventNode) node).getScope())) { getProcessInstance().addEventListener( ((EventNode) node).getType(), EMPTY_EVENT_LISTENER, true); } } else if (node instanceof EventSubProcessNode) { List<String> events = ((EventSubProcessNode) node).getEvents(); for (String type : events) { getProcessInstance().addEventListener(type, EMPTY_EVENT_LISTENER, true); } } } }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || nodeInstance instanceof EventSubProcessNodeInstance ) { if (getCompositeNode().isAutoComplete()) { if (nodeInstances.isEmpty()) { triggerCompleted( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
public NodeInstance getFirstNodeInstance(final long nodeId) { for ( final Iterator<NodeInstance> iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) { final NodeInstance nodeInstance = iterator.next(); if ( nodeInstance.getNodeId() == nodeId && nodeInstance.getLevel() == getCurrentLevel()) { return nodeInstance; } } return null; }
protected CompositeNode getCompositeNode() { return (CompositeNode) getNode(); }
public NodeContainer getNodeContainer() { return getCompositeNode(); }
public NodeInstance getNodeInstance(long nodeInstanceId, boolean recursive) { for (NodeInstance nodeInstance: getNodeInstances(recursive)) { if (nodeInstance.getId() == nodeInstanceId) { return nodeInstance; } } return null; }