use of io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance in project automatiko-engine by automatiko-io.
the class WorkItemNodeInstance method exceptionHandlingCompleted.
private void exceptionHandlingCompleted(ProcessInstance processInstance, ProcessWorkItemHandlerException handlerException) {
if (handlerException == null) {
handlerException = (ProcessWorkItemHandlerException) ((WorkflowProcessInstance) processInstance).getVariable("Error");
}
switch(handlerException.getStrategy()) {
case ABORT:
getProcessInstance().getProcessRuntime().getWorkItemManager().abortWorkItem(getWorkItem().getId());
break;
case RETHROW:
String exceptionName = handlerException.getCause().getClass().getName();
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
if (exceptionScopeInstance == null) {
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute work item " + handlerException.getMessage(), handlerException.getCause());
}
exceptionScopeInstance.handleException(this, exceptionName, handlerException.getCause());
break;
case RETRY:
Map<String, Object> parameters = new HashMap<>(getWorkItem().getParameters());
parameters.putAll(processInstance.getVariables());
((DefaultWorkItemManager) getProcessInstance().getProcessRuntime().getWorkItemManager()).retryWorkItem(getWorkItem().getId(), parameters);
break;
case COMPLETE:
getProcessInstance().getProcessRuntime().getWorkItemManager().completeWorkItem(getWorkItem().getId(), processInstance.getVariables());
break;
default:
break;
}
}
use of io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance in project automatiko-engine by automatiko-io.
the class DynamicUtils method addDynamicWorkItem.
public static void addDynamicWorkItem(final DynamicNodeInstance dynamicContext, InternalProcessRuntime runtime, String workItemName, Map<String, Object> parameters) {
final WorkflowProcessInstance processInstance = dynamicContext.getProcessInstance();
internalAddDynamicWorkItem(processInstance, dynamicContext, runtime, workItemName, parameters);
}
Aggregations