Search in sources :

Example 6 with WorkflowProcessInstance

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;
    }
}
Also used : DefaultWorkItemManager(io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager) HashMap(java.util.HashMap) WorkflowRuntimeException(io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException) WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance) ExceptionScopeInstance(io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance)

Example 7 with WorkflowProcessInstance

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);
}
Also used : WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)

Aggregations

WorkflowProcessInstance (io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)7 HashMap (java.util.HashMap)5 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)3 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)3 IdentityProvider (io.automatiko.engine.api.auth.IdentityProvider)2 Node (io.automatiko.engine.api.definition.process.Node)2 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)2 MockDataWorkItemHandler (io.automatiko.engine.workflow.base.instance.impl.demo.MockDataWorkItemHandler)2 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)2 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)2 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)2 Person (io.automatiko.engine.workflow.process.test.Person)2 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Set (java.util.Set)2 Test (org.junit.jupiter.api.Test)2 AccessPolicy (io.automatiko.engine.api.auth.AccessPolicy)1 SecurityPolicy (io.automatiko.engine.api.auth.SecurityPolicy)1 TrustedIdentityProvider (io.automatiko.engine.api.auth.TrustedIdentityProvider)1