use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcess in project automatiko-engine by automatiko-io.
the class ProcessRuntimeImpl method initProcessEventListener.
private void initProcessEventListener(Process process) {
if (process instanceof ExecutableProcess) {
for (Node node : ((ExecutableProcess) process).getNodes()) {
if (node instanceof StartNode) {
StartNode startNode = (StartNode) node;
if (startNode != null) {
List<Trigger> triggers = startNode.getTriggers();
if (triggers != null) {
for (Trigger trigger : triggers) {
if (trigger instanceof EventTrigger) {
final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
String type = null;
for (EventFilter filter : filters) {
if (filter instanceof EventTypeFilter) {
type = ((EventTypeFilter) filter).getType();
}
}
StartProcessEventListener listener = new StartProcessEventListener(process.getId(), filters, trigger.getInMappings(), startNode.getEventTransformer());
signalManager.addEventListener(type, listener);
((ExecutableProcess) process).getRuntimeMetaData().put("StartProcessEventType", type);
((ExecutableProcess) process).getRuntimeMetaData().put("StartProcessEventListener", listener);
}
}
}
}
}
}
}
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcess in project automatiko-engine by automatiko-io.
the class ProcessRuntimeImpl method initStartTimers.
public void initStartTimers() {
Collection<Process> processes = this.processes.values();
for (Process process : processes) {
ExecutableProcess p = (ExecutableProcess) process;
List<StartNode> startNodes = p.getTimerStart();
if (startNodes != null && !startNodes.isEmpty()) {
for (StartNode startNode : startNodes) {
if (startNode != null && startNode.getTimer() != null) {
jobService.scheduleProcessJob(ProcessJobDescription.of(createTimerInstance(startNode.getTimer()), p.getId(), p.getVersion()));
}
}
}
}
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcess in project automatiko-engine by automatiko-io.
the class CompensationEventListener method createNodeInstanceContainers.
private Stack<NodeInstance> createNodeInstanceContainers(Node toCompensateNode, boolean generalCompensation) {
Stack<NodeContainer> nestedNodes = new Stack<NodeContainer>();
Stack<NodeInstance> generatedInstances = new Stack<NodeInstance>();
NodeContainer parentContainer = toCompensateNode.getParentContainer();
while (!(parentContainer instanceof ExecutableProcess)) {
nestedNodes.add(parentContainer);
parentContainer = ((Node) parentContainer).getParentContainer();
}
NodeInstanceContainer parentInstance;
if (nestedNodes.isEmpty()) {
// nestedNodes is empty
parentInstance = (NodeInstanceContainer) getProcessInstance();
} else {
parentInstance = (NodeInstanceContainer) ((WorkflowProcessInstanceImpl) getProcessInstance()).getNodeInstance((Node) nestedNodes.pop());
generatedInstances.add((NodeInstance) parentInstance);
}
NodeInstanceContainer childInstance;
while (!nestedNodes.isEmpty()) {
// generate
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance((Node) nestedNodes.pop());
assert childInstance instanceof CompositeNodeInstance : "A node with child nodes should end up creating a CompositeNodeInstance type.";
// track and modify
generatedInstances.add((NodeInstance) childInstance);
// loop
parentInstance = childInstance;
}
if (generalCompensation) {
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance(toCompensateNode);
generatedInstances.add((NodeInstance) childInstance);
}
return generatedInstances;
}
Aggregations