davsclaus commented on code in PR #28724:
URL: https://github.com/apache/camel/pull/28724#discussion_r4430739347


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/TextBodyFlow.java:
##########
@@ -1625,6 +1692,112 @@ private static Error error(NodePath at, String routeId, 
String read, Text text)
                 .build();
     }
 
+    /** The key of the JSON data in the directory a file consumer reads, or 
null for any other consumer. */
+    private static String directoryKey(String uri, JsonNode from) {
+        if (!"file".equals(scheme(uri))) {
+            return null;
+        }
+        String path = uri.indexOf(':') > 0 ? 
normalize(uri).substring(uri.indexOf(':') + 1) : null;
+        if ((path == null || path.isBlank()) && from != null && 
from.isObject() && from.get("parameters") != null
+                && from.get("parameters").get("directoryName") != null) {
+            path = from.get("parameters").get("directoryName").asText();
+        }
+        return path != null && !path.isBlank() ? 
ProjectFacts.directoryKey(path) : null;
+    }
+
+    /** Remembers the body a step sends to a direct: or seda: endpoint, for 
the route of the file that consumes it. */
+    private static void recordSend(String name, JsonNode value, Body body, 
Walk w) {
+        if (!SENDS_THE_BODY.contains(name) && !"toD".equals(name)) {

Review Comment:
   Fixed in 789a4a9: the guard is now `if (!SENDS_THE_BODY.contains(name))`, 
since the set already has `toD`.
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/ProjectFacts.java:
##########
@@ -68,13 +71,49 @@ public record Observed(List<String> types, List<String> 
kinds) {
     public record KameletDataTypes(String in, String out) {
     }
 
+    /**
+     * The fields of JSON data, as the files of the project have them: the 
keys of its objects (of the elements, for a
+     * list), and of each field that holds a list of objects, the keys of 
those objects. Where says in words where the
+     * data is ("the files in orders/"); outer has the fields of the data an 
element was split from, and is empty
+     * otherwise.
+     */
+    public record JsonFields(String where, Set<String> fields, Map<String, 
Set<String>> elementFields, boolean list,
+            Set<String> outer) {
+
+        public JsonFields {
+            fields = fields != null ? Set.copyOf(fields) : Set.of();
+            elementFields = elementFields != null ? Map.copyOf(elementFields) 
: Map.of();

Review Comment:
   Fixed in 789a4a9: the compact constructor now copies each set too 
(`Collectors.toUnmodifiableMap(Map.Entry::getKey, e -> 
Set.copyOf(e.getValue()))`), so `elementFields().get(key)` can no longer be 
changed by a caller.
   
   _Claude Code on behalf of davsclaus_



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

Reply via email to