From 23a6e54429d743f363220317b45125357b9a65f8 Mon Sep 17 00:00:00 2001 From: Helber Belmiro Date: Fri, 4 Aug 2023 15:23:23 -0300 Subject: [PATCH] KOGITO-9158 Refactoring KnativeTypeHandler.java Signed-off-by: Helber Belmiro --- .../customfunctions/KnativeTypeHandler.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/quarkus/addons/knative/serving/deployment/src/main/java/org/kie/kogito/addons/quarkus/knative/serving/deployment/customfunctions/KnativeTypeHandler.java b/quarkus/addons/knative/serving/deployment/src/main/java/org/kie/kogito/addons/quarkus/knative/serving/deployment/customfunctions/KnativeTypeHandler.java index 08a2f68b81d..c35e3e78125 100644 --- a/quarkus/addons/knative/serving/deployment/src/main/java/org/kie/kogito/addons/quarkus/knative/serving/deployment/customfunctions/KnativeTypeHandler.java +++ b/quarkus/addons/knative/serving/deployment/src/main/java/org/kie/kogito/addons/quarkus/knative/serving/deployment/customfunctions/KnativeTypeHandler.java @@ -47,19 +47,10 @@ public class KnativeTypeHandler extends WorkItemTypeHandler { RuleFlowNodeContainerFactory embeddedSubProcess, FunctionDefinition functionDef, FunctionRef functionRef, VariableInfo varInfo) { validateArgs(functionRef); - return addFunctionArgs(workflow, - fillWorkItemHandler(buildWorkItem(embeddedSubProcess, context, varInfo.getInputVar(), varInfo.getOutputVar()).name(functionDef.getName()), functionDef, functionRef), - functionRef); - } - @Override - protected > WorkItemNodeFactory fillWorkItemHandler( - Workflow workflow, ParserContext context, WorkItemNodeFactory node, FunctionDefinition functionDef) { - throw new UnsupportedOperationException("This method must never be invoked."); - } + WorkItemNodeFactory node = buildWorkItem(embeddedSubProcess, context, varInfo.getInputVar(), varInfo.getOutputVar()) + .name(functionDef.getName()); - private > WorkItemNodeFactory fillWorkItemHandler( - WorkItemNodeFactory node, FunctionDefinition functionDef, FunctionRef functionRef) { if (functionRef.getArguments() != null && !functionRef.getArguments().isEmpty()) { List payloadFields = new ArrayList<>(); functionRef.getArguments().fieldNames().forEachRemaining(payloadFields::add); @@ -68,6 +59,14 @@ public class KnativeTypeHandler extends WorkItemTypeHandler { } } + return addFunctionArgs(workflow, + fillWorkItemHandler(workflow, context, node, functionDef), + functionRef); + } + + @Override + protected > WorkItemNodeFactory fillWorkItemHandler( + Workflow workflow, ParserContext context, WorkItemNodeFactory node, FunctionDefinition functionDef) { if (functionDef.getMetadata() != null) { functionDef.getMetadata().forEach(node::metaData); }