use of org.kie.kogito.internal.process.runtime.KogitoNode in project kogito-runtimes by kiegroup.
the class TriggerMetaData method getOwnerId.
private static String getOwnerId(Node node) {
StringBuilder prefix = new StringBuilder();
if (node instanceof KogitoNode) {
NodeContainer container = ((KogitoNode) node).getParentContainer();
while (container instanceof CompositeNode) {
CompositeNode compositeNode = (CompositeNode) container;
prefix.append(compositeNode.getId()).append('_');
container = compositeNode.getParentContainer();
}
}
return prefix.append(node.getId()).toString();
}
use of org.kie.kogito.internal.process.runtime.KogitoNode in project kogito-runtimes by kiegroup.
the class KogitoWorkingMemoryLogger method createNodeId.
private String createNodeId(NodeInstance nodeInstance) {
Node node = nodeInstance.getNode();
if (node == null) {
return "";
}
Object uniqueIdObj = node.getMetaData().get("UniqueId");
String nodeId;
if (uniqueIdObj == null) {
nodeId = "" + node.getId();
} else {
nodeId = (String) uniqueIdObj;
}
NodeContainer nodeContainer = ((KogitoNode) node).getParentContainer();
while (nodeContainer != null) {
if (nodeContainer instanceof Node) {
node = (Node) nodeContainer;
nodeContainer = node.getNodeContainer();
// TODO fix this filter out hidden compositeNode inside ForEach node
if (!(nodeContainer.getClass().getName().endsWith("ForEachNode"))) {
nodeId = node.getId() + ":" + nodeId;
}
} else {
break;
}
}
return nodeId;
}
use of org.kie.kogito.internal.process.runtime.KogitoNode in project kogito-runtimes by kiegroup.
the class RuleFlowProcessFactory method linkBoundaryErrorEvent.
protected void linkBoundaryErrorEvent(Node node, String attachedTo, Node attachedNode) {
// same logic from ProcessHandler.linkBoundaryErrorEvent
final String errorCode = (String) node.getMetaData().get(ERROR_EVENT);
final ContextResolver compositeNode = (ContextResolver) attachedNode;
ExceptionScope exceptionScope = (ExceptionScope) compositeNode.resolveContext(EXCEPTION_SCOPE, errorCode);
if (exceptionScope == null) {
ContextContainer contextContainer = (ContextContainer) (node instanceof ContextContainer ? node : ((KogitoNode) node).getParentContainer());
exceptionScope = new ExceptionScope();
contextContainer.addContext(exceptionScope);
contextContainer.setDefaultContext(exceptionScope);
}
final Boolean hasErrorCode = (Boolean) node.getMetaData().get(HAS_ERROR_EVENT);
final String errorStructureRef = (String) node.getMetaData().get(ERROR_STRUCTURE_REF);
final ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
final EventNode eventNode = (EventNode) node;
final String variable = eventNode.getVariableName();
final String inputVariable = eventNode.getInputVariableName();
final DroolsConsequenceAction signalAction = new DroolsConsequenceAction("java", null);
signalAction.setMetaData(ACTION, new SignalProcessInstanceAction(ERROR_TYPE_PREFIX + attachedTo + "-" + errorCode, variable, inputVariable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
exceptionHandler.setAction(signalAction);
exceptionHandler.setFaultVariable(variable);
final String code = Optional.ofNullable(hasErrorCode).filter(Boolean.TRUE::equals).map(v -> errorCode).orElse(null);
exceptionScope.setExceptionHandler(code, exceptionHandler);
if (errorStructureRef != null) {
exceptionScope.setExceptionHandler(errorStructureRef, exceptionHandler);
}
final DroolsConsequenceAction cancelAction = new DroolsConsequenceAction("java", null);
cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
final List<DroolsAction> actions = Optional.ofNullable(eventNode.getActions(EVENT_NODE_EXIT)).orElseGet(ArrayList::new);
actions.add(cancelAction);
eventNode.setActions(EVENT_NODE_EXIT, actions);
}
Aggregations