Search in sources :

Example 6 with KogitoNode

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();
}
Also used : CompositeNode(org.jbpm.workflow.core.node.CompositeNode) KogitoNode(org.kie.kogito.internal.process.runtime.KogitoNode) NodeContainer(org.kie.api.definition.process.NodeContainer)

Example 7 with KogitoNode

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;
}
Also used : KogitoNode(org.kie.kogito.internal.process.runtime.KogitoNode) Node(org.kie.api.definition.process.Node) KogitoNode(org.kie.kogito.internal.process.runtime.KogitoNode) NodeContainer(org.kie.api.definition.process.NodeContainer)

Example 8 with KogitoNode

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);
}
Also used : EventFilter(org.jbpm.process.core.event.EventFilter) Arrays(java.util.Arrays) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) TIME_CYCLE(org.jbpm.ruleflow.core.Metadata.TIME_CYCLE) ACTION(org.jbpm.ruleflow.core.Metadata.ACTION) StartNode(org.jbpm.workflow.core.node.StartNode) HashMap(java.util.HashMap) RuleFlowProcessValidator(org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) SIGNAL_NAME(org.jbpm.ruleflow.core.Metadata.SIGNAL_NAME) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) ArrayList(java.util.ArrayList) Timer(org.jbpm.process.core.timer.Timer) ProcessValidationError(org.jbpm.process.core.validation.ProcessValidationError) Swimlane(org.jbpm.process.core.context.swimlane.Swimlane) Map(java.util.Map) CancelNodeInstanceAction(org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) Variable(org.jbpm.process.core.context.variable.Variable) HAS_ERROR_EVENT(org.jbpm.ruleflow.core.Metadata.HAS_ERROR_EVENT) DataType(org.jbpm.process.core.datatype.DataType) UNIQUE_ID(org.jbpm.ruleflow.core.Metadata.UNIQUE_ID) ATTACHED_TO(org.jbpm.ruleflow.core.Metadata.ATTACHED_TO) EventNode(org.jbpm.workflow.core.node.EventNode) EVENT_NODE_EXIT(org.jbpm.workflow.core.impl.ExtendedNodeImpl.EVENT_NODE_EXIT) KogitoNode(org.kie.kogito.internal.process.runtime.KogitoNode) ContextResolver(org.jbpm.process.core.ContextResolver) TIME_DURATION(org.jbpm.ruleflow.core.Metadata.TIME_DURATION) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) DataTypeResolver(org.jbpm.process.core.datatype.DataTypeResolver) List(java.util.List) ERROR_STRUCTURE_REF(org.jbpm.ruleflow.core.Metadata.ERROR_STRUCTURE_REF) ContextContainer(org.jbpm.process.core.ContextContainer) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Node(org.kie.api.definition.process.Node) CANCEL_ACTIVITY(org.jbpm.ruleflow.core.Metadata.CANCEL_ACTIVITY) Optional(java.util.Optional) Action(org.jbpm.process.instance.impl.Action) EXCEPTION_SCOPE(org.jbpm.process.core.context.exception.ExceptionScope.EXCEPTION_SCOPE) TIME_DATE(org.jbpm.ruleflow.core.Metadata.TIME_DATE) Trigger(org.jbpm.workflow.core.node.Trigger) NodeContainer(org.kie.api.definition.process.NodeContainer) ERROR_EVENT(org.jbpm.ruleflow.core.Metadata.ERROR_EVENT) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) SignalProcessInstanceAction(org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) SignalProcessInstanceAction(org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction) CancelNodeInstanceAction(org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ArrayList(java.util.ArrayList) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) ContextContainer(org.jbpm.process.core.ContextContainer) EventNode(org.jbpm.workflow.core.node.EventNode) ContextResolver(org.jbpm.process.core.ContextResolver)

Aggregations

KogitoNode (org.kie.kogito.internal.process.runtime.KogitoNode)8 NodeContainer (org.kie.api.definition.process.NodeContainer)7 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)5 EventNode (org.jbpm.workflow.core.node.EventNode)4 Node (org.kie.api.definition.process.Node)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ContextContainer (org.jbpm.process.core.ContextContainer)2 ActionExceptionHandler (org.jbpm.process.core.context.exception.ActionExceptionHandler)2 ExceptionScope (org.jbpm.process.core.context.exception.ExceptionScope)2 EventFilter (org.jbpm.process.core.event.EventFilter)2 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)2 SignalProcessInstanceAction (org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction)2 Constraint (org.jbpm.workflow.core.Constraint)2 EndNode (org.jbpm.workflow.core.node.EndNode)2 FaultNode (org.jbpm.workflow.core.node.FaultNode)2 StartNode (org.jbpm.workflow.core.node.StartNode)2 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1