diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java index 9ccecb22a79..6c95879a018 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java @@ -30,7 +30,6 @@ import org.jbpm.workflow.core.node.Join; import org.jbpm.workflow.core.node.Split; import org.kie.kogito.serverless.workflow.parser.ParserContext; -import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser; import io.serverlessworkflow.api.Workflow; import io.serverlessworkflow.api.events.OnEvents; @@ -65,7 +64,7 @@ public MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { private MakeNodeResult processOnEvent(RuleFlowNodeContainerFactory factory, OnEvents onEvent) { MakeNodeResult result = joinNodes(factory, - onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), isStartState ? ServerlessWorkflowParser.DEFAULT_WORKFLOW_VAR : getVarName(), + onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), getVarName(), (f, inputVar, outputVar) -> buildEventNode(f, onEventRef, inputVar, outputVar))); CompositeContextNodeFactory embeddedSubProcess = handleActions(makeCompositeNode(factory), onEvent.getActions()); connect(result.getOutgoingNode(), embeddedSubProcess); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java index 63610ad6b71..5c9caf6f451 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java @@ -50,6 +50,7 @@ import org.kie.kogito.serverless.workflow.SWFConstants; import org.kie.kogito.serverless.workflow.parser.ParserContext; import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser; +import org.kie.kogito.serverless.workflow.parser.VariableInfo; import org.kie.kogito.serverless.workflow.suppliers.CollectorActionSupplier; import org.kie.kogito.serverless.workflow.suppliers.CompensationActionSupplier; import org.kie.kogito.serverless.workflow.suppliers.ErrorExpressionActionSupplier; @@ -424,7 +425,8 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory embeddedSubProcess, String actionVarName, String fromStateExpr, String resultExpr, String toStateExpr, boolean useData, boolean shouldMerge, FilterableNodeSupplier nodeSupplier) { + return filterAndMergeNode(embeddedSubProcess, new VariableInfo(actionVarName, actionVarName), fromStateExpr, resultExpr, toStateExpr, useData, shouldMerge, nodeSupplier); + } + protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory embeddedSubProcess, VariableInfo variableInfo, String fromStateExpr, String resultExpr, String toStateExpr, + boolean useData, + boolean shouldMerge, FilterableNodeSupplier nodeSupplier) { + String actionVarName = variableInfo.getOutputVar(); if (isTempVariable(actionVarName)) { embeddedSubProcess.variable(actionVarName, new ObjectDataType(JsonNode.class.getCanonicalName()), Map.of(KogitoTags.VARIABLE_TAGS, KogitoTags.INTERNAL_TAG)); } @@ -451,7 +459,7 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory