use of io.automatiko.engine.workflow.process.core.node.BoundaryEventNode in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method errorBoundaryEventNode.
public BoundaryEventNode errorBoundaryEventNode(long id, List<ErrorDefinition> defs, RetryDefinition retry, NodeContainer nodeContainer, Node attachedTo, Workflow workflow) {
BoundaryEventNode boundaryEventNode = new BoundaryEventNode();
boundaryEventNode.setId(id);
boundaryEventNode.setName(defs.stream().map(def -> def.getName()).collect(Collectors.joining("|")));
String errorCodes = defs.stream().map(def -> def.getCode()).collect(Collectors.joining(","));
String attachedToId = (String) attachedTo.getMetaData().getOrDefault(UNIQUE_ID_PARAM, Long.toString(attachedTo.getId()));
EventTypeFilter filter = new EventTypeFilter();
filter.setType("Error-" + attachedToId + "-" + errorCodes);
boundaryEventNode.addEventFilter(filter);
boundaryEventNode.setAttachedToNodeId(attachedToId);
boundaryEventNode.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
boundaryEventNode.setMetaData("EventType", "error");
boundaryEventNode.setMetaData("ErrorEvent", errorCodes);
boundaryEventNode.setMetaData("AttachedTo", attachedToId);
boundaryEventNode.setMetaData("HasErrorEvent", true);
if (retry != null) {
int delayAsInt = ((Long) DateTimeUtils.parseDuration(retry.getDelay())).intValue();
boundaryEventNode.setMetaData("ErrorRetry", retry.getDelay() == null ? DEFAULT_RETRY_AFTER : delayAsInt);
boundaryEventNode.setMetaData("ErrorRetryLimit", retry.getMaxAttempts() == null ? DEFAULT_RETRY_LIMIT : Integer.parseInt(retry.getMaxAttempts()));
if (retry.getMultiplier() != null) {
boundaryEventNode.setMetaData("ErrorRetryIncrementMultiplier", Float.parseFloat(retry.getMultiplier()));
}
}
nodeContainer.addNode(boundaryEventNode);
return boundaryEventNode;
}
use of io.automatiko.engine.workflow.process.core.node.BoundaryEventNode in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method compensationBoundaryEventNode.
public BoundaryEventNode compensationBoundaryEventNode(long id, String name, ExecutableProcess process, Node attachToNode) {
BoundaryEventNode boundaryEventNode = new BoundaryEventNode();
boundaryEventNode.setId(id);
boundaryEventNode.setName(name);
EventTypeFilter filter = new EventTypeFilter();
filter.setType("Compensation");
boundaryEventNode.addEventFilter(filter);
boundaryEventNode.setAttachedToNodeId(Long.toString(attachToNode.getId()));
boundaryEventNode.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
boundaryEventNode.setMetaData("EventType", "compensation");
boundaryEventNode.setMetaData("AttachedTo", Long.toString(attachToNode.getId()));
process.addNode(boundaryEventNode);
return boundaryEventNode;
}
use of io.automatiko.engine.workflow.process.core.node.BoundaryEventNode in project automatiko-engine by automatiko-io.
the class ServiceTaskDescriptor method collectHandledErrorCodes.
private Set<String> collectHandledErrorCodes() {
Set<String> errorCodes = new HashSet<>();
NodeContainer container = workItemNode.getParentContainer();
String thisNodeId = (String) workItemNode.getMetaData("UniqueId");
for (Node node : container.getNodes()) {
if (node instanceof BoundaryEventNode) {
String errorCode = (String) node.getMetaData().get("ErrorEvent");
if (errorCode != null && ((BoundaryEventNode) node).getAttachedToNodeId().equals(thisNodeId)) {
errorCodes.add(errorCode);
}
}
}
// next collect event subprocess node with error start event from this level and to all parents
String replaceRegExp = "Error-|Escalation-";
for (Node node : container.getNodes()) {
if (node instanceof EventSubProcessNode) {
EventSubProcessNode eventSubProcessNode = (EventSubProcessNode) node;
Node[] nodes = eventSubProcessNode.getNodes();
for (Node subNode : nodes) {
// avoids cyclomatic complexity
if (subNode == null || !(subNode instanceof StartNode)) {
continue;
}
List<Trigger> triggers = ((StartNode) subNode).getTriggers();
if (triggers == null) {
continue;
}
for (Trigger trigger : triggers) {
if (trigger instanceof EventTrigger) {
final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
for (EventFilter filter : filters) {
if (filter instanceof EventTypeFilter) {
eventSubProcessNode.addEvent((EventTypeFilter) filter);
String type = ((EventTypeFilter) filter).getType();
if (type.startsWith("Error-")) {
String trimmedType = type.replaceFirst(replaceRegExp, "");
for (String error : trimmedType.split(",")) {
errorCodes.add(error);
}
}
}
}
}
}
}
}
}
return errorCodes;
}
use of io.automatiko.engine.workflow.process.core.node.BoundaryEventNode in project automatiko-engine by automatiko-io.
the class BoundaryEventNodeInstance method signalEvent.
@Override
public void signalEvent(String type, Object event) {
BoundaryEventNode boundaryNode = (BoundaryEventNode) getEventNode();
String attachedTo = boundaryNode.getAttachedToNodeId();
Collection<NodeInstance> nodeInstances = ((NodeInstanceContainer) getProcessInstance()).getNodeInstances(true);
if (type != null && type.startsWith("Compensation")) {
// if not active && completed, signal
if (!isAttachedToNodeActive(nodeInstances, attachedTo, type, event) && isAttachedToNodeCompleted(attachedTo)) {
super.signalEvent(type, event);
} else {
cancel();
}
} else {
if (isAttachedToNodeActive(nodeInstances, attachedTo, type, event)) {
super.signalEvent(type, event);
} else {
cancel();
}
}
}
use of io.automatiko.engine.workflow.process.core.node.BoundaryEventNode in project automatiko-engine by automatiko-io.
the class SvgBpmnProcessImageGenerator method buildNodeContainer.
/*
* Build methods
*/
protected void buildNodeContainer(int x, int y, NodeContainer nodeContainer, SVGGraphics2D g2) {
try {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof StartNode) {
buildStartEvent(x, y, (StartNode) node, g2);
} else if (node instanceof EndNode) {
buildEndEvent(x, y, (EndNode) node, g2);
} else if (node instanceof FaultNode) {
buildErrorEndEvent(x, y, (FaultNode) node, g2);
} else if (node instanceof BoundaryEventNode) {
buildBoundaryEvent(x, y, node, g2);
} else if (node instanceof EventNode || node instanceof StateNode) {
buildIntermediateEvent(x, y, node, g2);
} else if (node instanceof HumanTaskNode) {
buildHumanTaskNode(x, y, (HumanTaskNode) node, g2);
} else if (node instanceof ActionNode) {
buildScriptTaskNode(x, y, (ActionNode) node, g2);
} else if (node instanceof WorkItemNode) {
buildServiceTaskNode(x, y, (WorkItemNode) node, g2);
} else if (node instanceof Split || node instanceof Join) {
buildGateway(x, y, node, g2);
} else if (node instanceof ForEachNode) {
buildNodeContainer(x(node), y(node), ((ForEachNode) node).getCompositeNode(), g2);
} else if (node instanceof CompositeNode) {
buildSubprocessNode(x, y, (CompositeNode) node, g2);
int sx = x(node);
int sy = y(node);
buildNodeContainer(sx, sy, (CompositeNode) node, g2);
} else if (node instanceof RuleSetNode) {
buildBusinessRuleTaskNode(x, y, (RuleSetNode) node, g2);
} else if (node instanceof TimerNode) {
buildTimerEvent(x, y, (TimerNode) node, g2);
} else if (node instanceof SubProcessNode) {
buildCallActivity(x, y, (SubProcessNode) node, g2);
}
buildSequenceFlow(x, y, node, g2);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations