Search in sources :

Example 1 with WorkItem

use of io.automatiko.engine.api.runtime.process.WorkItem in project automatiko-engine by automatiko-io.

the class UIWorkItemHandler method reloadWorkItemsList.

private void reloadWorkItemsList() {
    List<WorkItemWrapper> result = new ArrayList<WorkItemWrapper>();
    for (Iterator<WorkItem> iterator = workItems.keySet().iterator(); iterator.hasNext(); ) {
        WorkItem workItem = iterator.next();
        result.add(new WorkItemWrapper(workItem));
    }
    workItemsList.setListData(result.toArray());
}
Also used : ArrayList(java.util.ArrayList) WorkItem(io.automatiko.engine.api.runtime.process.WorkItem)

Example 2 with WorkItem

use of io.automatiko.engine.api.runtime.process.WorkItem in project automatiko-engine by automatiko-io.

the class DefaultWorkItemManager method retryWorkItem.

public void retryWorkItem(String workItemId) {
    WorkItem workItem = workItems.get(workItemId);
    retryWorkItem(workItem);
}
Also used : WorkItem(io.automatiko.engine.api.runtime.process.WorkItem)

Example 3 with WorkItem

use of io.automatiko.engine.api.runtime.process.WorkItem in project automatiko-engine by automatiko-io.

the class DefaultWorkItemManager method completeWorkItem.

public void completeWorkItem(String id, Map<String, Object> results, Policy<?>... policies) {
    WorkItem workItem = workItems.get(id);
    // work item may have been aborted
    if (workItem != null) {
        ((WorkItemImpl) workItem).setResults(results);
        ProcessInstance processInstance = runtime.getProcessInstance(workItem.getProcessInstanceId());
        ((WorkItemImpl) workItem).setState(COMPLETED);
        // process instance may have finished already
        if (processInstance != null) {
            processInstance.signalEvent("workItemCompleted", workItem);
        }
        workItems.remove(id);
    }
}
Also used : ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkItem(io.automatiko.engine.api.runtime.process.WorkItem)

Example 4 with WorkItem

use of io.automatiko.engine.api.runtime.process.WorkItem in project automatiko-engine by automatiko-io.

the class ProcessEventSupport method fireBeforeWorkItemTransition.

public void fireBeforeWorkItemTransition(final ProcessInstance instance, WorkItem workitem, Transition<?> transition, ProcessRuntime runtime) {
    final Iterator<ProcessEventListener> iter = getEventListenersIterator();
    final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
    final ProcessWorkItemTransitionEvent event = new ProcessWorkItemTransitionEventImpl(instance, workitem, transition, runtime, false);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.beforeWorkItemTransition(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
        delayedListeners.forEach(l -> l.beforeWorkItemTransition(e));
    }));
}
Also used : ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ProcessVariableChangedEvent(io.automatiko.engine.api.event.process.ProcessVariableChangedEvent) UnitOfWorkManager(io.automatiko.engine.api.uow.UnitOfWorkManager) DelayedExecution(io.automatiko.engine.api.event.process.DelayedExecution) ProcessNodeTriggeredEvent(io.automatiko.engine.api.event.process.ProcessNodeTriggeredEvent) WorkItem(io.automatiko.engine.api.runtime.process.WorkItem) Iterator(java.util.Iterator) ProcessNodeLeftEvent(io.automatiko.engine.api.event.process.ProcessNodeLeftEvent) ProcessSignaledEvent(io.automatiko.engine.api.event.process.ProcessSignaledEvent) ProcessStartedEvent(io.automatiko.engine.api.event.process.ProcessStartedEvent) NodeInstance(io.automatiko.engine.api.runtime.process.NodeInstance) ProcessRuntime(io.automatiko.engine.api.runtime.process.ProcessRuntime) ArrayList(java.util.ArrayList) WorkUnit(io.automatiko.engine.api.uow.WorkUnit) List(java.util.List) ProcessNodeInstanceFailedEvent(io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent) ProcessCompletedEvent(io.automatiko.engine.api.event.process.ProcessCompletedEvent) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) Transition(io.automatiko.engine.api.workflow.workitem.Transition) SLAViolatedEvent(io.automatiko.engine.api.event.process.SLAViolatedEvent) ProcessWorkItemTransitionEvent(io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent) DelayedExecution(io.automatiko.engine.api.event.process.DelayedExecution) ProcessWorkItemTransitionEvent(io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ArrayList(java.util.ArrayList)

Example 5 with WorkItem

use of io.automatiko.engine.api.runtime.process.WorkItem in project automatiko-engine by automatiko-io.

the class LightWorkItemManager method retryWorkItem.

public void retryWorkItem(String workItemId) {
    WorkItem workItem = workItems.get(workItemId);
    retryWorkItem(workItem);
}
Also used : WorkItem(io.automatiko.engine.api.runtime.process.WorkItem)

Aggregations

WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)22 ProcessConfig (io.automatiko.engine.api.workflow.ProcessConfig)7 Test (org.junit.jupiter.api.Test)7 WorkItemHandler (io.automatiko.engine.api.runtime.process.WorkItemHandler)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 TextNode (com.fasterxml.jackson.databind.node.TextNode)5 WorkItemManager (io.automatiko.engine.api.runtime.process.WorkItemManager)5 ClassPathResource (io.automatiko.engine.services.io.ClassPathResource)5 DefaultWorkItemHandlerConfig (io.automatiko.engine.workflow.DefaultWorkItemHandlerConfig)5 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)4 ArrayList (java.util.ArrayList)4 HumanTaskWorkItem (io.automatiko.engine.api.runtime.process.HumanTaskWorkItem)3 HashMap (java.util.HashMap)3 DelayedExecution (io.automatiko.engine.api.event.process.DelayedExecution)2 ProcessCompletedEvent (io.automatiko.engine.api.event.process.ProcessCompletedEvent)2 ProcessEventListener (io.automatiko.engine.api.event.process.ProcessEventListener)2 ProcessNodeInstanceFailedEvent (io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent)2 ProcessNodeLeftEvent (io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)2