protected void cancelProcess(long processIdToCancel) { ProcessInstance pi = jbpmContext.getGraphSession().loadProcessInstance(processIdToCancel); log.info("cancel process instance " + pi.getId()); // Record a standardized variable that we can use to determine that this // process has been 'canceled' and not just ended. pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime()); try { // End the process instance and any open tokens // TODO: Think about maybe canceling sub processes? cancelToken(pi.getRootToken()); pi.end(); log.info("finished process cancellation"); } catch (RuntimeException ex) { log.error("problems while cancel process", ex); throw ex; } }
/** * Signal the given transition for the current process instance. * * @param transitionName the jBPM transition name */ public void transition(String transitionName) { ProcessInstance process = org.jboss.seam.bpm.ProcessInstance.instance(); process.signal(transitionName); if ( process.hasEnded() ) { Events.instance().raiseEvent("org.jboss.seam.endProcess." + process.getProcessDefinition().getName()); } }
/** * convenience method for ending a composite log. Make sure you put this in a finally block. */ public void endCompositeLog() { LoggingInstance loggingInstance = processInstance.getLoggingInstance(); if (loggingInstance != null) loggingInstance.endCompositeLog(); }
public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof ProcessInstance)) return false; ProcessInstance other = (ProcessInstance) o; if (id != 0 && id == other.getId()) return true; return key != null && key.equals(other.getKey()) && processDefinition.equals(other.getProcessDefinition()); }
public void checkImplicitTermination() { if (isTerminationImplicit && node.hasNoLeavingTransitions()) { end(); if (processInstance.isTerminatedImplicitly()) processInstance.end(); } }
private void flushToProcessInstance(org.jbpm.graph.exe.ProcessInstance processInstance) { log.debug( "flushing to process instance: " + processInstance.getId() ); ContextInstance contextInstance = processInstance.getContextInstance(); for ( Map.Entry<String, Object> entry: additions.entrySet() ) { contextInstance.setVariable( entry.getKey(), entry.getValue() ); } for ( String name: removals ) { contextInstance.deleteVariable(name); } }
public Object execute(JbpmContext jbpmContext) { if (previousProcessInstance != null) { if (variables != null && variables.size() > 0) previousProcessInstance.getContextInstance().addVariables(variables); if (transitionName == null) { previousProcessInstance.signal(); } else { previousProcessInstance.signal(transitionName); } return previousProcessInstance.getRootToken(); } else { Token token = getToken(jbpmContext); if (expectedStateName != null && !expectedStateName.equals(token.getNode().getName())) throw new JbpmException("token is not in expected state '" + expectedStateName + "' but in '" + token.getNode().getName() + "'"); if (variables != null && variables.size() > 0) token.getProcessInstance().getContextInstance().addVariables(variables); if (transitionName == null) { token.signal(); } else { token.signal(transitionName); } return token; } }
ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition( processDefinitionId); processInstance = new ProcessInstance(processDefinition); processInstance.setKey(key); result = processInstance.getTaskMgmtInstance().createStartTaskInstance(); ContextInstance contextInstance = processInstance.getContextInstance(); Iterator iter = variables.keySet().iterator(); while (iter.hasNext()) {
private ContextInstance getContextInstance() { org.jbpm.graph.exe.ProcessInstance processInstance = getProcessInstance(); return processInstance==null ? null : processInstance.getContextInstance(); }
protected void raiseEndEventIfNecessary() { if ( processInstance.hasEnded() ) { Events.instance().raiseEvent( "org.jboss.seam.endPageflow." + processInstance.getProcessDefinition().getName() ); Events.instance().raiseEvent( "org.jboss.seam.endPageflow"); } }
private Token getRootToken() { return processInstance.getRootToken(); }
public ProcessInstance execute(ProcessInstance pi) { ProcessDefinition oldDef = pi.getProcessDefinition(); ProcessDefinition newDef = findNewProcessDefinition(oldDef.getName()); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("migrating " + pi + " from version " + oldDef.getVersion() + " to " + newDef.getVersion()); } pi.setProcessDefinition(newDef); changeTokenVersion(pi.getRootToken()); if (debug) log.debug(pi + " migrated to version " + newDef.getVersion()); return pi; }
final Token token = ((Token) value); token.end(); for (TaskInstance task : (Collection<TaskInstance>) token.getProcessInstance().getTaskMgmtInstance().getUnfinishedTasks(token)) { task.cancel(); } else if (value instanceof ProcessInstance) { final ProcessInstance processInstance = ((ProcessInstance) value); processInstance.end(); for (TaskInstance task : (Collection<TaskInstance>) processInstance.getTaskMgmtInstance().getUnfinishedTasks(processInstance.getRootToken())) { task.setSignalling(false); task.cancel();
/** * instructs the main path of execution to continue by taking the specified transition on the * current node. * * @throws IllegalStateException if the token is not active. */ public void signal(Transition transition) { if (hasEnded()) throw new IllegalStateException("process instance has ended"); rootToken.signal(transition); }
@Override public String toString() { String name = processInstance==null ? "null" : processInstance.getProcessDefinition().getName(); return "Pageflow(" + name + ")"; }
private void afterCreateProcess(String processDefinitionName, ProcessInstance process, boolean shouldSignalProcess) { setProcessId( process.getId() ); // need to set process variables before the signal Contexts.getBusinessProcessContext().flush(); if (shouldSignalProcess) { process.signal(); } Events.instance().raiseEvent("org.jboss.seam.createProcess." + processDefinitionName); }
public String toString() { return "sub-process["+subProcessInstance.getId()+"]"; }
subProcessInstance.end(); TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance(); if (taskMgmtInstance != null) taskMgmtInstance.removeSignalling(this);
public Object execute(JbpmContext jbpmContext) throws Exception { Object object = super.execute(jbpmContext); if (object instanceof ProcessInstance) { ProcessInstance processInstance = (ProcessInstance) object; if (startTransitionName == null || startTransitionName.length() == 0) processInstance.signal(); else processInstance.signal(startTransitionName); } return object; }
private void resumeTaskInstances() { TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance(); if (taskMgmtInstance != null) taskMgmtInstance.resume(this); }