Search in sources :

Example 6 with WorkItemHandlerNotFoundException

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException in project automatiko-engine by automatiko-io.

the class LightWorkItemManager method transitionWorkItem.

@SuppressWarnings("unchecked")
@Override
public void transitionWorkItem(String id, Transition<?> transition) {
    WorkItem workItem = workItems.get(id);
    // work item may have been aborted
    if (workItem != null) {
        WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
        if (handler != null) {
            ProcessInstance processInstance = workItem.getProcessInstance();
            eventSupport.fireBeforeWorkItemTransition(processInstance, workItem, transition, null);
            try {
                handler.transitionToPhase(workItem, this, transition);
            } catch (UnsupportedOperationException e) {
                ((WorkItemImpl) workItem).setResults((Map<String, Object>) transition.data());
                workItem.setPhaseId(Complete.ID);
                workItem.setPhaseStatus(Complete.STATUS);
                completePhase.apply(workItem, transition);
                internalCompleteWorkItem(workItem);
            }
            eventSupport.fireAfterWorkItemTransition(processInstance, workItem, transition, null);
        } else {
            throw new WorkItemHandlerNotFoundException(workItem.getName());
        }
    } else {
        throw new WorkItemNotFoundException("Work Item (" + id + ") does not exist", id);
    }
}
Also used : WorkItemHandler(io.automatiko.engine.api.runtime.process.WorkItemHandler) WorkItemNotFoundException(io.automatiko.engine.api.runtime.process.WorkItemNotFoundException) WorkItemHandlerNotFoundException(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkItem(io.automatiko.engine.api.runtime.process.WorkItem) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

WorkItemHandlerNotFoundException (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException)6 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)4 WorkItemHandler (io.automatiko.engine.api.runtime.process.WorkItemHandler)3 WorkItemImpl (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl)3 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)2 DefaultWorkItemManager (io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager)2 WorkflowProcessInstance (io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)2 HashMap (java.util.HashMap)2 HumanTaskWorkItem (io.automatiko.engine.api.runtime.process.HumanTaskWorkItem)1 ProcessWorkItemHandlerException (io.automatiko.engine.api.runtime.process.ProcessWorkItemHandlerException)1 WorkItemNotFoundException (io.automatiko.engine.api.runtime.process.WorkItemNotFoundException)1 WorkItemExecutionError (io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError)1 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)1 ProcessInstance (io.automatiko.engine.workflow.base.instance.ProcessInstance)1 DoNothingWorkItemHandler (io.automatiko.engine.workflow.base.instance.impl.demo.DoNothingWorkItemHandler)1 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 WorkflowRuntimeException (io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException)1 Person (io.automatiko.engine.workflow.process.test.Person)1 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)1