@Override protected ExecutionImpl newProcessInstance() { XpdlInstance xpdlInstance = new XpdlInstance(this); return xpdlInstance.getRootExecution(); }
/** * @param execution */ public void setExecutionToSignal(final XpdlExecution execution) { this.executionToSignal = execution; if (execution != null) { // executionToSignal is set to null when the subflow is ended. // not setting it to null can create a bug, because the executionTosignal // is removed from the db, but still referenced in the subflow instance. // // When executionToSignal is set to null, // the parent process instance has to be kept. // (to delete the subflow instance with the main instance) this.parentInstance = execution.getXpdlInstance(); this.parentInstance.addChildInstance(this); } }
public void cancel() { // cancel execution this.getRootExecution().cancel(); // record cancel ServiceEnvTool.getRecorder().recordInstanceCancelled( new ProcessInstanceCurrentInfo( this.getPackageDefinitionUUID(), this.getProcessDefinitionUUID(), this.getUUID(), this.getParentInstance() != null ? this.getParentInstance().getUUID() : null, this.getRootExecution().getVariables(), ServiceEnvTool.getUserId()) ); // execute finished instance handler if (this.getParentInstance() == null) { this.finish(); } }
public List<XpdlExecution> getExecOnNode(final String nodeName) { return this.getExecOnNode(this.getRootExecution(), nodeName); }
final XpdlExecution xpdlExecution = (XpdlExecution) execution; final XpdlInstance xpdlInstance = xpdlExecution.getXpdlInstance(); xpdlInstance.setInstanceState(InstanceState.FINISHED); final Recorder recorder = ServiceEnvTool.getRecorder(); final ActivityInstanceCurrentInfo activityInstanceCurrentInfo = new ActivityInstanceCurrentInfo( xpdlInstance.getPackageDefinitionUUID(), xpdlInstance.getProcessDefinitionUUID(), xpdlInstance.getUUID(), xpdlExecution.getCurrentActivityInstanceUUID(), this.getActivityType(), xpdlInstance.getPackageDefinitionUUID(), xpdlInstance.getProcessDefinitionUUID(), xpdlInstance.getUUID(), (xpdlInstance.getParentInstance() != null) ? xpdlInstance.getParentInstance().getUUID() : null, xpdlExecution.getVariables(), ServiceEnvTool.getUserId()) ); final XpdlExecution execToSignal = xpdlInstance.getExecutionToSignal(); if (execToSignal != null) { xpdlInstance.setExecutionToSignal(null); } else { xpdlInstance.finish();
case subFlow: final XpdlInstance childInstance = this.getSubflowXpdlInstance(); childInstance.getRootExecution().abort(); childInstance.setInstanceState(InstanceState.ABORTED); childInstance.setExecutionToSignal(null); final Recorder recorder = ServiceEnvTool.getRecorder(); childInstance.getPackageDefinitionUUID(), childInstance.getProcessDefinitionUUID(), childInstance.getUUID(), childInstance.getParentInstance().getUUID(), childInstance.getRootExecution().getVariables(), ServiceEnvTool.getUserId()) ); this.getXpdlInstance().getPackageDefinitionUUID(), this.getXpdlInstance().getProcessDefinitionUUID(), this.getXpdlInstance().getUUID(), this.getCurrentActivityInstanceUUID(), activity.getActivityType(),
private boolean executeBody(final XpdlExecution xpdlExecution) { if (this.bodyStartAutomatically()) { final ActivityInstanceCurrentInfo activityInstanceCurrentInfo = new ActivityInstanceCurrentInfo( xpdlExecution.getXpdlInstance().getPackageDefinitionUUID(), xpdlExecution.getXpdlInstance().getProcessDefinitionUUID(), xpdlExecution.getXpdlInstance().getUUID(), xpdlExecution.getCurrentActivityInstanceUUID(), this.getActivityType(), this.getActivityId(), xpdlExecution.getIterationId(), xpdlExecution.getActivityInstanceId(), xpdlExecution.getScopeVariables()); ServiceEnvTool.getRecorder().recordBodyStarted(activityInstanceCurrentInfo); } return this.executeBusinessLogic(xpdlExecution); }
@Override public void signal(final ActivityExecution execution, final String signal, final Map<String, Object> parameters) { final XpdlExecution xpdlExecution = (XpdlExecution) execution; final XpdlInstance xpdlInstance = xpdlExecution.getXpdlInstance(); xpdlInstance.setInstanceState(InstanceState.STARTED); final Recorder recorder = ServiceEnvTool.getRecorder(); recorder.recordInstanceStarted(new ProcessInstanceCurrentInfo( xpdlInstance.getPackageDefinitionUUID(), xpdlInstance.getProcessDefinitionUUID(), xpdlInstance.getUUID(), (xpdlInstance.getParentInstance() != null) ? xpdlInstance.getParentInstance().getUUID() : null, xpdlExecution.getVariables(), ServiceEnvTool.getUserId()) ); final ActivityInstanceCurrentInfo activityInstanceCurrentInfo = new ActivityInstanceCurrentInfo( xpdlInstance.getPackageDefinitionUUID(), xpdlInstance.getProcessDefinitionUUID(), xpdlInstance.getUUID(), xpdlExecution.getCurrentActivityInstanceUUID(), this.getActivityType(), this.getActivityId(), xpdlExecution.getIterationId(), xpdlExecution.getActivityInstanceId(), xpdlExecution.getScopeVariables()); recorder.recordEnterActivity(activityInstanceCurrentInfo); recorder.recordBodyStarted(activityInstanceCurrentInfo); recorder.recordBodyEnded(activityInstanceCurrentInfo); executeSplit(execution, false); }
case subFlow: final XpdlInstance childInstance = this.getSubflowXpdlInstance(); childInstance.cancel(); break; default: this.getXpdlInstance().getPackageDefinitionUUID(), this.getXpdlInstance().getProcessDefinitionUUID(), this.getXpdlInstance().getUUID(), this.getCurrentActivityInstanceUUID(), activity.getActivityType(),
public void removeInstance(XpdlInstance instance) { ProcessInstanceUUID instanceUUID = instance.getUUID(); removedInstances.put(instanceUUID, instance); instances.remove(instanceUUID); } public boolean isInstanceRemoved(ProcessInstanceUUID instanceUUID) {
public XpdlExecution getExecutionPointingOnNode( ProcessInstanceUUID instanceUUID, String nodeName, String iterationId, String activityInstanceId) { Misc.checkArgsNotNull(instanceUUID, nodeName, iterationId, activityInstanceId); XpdlInstance instance = buffer.getInstance(instanceUUID); if (instance != null) { return getExecOnNode(instance.getRootExecution(), nodeName, iterationId, activityInstanceId); } XpdlExecution exec = getRuntimeDbSession().getExecutionPointingOnNode(instanceUUID, nodeName, iterationId, activityInstanceId); if (exec != null && !buffer.isInstanceRemoved(exec.getXpdlInstance().getUUID())) { return exec; } return null; }
XpdlExecution xpdlExecution = (XpdlExecution) execution; XpdlInstance xpdlInstance = xpdlExecution.getXpdlInstance(); xpdlInstance.setInstanceState(InstanceState.FINISHED); final Recorder recorder = EnvTool.getRecorder(); recorder.recordBodyEnded(this, xpdlExecution); recorder.recordInstanceEnded(xpdlInstance, EnvTool.getUserId()); XpdlExecution execToSignal = xpdlInstance.getExecutionToSignal(); if (execToSignal != null) { xpdlInstance.setExecutionToSignal(null); } else {
public void execute(ActivityExecution execution) { XpdlExecution xpdlExecution = (XpdlExecution) execution; if (xpdlExecution.getXpdlInstance().getInstanceState().equals(InstanceState.FINISHED)) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("XPDLInstance ended : " + xpdlExecution.getXpdlInstance()); ProcessInstanceUUID instanceUUID = xpdlExecution.getXpdlInstance().getUUID(); MultiInstantiator actInstantiator = ClassDataLoader.getActivityInstantiatorInstance( xpdlExecution.getXpdlInstance().getPackageDefinitionUUID(), multiInstantiationClass); try { actInstDescr = actInstantiator.execute(
public void handleFinishedInstance(XpdlInstance instance) { final Querier journal = EnvTool.getJournalQueriers(); final Recorder recorder = EnvTool.getRecorder(); List<ProcessFullInstance> ids = new ArrayList<ProcessFullInstance>(); ids.add(journal.getProcessInstance(instance.getUUID())); if (instance.getChildInstances() != null) { for (XpdlInstance child : instance.getChildInstances()) { ids.add(journal.getProcessInstance(child.getUUID())); } } for (ProcessFullInstance processInst : ids) { recorder.remove(processInst); } } }
public Set<XpdlInstance> getXpdlInstances(ProcessDefinitionUUID processUUID) { Misc.checkArgsNotNull(processUUID); Set<XpdlInstance> dbInstances = getRuntimeDbSession().getXpdlInstances(processUUID); for (XpdlInstance instance : dbInstances) { if (!buffer.containsInstance(instance.getUUID()) && !buffer.isInstanceRemoved(instance.getUUID())) { buffer.addInstance(instance); } } Set<XpdlInstance> result = new HashSet<XpdlInstance>(); for (XpdlInstance instance : buffer.getInstances().values()) { if (instance.getProcessDefinitionUUID().equals(processUUID)) { result.add(instance); } } return result; }
if (xpdlExecution.getXpdlInstance().getInstanceState().equals(InstanceState.FINISHED)) { if (AbstractActivity.LOG.isLoggable(Level.FINE)) { AbstractActivity.LOG.fine("XPDLInstance ended : " + xpdlExecution.getXpdlInstance()); xpdlExecution.getXpdlInstance().getPackageDefinitionUUID(), this.multiInstantiationClass); try { actInstDescr = EngineEnvTool.getHookExecutor()
instance.setExecutionToSignal((XpdlExecution)execution);
public static void executeHook(XpdlExecution execution, String activityId, JavaHook javaHook) { if (javaHook != null) { final XpdlInstance instance = execution.getXpdlInstance(); final ProcessInstanceUUID instanceUUID = instance.getUUID(); final String iterationId = execution.getIterationId(); final String activityInstanceId = execution.getActivityInstanceId(); final ProcessDefinitionUUID processUUID = instance.getProcessDefinitionUUID(); boolean inTransaction = javaHook.isInTransaction(); try { Object hookInstance = ClassDataLoader.getHookInstance(instance.getPackageDefinitionUUID(), javaHook); if (!inTransaction && hookInstance instanceof TxHook) { throw new BonitaRuntimeException("The specified hook eventName declares an 'outside transaction hook' "
public void addInstance(XpdlInstance instance) { ProcessInstanceUUID instanceUUID = instance.getUUID(); instances.put(instanceUUID, instance); removedInstances.remove(instanceUUID); } public void removeInstance(XpdlInstance instance) {
@Override public void signal(final ActivityExecution execution, final String signal, final Map<String, Object> signalParameters) { final XpdlExecution xpdlExecution = (XpdlExecution) execution; xpdlExecution.setSubflowXpdlInstance(null); if (SUBFLOW_SIGNAL.equals(signal)) { if (this.outParameters != null) { final Recorder recorder = EngineEnvTool.getRecorder(); final ProcessInstanceUUID instanceUUID = xpdlExecution.getXpdlInstance().getUUID(); for (final Map.Entry<String, String> parameter : this.outParameters.entrySet()) { final String variableId = parameter.getValue(); final Object variableValue = signalParameters.get(parameter.getKey()); execution.setVariable(variableId, variableValue); if (xpdlExecution.getXpdlInstance().getRootExecution().hasVariable(variableId)) { recorder.recordInstanceVariableUpdated(variableId, variableValue, instanceUUID, EngineEnvTool.getUserId()); } else { recorder.recordActivityVariableUpdated(variableId, variableValue, xpdlExecution.getCurrentActivityInstanceUUID(), EngineEnvTool.getUserId()); } } } super.signal(xpdlExecution, BODY_FINISHED, null); } else { super.signal(xpdlExecution, signal, signalParameters); } }