fjtirado commented on code in PR #3696:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3696#discussion_r1793094829


##########
kogito-serverless-workflow/kogito-jsonpath-expression/src/main/java/org/kie/kogito/expr/jsonpath/JsonPathExpression.java:
##########
@@ -61,24 +63,28 @@ private Configuration getConfiguration(KogitoProcessContext 
context) {
                 .build();
     }
 
+    private static boolean isContextAware(JsonNode context, Map<String, 
JsonNode> additionalVars) {
+        return !additionalVars.isEmpty() && context instanceof ObjectNode;
+    }
+
     private <T> T eval(JsonNode context, Class<T> returnClass, 
KogitoProcessContext processInfo) {
-        try (JsonNodeContext jsonNode = JsonNodeContext.from(context, 
processInfo)) {
-            Configuration jsonPathConfig = getConfiguration(processInfo);
-            DocumentContext parsedContext = 
JsonPath.using(jsonPathConfig).parse(jsonNode.getNode());
-            if (String.class.isAssignableFrom(returnClass)) {
-                StringBuilder sb = new StringBuilder();
-                // valid json path is $. or $[
-                for (String part : expr.split("((?=\\$\\.|\\$\\[))")) {
-                    JsonNode partResult = parsedContext.read(part, 
JsonNode.class);
-                    sb.append(partResult.isTextual() ? partResult.asText() : 
partResult.toPrettyString());
-                }
-                return (T) sb.toString();
-            } else {
-                Object result = parsedContext.read(expr);
-                return Boolean.class.isAssignableFrom(returnClass) && result 
instanceof ArrayNode ? (T) Boolean.valueOf(!((ArrayNode) result).isEmpty())
-                        : 
JsonObjectUtils.convertValue(jsonPathConfig.mappingProvider().map(result, 
returnClass, jsonPathConfig), returnClass);
+
+        Configuration jsonPathConfig = getConfiguration(processInfo);
+        DocumentContext parsedContext = 
JsonPath.using(jsonPathConfig).parse(context);
+        if (String.class.isAssignableFrom(returnClass)) {
+            StringBuilder sb = new StringBuilder();
+            // valid json path is $. or $[
+            for (String part : expr.split("((?=\\$\\.|\\$\\[))")) {
+                JsonNode partResult = parsedContext.read(part, JsonNode.class);
+                sb.append(partResult.isTextual() ? partResult.asText() : 
partResult.toPrettyString());

Review Comment:
   all this code that got your attention was already there. 
   Its a legacy code intended to make possible to concatenate strings using 
jsonpath (which is otherwise not possilbe), mainly in custom sysout function 
type. 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to