protected boolean useAsync(final Node node) { if (!(node instanceof EventSubProcessNode) && (node instanceof ActionNode || node instanceof StateBasedNode || node instanceof EndNode)) { boolean asyncMode = Boolean.parseBoolean((String)node.getMetaData().get("customAsync")); if (asyncMode) { return asyncMode; } return Boolean.parseBoolean((String)getProcessInstance().getKnowledgeRuntime().getEnvironment().get("AsyncMode")); } return false; }
private void addActivationListener() { getProcessInstance().getKnowledgeRuntime().addEventListener(this); getProcessInstance().addEventListener(getActivationEventType(), this, true); }
public void afterProcessCompleted(ProcessCompletedEvent event) { ObjectMarshallingStrategy[] strategies = (ObjectMarshallingStrategy[]) event.getKieRuntime().getEnvironment().get(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES); (VariableScopeInstance) ((WorkflowProcessInstance)event.getProcessInstance()).getContextInstance(VariableScope.VARIABLE_SCOPE);
public void removeEventListeners() { super.removeEventListeners(); getProcessInstance().getKnowledgeRuntime().removeEventListener(this); getProcessInstance().removeEventListener(getActivationEventType(), this, true); }
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); // if node instance was cancelled, abort if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; } if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "A MilestoneNode only accepts default incoming connections!"); } String rule = "RuleFlow-Milestone-" + getProcessInstance().getProcessId() + "-" + getMilestoneNode().getUniqueId(); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId()); if (isActive) { triggerCompleted(); } else { addActivationListener(); } }
protected boolean actAsWaitState() { Object asWaitState = getProcessInstance().getKnowledgeRuntime().getEnvironment().get(ACT_AS_WAIT_STATE_PROPERTY); if (asWaitState != null) { return Boolean.parseBoolean(asWaitState.toString()); } return false; }
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; addWorkItemListener(); String deploymentId = (String) getProcessInstance().getKnowledgeRuntime().getEnvironment().get(EnvironmentName.DEPLOYMENT_ID); ((WorkItem) workItem).setDeploymentId(deploymentId); ((WorkItem) workItem).setNodeInstanceId(this.getId()); if (isInversionOfControl()) { ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime() .update(((ProcessInstance) getProcessInstance()).getKnowledgeRuntime().getFactHandle(this), this); } else { try { (org.drools.core.process.instance.WorkItem) workItem); } catch (WorkItemHandlerNotFoundException wihnfe) { getProcessInstance().setState(ProcessInstance.STATE_ABORTED); throw wihnfe; } catch (ProcessWorkItemHandlerException handlerException) {
if ((getNodeInstanceContainer().getNodeInstance(getId()) == null) || (((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer()).getState() != ProcessInstance.STATE_ACTIVE)) { return; .removeNodeInstance(this); if (((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer()).getState() != ProcessInstance.STATE_ACTIVE) { return; throw new IllegalArgumentException( "Uncontrolled flow node could not find at least one valid outgoing connection " + getNode().getName() ); connections = node.getOutgoingConnections(type); hidden = true; InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime); .nodeInstanceCompleted(this, type); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeLeft(this, kruntime);
public final void trigger(NodeInstance from, String type) { boolean hidden = false; if (getNode().getMetaData().get("hidden") != null) { hidden = true; ((org.jbpm.workflow.instance.NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(level); Collection<Connection> incoming = getNode().getIncomingConnections(type); for (Connection conn : incoming) { if (conn.getFrom().getId() == from.getNodeId()) { this.metaData.put("IncomingConnection", conn.getMetaData().get("UniqueId")); break; InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeTriggered(this, kruntime); ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeTriggered(this, kruntime);
final WorkItemImpl workItem = new WorkItemImpl(); workItem.setState(WorkItem.ACTIVE); workItem.setProcessInstanceId(processInstance.getId()); workItem.setDeploymentId((String) ksession.getEnvironment().get(EnvironmentName.DEPLOYMENT_ID)); workItem.setName(workItemName); workItem.setParameters(parameters); while (matcher.find()) { String paramName = matcher.group(1); variableValue = processInstance.getVariable(paramName); if (variableValue == null) { try {
protected void triggerNodeInstance(org.jbpm.workflow.instance.NodeInstance nodeInstance, String type, boolean fireEvents) { boolean hidden = false; if (getNode().getMetaData().get("hidden") != null) { hidden = true; } InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden && fireEvents) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime); } // trigger next node nodeInstance.trigger(this, type); Collection<Connection> outgoing = getNode().getOutgoingConnections(type); for (Connection conn : outgoing) { if (conn.getTo().getId() == nodeInstance.getNodeId()) { this.metaData.put("OutgoingConnection", conn.getMetaData().get("UniqueId")); break; } } if (!hidden && fireEvents) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeLeft(this, kruntime); } }
public void cancel() { boolean hidden = false; Node node = getNode(); if (node != null && node.getMetaData().get("hidden") != null) { hidden = true; } if (!hidden) { InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime); } nodeInstanceContainer.removeNodeInstance(this); if (!hidden) { InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeLeft(this, kruntime); } }
public void internalTrigger(NodeInstance from, String type) { super.internalTrigger(from, type); if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; timerInstances = new ArrayList<Long>(timers.size()); TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); for (Timer timer: timers.keySet()) { TimerInstance timerInstance = createTimerInstance(timer); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", name, getProcessInstance().getId()); if (isActive) { getProcessInstance().getKnowledgeRuntime().signalEvent(name, null); } else { addActivationListener(); ((WorkflowProcessInstanceImpl) getProcessInstance()).addActivatingNodeId((String) getNode().getMetaData().get("UniqueId"));
protected TimerInstance createTimerInstance(Timer timer) { TimerInstance timerInstance = new TimerInstance(); KieRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (kruntime != null && kruntime.getEnvironment().get("jbpm.business.calendar") != null){ BusinessCalendar businessCalendar = (BusinessCalendar) kruntime.getEnvironment().get("jbpm.business.calendar"); String delay = null; switch (timer.getTimeType()) {
((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this); if ( selected == null ) { for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) { ((NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(1); ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this); outgoing = split.getDefaultOutgoingConnections(); boolean found = false; if (getProcessInstance().getState() != ProcessInstance.STATE_ACTIVE) { return; if (getProcessInstance().getState() != ProcessInstance.STATE_ACTIVE) { return; if (getNode().getMetaData().get("hidden") != null) { hidden = true; InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime); ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeLeft(this, kruntime);
if (getNode().getMetaData().get("hidden") != null) { hidden = true; InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime); ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this); if (getEndNode().isTerminate()) { if (getNodeInstanceContainer() instanceof CompositeNodeInstance) { if (getEndNode().getScope() == EndNode.PROCESS_SCOPE) { getProcessInstance().setState( ProcessInstance.STATE_COMPLETED ); } else { while (!getNodeInstanceContainer().getNodeInstances().isEmpty()) { ((org.jbpm.workflow.instance.NodeInstance) getNodeInstanceContainer().getNodeInstances().iterator().next()).cancel(); ((NodeInstanceContainer) getNodeInstanceContainer()).nodeInstanceCompleted(this, null); ((NodeInstanceContainer) getNodeInstanceContainer()).setState( ProcessInstance.STATE_COMPLETED ); ((InternalProcessRuntime) kruntime.getProcessRuntime()) .getProcessEventSupport().fireAfterNodeLeft(this, kruntime);
DefaultSignalManagerFactory.class.getName()); BusinessCalendar bc = (BusinessCalendar) kieSession.getEnvironment().get("jbpm.business.calendar"); assertNotNull(bc); assertTrue(bc instanceof TestBusinessCalendar); assertNotNull(pi); String varX = (String) ((WorkflowProcessInstance)pi).getVariable("x"); assertEquals(TestMarshallingStrategy.ALWAYS_RESPOND_WITH, varX);
nodeInstance.setNodeId(node.getId()); nodeInstance.setNodeInstanceContainer(this); nodeInstance.setProcessInstance(getProcessInstance()); } else if (node instanceof CompositeNode.CompositeNodeEnd) { CompositeNodeEndInstance nodeInstance = new CompositeNodeEndInstance(); nodeInstance.setNodeId(node.getId()); nodeInstance.setNodeInstanceContainer(this); nodeInstance.setProcessInstance(getProcessInstance()); NodeInstanceFactory conf = NodeInstanceFactoryRegistry.getInstance(getProcessInstance().getKnowledgeRuntime().getEnvironment()).getProcessNodeInstanceFactory(actualNode); if (conf == null) { throw new IllegalArgumentException("Illegal node type: " + node.getClass());
private void cancelSlaTimer() { if (this.slaTimerId > -1) { TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); timerManager.cancelTimer(this.slaTimerId); logger.debug("SLA Timer {} has been canceled", this.slaTimerId); } }
public void internalTrigger(NodeInstance from, String type) { super.internalTrigger(from, type); if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; Constraint constraint = stateNode.getConstraint(connection); if (constraint != null && constraint.getPriority() < priority) { String rule = "RuleFlowStateNode-" + getProcessInstance().getProcessId() + "-" + getStateNode().getUniqueId() + "-" + connection.getTo().getId() + "-" + connection.getToType(); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId()); if (isActive) { selected = connection; ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this); triggerConnection(selected); } else {