use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeProcessStarted.
public void fireBeforeProcessStarted(final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessStartedEvent event = new ProcessStartedEventImpl(instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeProcessStarted(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.beforeProcessStarted(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterProcessCompleted.
public void fireAfterProcessCompleted(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.afterProcessCompleted(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.afterProcessCompleted(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance 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));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterNodeInstanceFailed.
public void fireAfterNodeInstanceFailed(final ProcessInstance instance, NodeInstance nodeInstance, String errorId, String errorMessage, Exception exception, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessNodeInstanceFailedEvent event = new ProcessNodeInstanceFailedEventImpl(instance, nodeInstance, errorId, errorMessage, exception, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.afterNodeInstanceFailed(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.afterNodeInstanceFailed(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeVariableChanged.
public void fireBeforeVariableChanged(final String id, final String instanceId, 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(id, instanceId, oldValue, newValue, tags, processInstance, nodeInstance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeVariableChanged(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.beforeVariableChanged(e));
}));
}
Aggregations