use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method linkBoundaryConditionEvent.
private void linkBoundaryConditionEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
String processId = ((ExecutableProcess) nodeContainer).getId();
String eventType = "RuleFlowStateEvent-" + processId + "-" + ((EventNode) node).getUniqueId() + "-" + attachedTo;
((EventTypeFilter) ((EventNode) node).getEventFilters().get(0)).setType(eventType);
((ExtendedNodeImpl) attachedNode).setCondition(((EventNode) node).getCondition());
((ExtendedNodeImpl) attachedNode).setMetaData("ConditionEventType", eventType);
boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
if (cancelActivity) {
List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
if (actions == null) {
actions = new ArrayList<ProcessAction>();
}
ConsequenceAction consequenceAction = new ConsequenceAction("java", "");
consequenceAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
actions.add(consequenceAction);
((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method linkBoundaryErrorEvent.
private static void linkBoundaryErrorEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
ContextContainer compositeNode = (ContextContainer) attachedNode;
ExceptionScope exceptionScope = (ExceptionScope) compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope == null) {
exceptionScope = new ExceptionScope();
compositeNode.addContext(exceptionScope);
compositeNode.setDefaultContext(exceptionScope);
}
String errorCode = (String) node.getMetaData().get("ErrorEvent");
boolean hasErrorCode = (Boolean) node.getMetaData().get("HasErrorEvent");
String errorStructureRef = (String) node.getMetaData().get("ErrorStructureRef");
ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
String variable = ((EventNode) node).getVariableName();
ConsequenceAction action = new ConsequenceAction("java", null);
action.setMetaData(ACTION, new SignalProcessInstanceAction("Error-" + attachedTo + "-" + errorCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
exceptionHandler.setAction(action);
exceptionHandler.setFaultVariable(variable);
exceptionHandler.setRetryAfter((Integer) node.getMetaData().get("ErrorRetry"));
exceptionHandler.setRetryIncrement((Integer) node.getMetaData().get("ErrorRetryIncrement"));
if (node.getMetaData().get("ErrorRetryIncrementMultiplier") != null) {
exceptionHandler.setRetryIncrementMultiplier(((Number) node.getMetaData().get("ErrorRetryIncrementMultiplier")).floatValue());
}
exceptionHandler.setRetryLimit((Integer) node.getMetaData().get("ErrorRetryLimit"));
if (hasErrorCode) {
for (String error : errorCode.split(",")) {
exceptionScope.setExceptionHandler(error, exceptionHandler);
}
} else {
exceptionScope.setExceptionHandler(null, exceptionHandler);
}
if (errorStructureRef != null) {
exceptionScope.setExceptionHandler(errorStructureRef, exceptionHandler);
}
List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
if (actions == null) {
actions = new ArrayList<ProcessAction>();
}
ConsequenceAction cancelAction = new ConsequenceAction("java", null);
cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
actions.add(cancelAction);
((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method timerAction.
protected ProcessAction timerAction(String type) {
ProcessAction signal = new ProcessAction();
Action action = kcontext -> kcontext.getProcessInstance().signalEvent(type, kcontext.getNodeInstance().getId());
signal.wire(action);
return signal;
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method linkBoundarySignalEvent.
protected void linkBoundarySignalEvent(Node node, String attachedTo) {
boolean cancelActivity = (Boolean) node.getMetaData().get(CANCEL_ACTIVITY);
if (cancelActivity) {
List<ProcessAction> actions = ((EventNode) node).getActions(EVENT_NODE_EXIT);
if (actions == null) {
actions = new ArrayList<>();
}
ConsequenceAction action = new ConsequenceAction("java", null);
action.setMetaData(ACTION, new CancelNodeInstanceAction(attachedTo));
actions.add(action);
((EventNode) node).setActions(EVENT_NODE_EXIT, actions);
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class StateBasedNode method addTimer.
public void addTimer(Timer timer, ProcessAction action) {
if (timers == null) {
timers = new HashMap<Timer, ProcessAction>();
}
if (timer.getId() == 0) {
long id = 0;
for (Timer t : timers.keySet()) {
if (t.getId() > id) {
id = t.getId();
}
}
timer.setId(++id);
}
timers.put(timer, action);
}
Aggregations