use of io.automatiko.engine.api.event.process.ProcessEventListener 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));
}));
}
use of io.automatiko.engine.api.event.process.ProcessEventListener 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));
}));
}
use of io.automatiko.engine.api.event.process.ProcessEventListener 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));
}));
}
use of io.automatiko.engine.api.event.process.ProcessEventListener 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));
}));
}
use of io.automatiko.engine.api.event.process.ProcessEventListener 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));
}));
}
Aggregations