You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/01/07 13:40:54 UTC

[GitHub] [camel-kamelets] oscerd opened a new pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

oscerd opened a new pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681


   Fixes #677 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780364632



##########
File path: kamelets/extract-field-action.kamelet.yaml
##########
@@ -29,14 +29,30 @@ metadata:
 spec:
   definition:
     title: "Extract Field Action"
-    description: "Extract a field from the body"
+    description: |-
+      Extract a field from the message body.
+
+      The extract field action expected an application/json content type. 
+
+      The field parameter allows to specify which field of the json the user wants to extract. By default the message body will be overriden with the extracted field.

Review comment:
       The field parameter allows you to ...




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780373734



##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Also this is a bean that should be simple as simple. I troducing more logic to check stuff like headers existence is too much, there is for example the has header action or you can write your own kamelet action doing all the logic you want. But I'd probably leave the beans simplest as possible.




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd merged pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd merged pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681


   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007551335


   I don't understand - you seem to think I'm attacking you.  Nothing could be farther from the truth.
   
   You want community involvement but every time a question, suggestion or involvement is offered, you're offended.
   
   If you don't like my suggestions/questions that's fine.  But I'm trying to keep this conversation from devolving into something inappropriate for public discourse on an open source project.  I truly am interested in a dialog about improving this for myself and others.
   
   The issue tool is intended to allow public discussion and debate as well as to get ideas circulated that improves the product for all.  Some ideas are great and some not so great. Maybe my suggestions don't align with the intended product direction. 
   
   Remember that the only people willing to spend any time at all writing issues and commenting have a vested interest in seeing this project succeed for everyone.  Attacking people that raise issues with what has been produced as open source is counter productive to the open source ideals and serves only to push people away.
   
   If this is not the venue by which we community members make suggestions, then what is?


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007537311


   I'm starting to be a bit bored by the way you're going through this stuff. Maybe someone else will want to help you. Have a nice weekend


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780368069



##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       As per my comments in the issue, maybe this is better in line 38?
   
   ex.getMessage.setHeader(sanitized(headerOutput), body.get(field));
   
   Where ```String sanitized(String headerOutput)``` does its best to ensure a valid headerName that does not collide with existing headers.




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007551335


   I don't understand - you seem to think I'm attacking you.  Nothing could be farther from the truth.
   
   You want community involvement but every time a question, suggestion or involvement is offered, you're offended.
   
   If you don't like my suggestions/questions that's fine.  But I'm trying to keep this conversation from devolving into something inappropriate for public discourse on an open source project.  I truly am interested in a dialog about improving this for myself and others.
   
   The issue tool is intended to allow public discussion and debate as well as to get ideas circulated that improves the product for all.  Some ideas are great and some not so great. Maybe my suggestions don't align with the intended product direction. 
   
   Remember that the only people willing to spend any time at all writing issues and commenting have a vested interest in seeing this project succeed for everyone.  Attacking people that raise issues with what has been produced as open source is counter productive to the open source ideals and serves only to push people away.
   
   If this is not the venue by which we community members make suggestions, then what is?


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780373734



##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Also this is a bean that should be simple. Introducing more logic to check stuff like headers existence is too much, there is for example the has header action or you can write your own kamelet action doing all the logic you want. But I'd probably leave the beans simplest as possible. 




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780369042



##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Header output is a boolean. The header name is static and fixed. So, no.




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007416349


   Related to #673 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007416349






-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780369042



##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Header output is a boolean. The header name is static and fixed. So, no.

##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Also this is a bean that should be simple as simple. I troducing more logic to check stuff like headers existence is too much, there is for example the has header action or you can write your own kamelet action doing all the logic you want. But I'd probably leave the beans simplest as possible.

##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       Also this is a bean that should be simple. Introducing more logic to check stuff like headers existence is too much, there is for example the has header action or you can write your own kamelet action doing all the logic you want. But I'd probably leave the beans simplest as possible. 




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1008016738


   I found some time to answer now with a bit more lucidity than yesterday. I answered on the issue related to ES Index Sink Kamelet. Hope this clarifies some stuff, but lets continue the discussion there. Cheers.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780363207



##########
File path: kamelets/extract-field-action.kamelet.yaml
##########
@@ -29,14 +29,30 @@ metadata:
 spec:
   definition:
     title: "Extract Field Action"
-    description: "Extract a field from the body"
+    description: |-
+      Extract a field from the message body.
+
+      The extract field action expected an application/json content type. 

Review comment:
       The extract field action expects an application/json content 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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] ReggieCarey commented on a change in pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
ReggieCarey commented on a change in pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#discussion_r780363207



##########
File path: kamelets/extract-field-action.kamelet.yaml
##########
@@ -29,14 +29,30 @@ metadata:
 spec:
   definition:
     title: "Extract Field Action"
-    description: "Extract a field from the body"
+    description: |-
+      Extract a field from the message body.
+
+      The extract field action expected an application/json content type. 

Review comment:
       The extract field action expects an application/json content type.

##########
File path: kamelets/extract-field-action.kamelet.yaml
##########
@@ -29,14 +29,30 @@ metadata:
 spec:
   definition:
     title: "Extract Field Action"
-    description: "Extract a field from the body"
+    description: |-
+      Extract a field from the message body.
+
+      The extract field action expected an application/json content type. 
+
+      The field parameter allows to specify which field of the json the user wants to extract. By default the message body will be overriden with the extracted field.

Review comment:
       The field parameter allows you to ...

##########
File path: library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java
##########
@@ -27,11 +27,16 @@
 
 public class ExtractField {
 
-    public void process(@ExchangeProperty("field") String field, Exchange ex) {
+    public void process(@ExchangeProperty("field") String field, @ExchangeProperty("headerOutput") boolean headerOutput, Exchange ex) {
+        final String EXTRACTED_FIELD_HEADER = "CamelKameletsExtractFieldName";
         ObjectMapper mapper = new ObjectMapper();
         JsonNode jsonNodeBody = ex.getMessage().getBody(JsonNode.class);
         Map<Object, Object> body = mapper.convertValue(jsonNodeBody, new TypeReference<Map<Object, Object>>(){});
-        ex.getMessage().setBody(body.get(field));
+        if (!headerOutput) {
+            ex.getMessage().setBody(body.get(field));
+        } else {
+            ex.getMessage().setHeader(EXTRACTED_FIELD_HEADER, body.get(field));

Review comment:
       As per my comments in the issue, maybe this is better in line 38?
   
   ex.getMessage.setHeader(sanitized(headerOutput), body.get(field));
   
   Where ```String sanitized(String headerOutput)``` does its best to ensure a valid headerName that does not collide with existing headers.




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd commented on pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681#issuecomment-1007556097


   I don't discuss the where, or the issue, I'm discussing the way. But it might be it's just me.
   You and anyone else are always welcome to discuss and open issues. Probably i was already upset by all the reksted discussion from yesterday and I'm still upset, but not with you in particular. 
   
   By the way let's have another discussiin after the weekend. Thanks for the suggestions and for the help.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-kamelets] oscerd merged pull request #681: Extract Field Action: Make it possible to set if the extracted field should be in the body or in a particular header

Posted by GitBox <gi...@apache.org>.
oscerd merged pull request #681:
URL: https://github.com/apache/camel-kamelets/pull/681


   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org