Search in sources :

Example 11 with ProcessRuntime

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

the class ProcessEventSupport method fireAfterSLAViolated.

public void fireAfterSLAViolated(final ProcessInstance instance, NodeInstance nodeInstance, ProcessRuntime runtime) {
    final Iterator<ProcessEventListener> iter = getEventListenersIterator();
    final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
    final SLAViolatedEvent event = new SLAViolatedEventImpl(instance, nodeInstance, runtime);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.afterSLAViolated(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
        delayedListeners.forEach(l -> l.afterSLAViolated(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) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ArrayList(java.util.ArrayList) SLAViolatedEvent(io.automatiko.engine.api.event.process.SLAViolatedEvent)

Example 12 with ProcessRuntime

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

the class ProcessEventSupport method fireBeforeProcessCompleted.

public void fireBeforeProcessCompleted(final ProcessInstance instance, ProcessRuntime runtime) {
    final Iterator<ProcessEventListener> iter = getEventListenersIterator();
    final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
    final ProcessCompletedEvent event = new ProcessCompletedEventImpl(instance, runtime);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.beforeProcessCompleted(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
        delayedListeners.forEach(l -> l.beforeProcessCompleted(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) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ArrayList(java.util.ArrayList) ProcessCompletedEvent(io.automatiko.engine.api.event.process.ProcessCompletedEvent)

Example 13 with ProcessRuntime

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

the class ProcessEventSupport method fireAfterWorkItemTransition.

public void fireAfterWorkItemTransition(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, true);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.afterWorkItemTransition(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
        delayedListeners.forEach(l -> l.afterWorkItemTransition(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 14 with ProcessRuntime

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

the class ProcessEventSupport method fireAfterNodeLeft.

public void fireAfterNodeLeft(final NodeInstance nodeInstance, ProcessRuntime runtime) {
    final Iterator<ProcessEventListener> iter = getEventListenersIterator();
    final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
    final ProcessNodeLeftEvent event = new ProcessNodeLeftEventImpl(nodeInstance, runtime);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.afterNodeLeft(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
        delayedListeners.forEach(l -> l.afterNodeLeft(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) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ArrayList(java.util.ArrayList) ProcessNodeLeftEvent(io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)

Example 15 with ProcessRuntime

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

the class ProcessEventSupport method fireAfterVariableChanged.

public void fireAfterVariableChanged(final String name, final String id, final Object oldValue, final Object newValue, final List<String> tags, final ProcessInstance processInstance, NodeInstance nodeInstance, ProcessRuntime runtime) {
    final Iterator<ProcessEventListener> iter = getEventListenersIterator();
    final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
    final ProcessVariableChangedEvent event = new ProcessVariableChangedEventImpl(name, id, oldValue, newValue, tags, processInstance, nodeInstance, runtime);
    if (iter.hasNext()) {
        do {
            ProcessEventListener listener = iter.next();
            if (listener instanceof DelayedExecution) {
                delayedListeners.add(listener);
            } else {
                listener.afterVariableChanged(event);
            }
        } while (iter.hasNext());
    }
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
        delayedListeners.forEach(l -> l.afterVariableChanged(e));
    }));
}
Also used : ProcessVariableChangedEvent(io.automatiko.engine.api.event.process.ProcessVariableChangedEvent) 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) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) ArrayList(java.util.ArrayList)

Aggregations

ProcessRuntime (io.automatiko.engine.api.runtime.process.ProcessRuntime)22 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)21 ArrayList (java.util.ArrayList)21 List (java.util.List)20 DelayedExecution (io.automatiko.engine.api.event.process.DelayedExecution)19 ProcessCompletedEvent (io.automatiko.engine.api.event.process.ProcessCompletedEvent)19 ProcessEventListener (io.automatiko.engine.api.event.process.ProcessEventListener)19 ProcessNodeInstanceFailedEvent (io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent)19 ProcessNodeLeftEvent (io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)19 ProcessNodeTriggeredEvent (io.automatiko.engine.api.event.process.ProcessNodeTriggeredEvent)19 ProcessSignaledEvent (io.automatiko.engine.api.event.process.ProcessSignaledEvent)19 ProcessStartedEvent (io.automatiko.engine.api.event.process.ProcessStartedEvent)19 ProcessVariableChangedEvent (io.automatiko.engine.api.event.process.ProcessVariableChangedEvent)19 ProcessWorkItemTransitionEvent (io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent)19 SLAViolatedEvent (io.automatiko.engine.api.event.process.SLAViolatedEvent)19 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)19 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)19 UnitOfWorkManager (io.automatiko.engine.api.uow.UnitOfWorkManager)19 WorkUnit (io.automatiko.engine.api.uow.WorkUnit)19 Transition (io.automatiko.engine.api.workflow.workitem.Transition)19