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


##########
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 $[

Review Comment:
   The purpose of that regexp is not to eval the expression, but to split it in 
the case of sysout custom fucntion type, because jsonpath does not support 
concatenation. 
   so, you can write $.greeting $.name (as in original greeting example) and 
the jsonpath will evaluate separately, first $.greeting and then $.name
   It does not apply anywhwere else, including foreach that does support nested 
expression as any other expression sensitive construct. 



-- 
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