Search in sources :

Example 6 with WorkItemNotFoundException

use of io.automatiko.engine.api.runtime.process.WorkItemNotFoundException 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

WorkItemNotFoundException (io.automatiko.engine.api.runtime.process.WorkItemNotFoundException)6 WorkItem (io.automatiko.engine.api.workflow.WorkItem)5 IdentityProvider (io.automatiko.engine.api.auth.IdentityProvider)3 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)3 ProcessInstanceReadMode (io.automatiko.engine.api.workflow.ProcessInstanceReadMode)2 Sig (io.automatiko.engine.workflow.Sig)2 Collections (java.util.Collections)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Collectors (java.util.stream.Collectors)2 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)1 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)1 WorkItemHandler (io.automatiko.engine.api.runtime.process.WorkItemHandler)1 WorkItemHandlerNotFoundException (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException)1 RawString (io.quarkus.qute.RawString)1 Template (io.quarkus.qute.Template)1 TemplateInstance (io.quarkus.qute.TemplateInstance)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1