}
if (connections == null || connections.isEmpty()) {
((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer())
.nodeInstanceCompleted(this, type);
} else {
ExclusiveGroupInstance groupInstance = new ExclusiveGroupInstance();
org.drools.runtime.process.NodeInstanceContainer parent = getNodeInstanceContainer();
if (parent instanceof ContextInstanceContainer) {
((ContextInstanceContainer) parent).addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, groupInstance);
} else {
throw new IllegalArgumentException(
"An Exclusive AND is only possible if the parent is a context instance container");
}
Map<NodeInstance, String> nodeInstances = new HashMap<NodeInstance, String>();
for (Connection connection: connections) {
nodeInstances.put(
((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer())
.getNodeInstance(connection.getTo()),
connection.getToType());
}
for (NodeInstance nodeInstance: nodeInstances.keySet()) {
groupInstance.addNodeInstance(nodeInstance);
}
for (Map.Entry<NodeInstance, String> entry: nodeInstances.entrySet()) {
// stop if this process instance has been aborted / completed
if (getProcessInstance().getState() != ProcessInstance.STATE_ACTIVE) {
return;