use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeSLAViolated.
public void fireBeforeSLAViolated(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.beforeSLAViolated(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.beforeSLAViolated(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeProcessSignaled.
public void fireBeforeProcessSignaled(String signal, Object data, final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessSignaledEvent event = new ProcessSignaledEventImpl(signal, data, instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeProcessSignaled(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.beforeProcessSignaled(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class CleanFilesEventListener method afterProcessCompleted.
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
ProcessInstance pi = event.getProcessInstance();
for (Entry<String, Object> variable : pi.getVariables().entrySet()) {
if (variable.getValue() instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) variable.getValue();
store.remove(pi.getProcess().getId(), pi.getProcess().getVersion(), pi.getId(), variable.getKey(), file.name());
} else if (variable.getValue() instanceof Collection) {
for (Object potentialFile : (Collection<?>) variable.getValue()) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
store.remove(pi.getProcess().getId(), pi.getProcess().getVersion(), pi.getId(), variable.getKey(), file.name());
}
}
}
}
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class JbpmBpmn2TestCase method assertNodeActive.
public void assertNodeActive(String processInstanceId, InternalProcessRuntime processRuntime, String... name) {
List<String> names = new ArrayList<String>();
for (String n : name) {
names.add(n);
}
ProcessInstance processInstance = processRuntime.getProcessInstance(processInstanceId);
if (processInstance instanceof WorkflowProcessInstance) {
assertNodeActive((WorkflowProcessInstance) processInstance, names);
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) not active: " + s);
}
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class JbpmBpmn2TestCase method assertProcessInstanceCompleted.
protected void assertProcessInstanceCompleted(String processInstanceId, InternalProcessRuntime processRuntime) {
ProcessInstance processInstance = processRuntime.getProcessInstance(processInstanceId);
assertNull(processInstance, "Process instance has not completed.");
}
Aggregations