protected void triggerConnection(Connection connection) {
boolean hidden = false;
if (getNode().getMetaData().get("hidden") != null) {
hidden = true;
}
InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime();
if (!hidden) {
((InternalProcessRuntime) kruntime.getProcessRuntime())
.getProcessEventSupport().fireBeforeNodeLeft(this, kruntime);
}
// check for exclusive group first
NodeInstanceContainer parent = getNodeInstanceContainer();
if (parent instanceof ContextInstanceContainer) {
List<ContextInstance> contextInstances = ((ContextInstanceContainer) parent).getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
if (contextInstances != null) {
for (ContextInstance contextInstance: new ArrayList<ContextInstance>(contextInstances)) {
ExclusiveGroupInstance groupInstance = (ExclusiveGroupInstance) contextInstance;
if (groupInstance.containsNodeInstance(this)) {
for (NodeInstance nodeInstance: groupInstance.getNodeInstances()) {
if (nodeInstance != this) {
((org.jbpm.workflow.instance.NodeInstance) nodeInstance).cancel();
}
}
((ContextInstanceContainer) parent).removeContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, contextInstance);
}
}
}
}
// trigger next node
((org.jbpm.workflow.instance.NodeInstance) ((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer())
.getNodeInstance(connection.getTo())).trigger(this, connection.getToType());
if (!hidden) {
((InternalProcessRuntime) kruntime.getProcessRuntime())
.getProcessEventSupport().fireAfterNodeLeft(this, kruntime);
}
}