public Collection<org.kie.api.runtime.process.NodeInstance> getNodeInstances() { return new ArrayList<org.kie.api.runtime.process.NodeInstance>(getNodeInstances(false)); }
public NodeInstance getNodeInstance(long nodeInstanceId, boolean recursive) { for (NodeInstance nodeInstance: getNodeInstances(recursive)) { if (nodeInstance.getId() == nodeInstanceId) { return nodeInstance; } } return null; }
private NodeInstance findNodeByUniqueId(Collection<NodeInstance> nodeInstances, String uniqueId) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); if (uniqueId.equals(nodeUniqueId)) { return nInstance; } if (nInstance instanceof CompositeNodeInstance) { NodeInstance nodeInstance = findNodeByUniqueId(((CompositeNodeInstance) nInstance).getNodeInstances(), uniqueId); if (nodeInstance != null) { return nodeInstance; } } } } return null; }
private boolean isAttachedToNodeActive(Collection<NodeInstance> nodeInstances, String attachedTo, String type, Object event) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); boolean isActivating = ((WorkflowProcessInstanceImpl)nInstance.getProcessInstance()).getActivatingNodeIds().contains(nodeUniqueId); if (attachedTo.equals(nodeUniqueId) && !isActivating) { // in case this is timer event make sure it corresponds to the proper node instance if (type.startsWith("Timer-")) { if (Long.valueOf(nInstance.getId()).equals(event)) { return true; } } else { return true; } } if (nInstance instanceof CompositeNodeInstance) { boolean hasActive = isAttachedToNodeActive(((CompositeNodeInstance) nInstance).getNodeInstances(), attachedTo, type, event); if (hasActive) { return true; } } } } return false; }
@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 Collection<org.kie.api.runtime.process.NodeInstance> getNodeInstances() { return new ArrayList<org.kie.api.runtime.process.NodeInstance>(getNodeInstances(false)); }
public NodeInstance getNodeInstance(long nodeInstanceId, boolean recursive) { for (NodeInstance nodeInstance: getNodeInstances(recursive)) { if (nodeInstance.getId() == nodeInstanceId) { return nodeInstance; } } return null; }
protected static Collection<NodeInstance> collectActiveNodeInstances(Collection<NodeInstance> activeNodes) { Collection<NodeInstance> activeNodesComposite = new ArrayList<NodeInstance>(); for (NodeInstance nodeInstance : activeNodes) { if (nodeInstance instanceof CompositeNodeInstance) { Collection<NodeInstance> currentNodeInstances = ((CompositeNodeInstance) nodeInstance).getNodeInstances(); activeNodesComposite.addAll(currentNodeInstances); // recursively check current nodes activeNodesComposite.addAll(collectActiveNodeInstances(currentNodeInstances)); } } return activeNodesComposite; }
private NodeInstance findNodeByUniqueId(Collection<NodeInstance> nodeInstances, String uniqueId) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); if (uniqueId.equals(nodeUniqueId)) { return nInstance; } if (nInstance instanceof CompositeNodeInstance) { NodeInstance nodeInstance = findNodeByUniqueId(((CompositeNodeInstance) nInstance).getNodeInstances(), uniqueId); if (nodeInstance != null) { return nodeInstance; } } } } return null; }
public static Collection<String> collectActiveSignals(Collection<NodeInstance> activeNodes) { Collection<String> activeNodesComposite = new ArrayList<String>(); for (NodeInstance nodeInstance : activeNodes) { if (nodeInstance instanceof EventNodeInstance) { String type = ((EventNodeInstance) nodeInstance).getEventNode().getType(); if (type != null && !type.startsWith("Message-")) { activeNodesComposite.add(type); } } if (nodeInstance instanceof CompositeNodeInstance) { Collection<NodeInstance> currentNodeInstances = ((CompositeNodeInstance) nodeInstance).getNodeInstances(); // recursively check current nodes activeNodesComposite.addAll(collectActiveSignals(currentNodeInstances)); } } return activeNodesComposite; }
private boolean isAttachedToNodeActive(Collection<NodeInstance> nodeInstances, String attachedTo, String type, Object event) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); boolean isActivating = ((WorkflowProcessInstanceImpl)nInstance.getProcessInstance()).getActivatingNodeIds().contains(nodeUniqueId); if (attachedTo.equals(nodeUniqueId) && !isActivating) { // in case this is timer event make sure it corresponds to the proper node instance if (type.startsWith("Timer-")) { if (Long.valueOf(nInstance.getId()).equals(event)) { return true; } } else { return true; } } if (nInstance instanceof CompositeNodeInstance) { boolean hasActive = isAttachedToNodeActive(((CompositeNodeInstance) nInstance).getNodeInstances(), attachedTo, type, event); if (hasActive) { return true; } } } } return false; }
@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); } } } } } } }