@Override public String getName() { return instanceContext.getProcessDefinition().getName(); }
@Override public String toString() { try { return "Process [" + instanceContext.getProcessDefinition().getName() + "] resource [" + instanceContext.getState().getResourceId() + "]"; } catch (NullPointerException e) { return super.toString(); } }
protected String getConfiguredChainProcess() { ProcessState state = instanceContext.getState(); ProcessDefinition processDefinition = instanceContext.getProcessDefinition(); if (state.getData().containsKey(processDefinition.getName() + ProcessLogic.CHAIN_PROCESS)) { return state.getData().get(processDefinition.getName() + ProcessLogic.CHAIN_PROCESS).toString(); } return null; }
protected void runLogic() { inLogic = true; boolean shouldDelegate = false; try { instanceContext.setPhase(ProcessPhase.PRE_LISTENERS); shouldDelegate |= runHandlers(ProcessPhase.PRE_LISTENERS_DONE, instanceContext.getProcessDefinition().getPreProcessListeners()); instanceContext.setPhase(ProcessPhase.HANDLERS); shouldDelegate |= runHandlers(ProcessPhase.HANDLER_DONE, instanceContext.getProcessDefinition().getProcessHandlers()); instanceContext.setPhase(ProcessPhase.POST_LISTENERS); shouldDelegate |= runHandlers(ProcessPhase.POST_LISTENERS_DONE, instanceContext.getProcessDefinition().getPostProcessListeners()); if (shouldDelegate) { throw new ProcessCancelException("Process result triggered a delegation"); } } finally { inLogic = false; } instanceContext.setPhase(ProcessPhase.DONE); }
protected boolean shouldAbort(ProcessCancelException e) { ProcessDefinition def = context.getProcessManager().getProcessDelegate(instanceContext.getProcessDefinition()); if (def == null) { return true; } ProcessState state = def.constructProcessState(record); if (state.shouldCancel(record)) { return true; } ProcessInstanceContext newContext = new ProcessInstanceContext(); newContext.setProcessDefinition(def); newContext.setState(state); newContext.setPhase(ProcessPhase.STARTED); instanceContextHistory.push(instanceContext); instanceContext = newContext; return false; }
protected void openLog(EngineContext engineContext) { if (processLog == null) { ParentLog parentLog = engineContext.peekLog(); if (parentLog == null) { processLog = new ProcessLog(); } else { processLog = parentLog.newChildLog(); } } execution = processLog.newExecution(); execution.setProcessId(record.getId()); execution.setResourceType(instanceContext.getProcessDefinition().getResourceType()); execution.setResourceId(instanceContext.getState().getResourceId()); execution.setProcessName(instanceContext.getProcessDefinition().getName()); engineContext.pushLog(execution); }
protected boolean runHandlers(ProcessPhase phase, List<? extends ProcessLogic> handlers) { boolean shouldDelegate = false; final ProcessDefinition processDefinition = instanceContext.getProcessDefinition(); final ProcessState state = instanceContext.getState(); ProcessPhase currentPhase = instanceContext.getPhase();
Predicate predicate = record.getPredicate(); if (predicate != null) { if (!predicate.evaluate(this.instanceContext.getState(), this, this.instanceContext.getProcessDefinition())) { throw new ProcessCancelException("Predicate is not valid");