public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { Element element = parser.endElementBuilder(); StateBasedNode parent = (StateBasedNode) parser.getParent(); String id = element.getAttribute("id"); emptyAttributeCheck( localName, "id", id, parser ); String delay = element.getAttribute("delay"); String period = element.getAttribute("period"); Timer timer = new Timer(); timer.setId(new Long(id)); if (delay != null && delay.length() != 0 ) { timer.setDelay(delay); } if (period != null && period.length() != 0 ) { timer.setPeriod(period); } org.w3c.dom.Node xmlNode = element.getFirstChild(); DroolsAction action = null; if (xmlNode instanceof Element) { Element actionXml = (Element) xmlNode; action = AbstractNodeHandler.extractAction(actionXml); } parent.addTimer(timer, action); return null; }
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) { super.build(process, processDescr, context, node); Map<Timer, DroolsAction> timers = ((StateBasedNode) node).getTimers(); if (timers != null) { for (DroolsAction action: timers.values()) { buildAction(action, context, (NodeImpl) node ); } } }
@Override public Context getContext(String contextId) { Context context = getDefaultContext(contextId); if (context != null) { return context; } return super.getContext(contextId); }
Map<Timer, DroolsAction> timers = getEventBasedNode().getTimers(); if (timers != null) { addTimerListener(); if (getEventBasedNode().getBoundaryEvents() != null) { for (String name : getEventBasedNode().getBoundaryEvents()) {
public void validateAddIncomingConnection(final String type, final Connection connection) { super.validateAddIncomingConnection(type, connection); if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); } }
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"); } }
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"); } }
public void addIncomingConnection(String type, Connection connection) { if (connection.getFrom().getNodeContainer() == this) { linkOutgoingConnections(connection.getFrom().getId(), connection.getFromType(), org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } else { super.addIncomingConnection(type, connection); CompositeNode.NodeAndType inNode = internalGetLinkedIncomingNode(type); if (inNode != null) { CompositeNodeStart start = new CompositeNodeStart(this, connection.getFrom(), type); internalAddNode(start); NodeImpl node = (NodeImpl) inNode.getNode(); if (node != null) { new ConnectionImpl( start, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, inNode.getNode(), inNode.getType()); } } } }
public void addOutgoingConnection(String type, Connection connection) { if (connection.getTo().getNodeContainer() == this) { linkIncomingConnections( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, connection.getTo().getId(), connection.getToType()); } else { super.addOutgoingConnection(type, connection); CompositeNode.NodeAndType outNode = internalGetLinkedOutgoingNode(type); if (outNode != null) { CompositeNodeEnd end = new CompositeNodeEnd(this, connection.getTo(), type); internalAddNode(end); NodeImpl node = (NodeImpl) outNode.getNode(); if (node != null) { new ConnectionImpl( outNode.getNode(), outNode.getType(), end, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } }
Map<Timer, DroolsAction> timers = getEventBasedNode().getTimers(); if (timers != null) { addTimerListener(); if (getEventBasedNode().getBoundaryEvents() != null) { for (String name : getEventBasedNode().getBoundaryEvents()) {
public void validateAddIncomingConnection(final String type, final Connection connection) { super.validateAddIncomingConnection(type, connection); if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); } }
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"); } }
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"); } }
public void addIncomingConnection(String type, Connection connection) { if (connection.getFrom().getNodeContainer() == this) { linkOutgoingConnections(connection.getFrom().getId(), connection.getFromType(), org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } else { super.addIncomingConnection(type, connection); CompositeNode.NodeAndType inNode = internalGetLinkedIncomingNode(type); if (inNode != null) { CompositeNodeStart start = new CompositeNodeStart(this, connection.getFrom(), type); internalAddNode(start); NodeImpl node = (NodeImpl) inNode.getNode(); if (node != null) { new ConnectionImpl( start, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, inNode.getNode(), inNode.getType()); } } } }
public void addOutgoingConnection(String type, Connection connection) { if (connection.getTo().getNodeContainer() == this) { linkIncomingConnections( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, connection.getTo().getId(), connection.getToType()); } else { super.addOutgoingConnection(type, connection); CompositeNode.NodeAndType outNode = internalGetLinkedOutgoingNode(type); if (outNode != null) { CompositeNodeEnd end = new CompositeNodeEnd(this, connection.getTo(), type); internalAddNode(end); NodeImpl node = (NodeImpl) outNode.getNode(); if (node != null) { new ConnectionImpl( outNode.getNode(), outNode.getType(), end, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } }
timer.setDelay(timeDuration); timer.setTimeType(Timer.TIME_DURATION); compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId() +"\", kcontext.getNodeInstance().getId());")); } else if (timeCycle != null) { compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId() + "\", kcontext.getNodeInstance().getId());")); } else if (timeDate != null) { timer.setDate(timeDate); timer.setTimeType(Timer.TIME_DATE); compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeDate + "-" + node.getId() + "\", kcontext.getNodeInstance().getId());"));
private void triggerTimer(TimerInstance timerInstance) { for (Map.Entry<Timer, DroolsAction> entry: getEventBasedNode().getTimers().entrySet()) { if (entry.getKey().getId() == timerInstance.getTimerId()) { executeAction((Action) entry.getValue().getMetaData("Action")); return; } } }
public void validateAddIncomingConnection(final String type, final Connection connection) { super.validateAddIncomingConnection(type, connection); if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getMetaData().get("UniqueId") + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); } }
@Override public Context getContext(String contextId) { Context context = getDefaultContext(contextId); if (context != null) { return context; } return super.getContext(contextId); }
timer.setDelay(timeDuration); timer.setTimeType(Timer.TIME_DURATION); compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId() + "\", kcontext.getNodeInstance().getId());")); } else if (timeCycle != null) { compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node .getId() + timer.setDate(timeDate); timer.setTimeType(Timer.TIME_DATE); compositeNode.addTimer(timer, new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Timer-" + attachedTo + "-" + timeDate + "-" + node.getId() + "\", kcontext.getNodeInstance().getId());"));