This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 825087e749a82bfce522a640f73b998198f38ad7
Author: Nicolas Filotto <[email protected]>
AuthorDate: Mon Mar 21 11:44:16 2022 +0100

    CAMEL-17792: Add doc about the message headers of camel-elsql
---
 .../org/apache/camel/component/elsql/elsql.json    |  4 +++
 .../camel-elsql/src/main/docs/elsql-component.adoc | 20 ++----------
 .../camel/component/elsql/ElsqlConstants.java      | 36 ++++++++++++++++++++++
 .../camel/component/elsql/ElsqlEndpoint.java       |  2 +-
 .../camel/component/elsql/ElsqlProducer.java       | 11 +++----
 5 files changed, 49 insertions(+), 24 deletions(-)

diff --git 
a/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json
 
b/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json
index 2cd8f7b..0b52072 100644
--- 
a/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json
+++ 
b/components/camel-elsql/src/generated/resources/org/apache/camel/component/elsql/elsql.json
@@ -30,6 +30,10 @@
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired 
Enabled", "group": "advanced", "label": "advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether autowiring is 
enabled. This is used for automatic autowiring options (the option must be 
marked as autowired) by looking up in the registry to find if there is a single 
instance of matching type, which t [...]
     "elSqlConfig": { "kind": "property", "displayName": "El Sql Config", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "com.opengamma.elsql.ElSqlConfig", "deprecated": false, 
"autowired": false, "secret": false, "description": "To use a specific 
configured ElSqlConfig. It may be better to use the databaseVendor option 
instead." }
   },
+  "headers": {
+    "CamelSqlUpdateCount": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "Integer", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The number of rows updated for `update` operations, returned as 
an\n`Integer` object." },
+    "CamelSqlRowCount": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "Integer", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The number of rows returned for `select` operations, returned 
as an\n`Integer` object." }
+  },
   "properties": {
     "elsqlName": { "kind": "path", "displayName": "Elsql Name", "group": 
"common", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The name of the elsql to use (is NAMED 
in the elsql file)" },
     "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": 
"common", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The resource file which contains the elsql SQL statements to 
use. You can specify multiple resources separated by comma. The resources are 
loaded on the classpath by default, you can prefix with file: to load from file 
system. Notice you can set thi [...]
diff --git a/components/camel-elsql/src/main/docs/elsql-component.adoc 
b/components/camel-elsql/src/main/docs/elsql-component.adoc
index 045fcb3..853587a 100644
--- a/components/camel-elsql/src/main/docs/elsql-component.adoc
+++ b/components/camel-elsql/src/main/docs/elsql-component.adoc
@@ -71,7 +71,9 @@ include::partial$component-endpoint-options.adoc[]
 // endpoint options: START
 
 // endpoint options: END
-
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Result of the query
 
@@ -87,22 +89,6 @@ headers, it provides a concise syntax for querying a 
sequence or some
 other small value into a header.  It is convenient to use outputHeader
 and outputType together:
 
-== Header values
-
-When performing `update` operations, the SQL Component stores the update
-count in the following message headers:
-
-[width="100%",cols="10%,90%",options="header",]
-|===
-|Header |Description
-
-|`CamelSqlUpdateCount` |The number of rows updated for `update` operations, 
returned as an
-`Integer` object.
-
-|`CamelSqlRowCount` |The number of rows returned for `select` operations, 
returned as an
-`Integer` object.
-|===
-
 === Sample
 
 In the given route below, we want to get all the projects from the
diff --git 
a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java
 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java
new file mode 100644
index 0000000..4b55d49
--- /dev/null
+++ 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlConstants.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.elsql;
+
+import org.apache.camel.component.sql.SqlConstants;
+import org.apache.camel.spi.Metadata;
+
+public final class ElsqlConstants {
+
+    @Metadata(label = "producer", description = "The number of rows updated 
for `update` operations, returned as an\n" +
+                            "`Integer` object.",
+              javaType = "Integer")
+    public static final String SQL_UPDATE_COUNT = 
SqlConstants.SQL_UPDATE_COUNT;
+    @Metadata(label = "producer", description = "The number of rows returned 
for `select` operations, returned as an\n" +
+                            "`Integer` object.",
+              javaType = "Integer")
+    public static final String SQL_ROW_COUNT = SqlConstants.SQL_ROW_COUNT;
+
+    private ElsqlConstants() {
+        // Utility class
+    }
+}
diff --git 
a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
index cc69d26..89b3846 100644
--- 
a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
+++ 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
@@ -49,7 +49,7 @@ import 
org.springframework.jdbc.core.namedparam.SqlParameterSource;
  * Use ElSql to define SQL queries. Extends the SQL Component.
  */
 @UriEndpoint(firstVersion = "2.16.0", scheme = "elsql", title = "ElSQL", 
syntax = "elsql:elsqlName:resourceUri",
-             category = { Category.DATABASE, Category.SQL })
+             category = { Category.DATABASE, Category.SQL }, headersClass = 
ElsqlConstants.class)
 public class ElsqlEndpoint extends DefaultSqlEndpoint {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(ElsqlEndpoint.class);
diff --git 
a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java
 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java
index 9901a3b..2a2fd1b 100644
--- 
a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java
+++ 
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlProducer.java
@@ -33,7 +33,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExtendedExchange;
 import org.apache.camel.component.sql.ResultSetIterator;
 import org.apache.camel.component.sql.ResultSetIteratorCompletion;
-import org.apache.camel.component.sql.SqlConstants;
 import org.apache.camel.component.sql.SqlOutputType;
 import org.apache.camel.component.sql.SqlPrepareStatementStrategy;
 import org.apache.camel.support.DefaultProducer;
@@ -131,7 +130,7 @@ public class ElsqlProducer extends DefaultProducer {
                         for (final int count : updateCounts) {
                             total += count;
                         }
-                        
exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, total);
+                        
exchange.getIn().setHeader(ElsqlConstants.SQL_UPDATE_COUNT, total);
                     } else {
                         isResultSet = ps.execute();
                         if (isResultSet) {
@@ -153,7 +152,7 @@ public class ElsqlProducer extends DefaultProducer {
                                 } else {
                                     exchange.getOut().setBody(data);
                                 }
-                                
exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, data.size());
+                                
exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, data.size());
                             } else if (outputType == SqlOutputType.SelectOne) {
                                 final Object data = 
getEndpoint().queryForObject(rs);
                                 if (data != null) {
@@ -166,14 +165,14 @@ public class ElsqlProducer extends DefaultProducer {
                                     } else {
                                         exchange.getOut().setBody(data);
                                     }
-                                    
exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 1);
+                                    
exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, 1);
                                 } else {
                                     if (getEndpoint().isNoop()) {
                                         
exchange.getOut().setBody(exchange.getIn().getBody());
                                     } else if (getEndpoint().getOutputHeader() 
!= null) {
                                         
exchange.getOut().setBody(exchange.getIn().getBody());
                                     }
-                                    
exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 0);
+                                    
exchange.getOut().setHeader(ElsqlConstants.SQL_ROW_COUNT, 0);
                                 }
                             } else {
                                 throw new IllegalArgumentException("Invalid 
outputType=" + outputType);
@@ -181,7 +180,7 @@ public class ElsqlProducer extends DefaultProducer {
                         } else {
                             // if we are here, there isResultSet is false. 
This can happen only if we are doing an update operation or there is no result.
                             // we can simply add the updateCount in this case.
-                            
exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, ps.getUpdateCount());
+                            
exchange.getIn().setHeader(ElsqlConstants.SQL_UPDATE_COUNT, 
ps.getUpdateCount());
                         }
                     }
                 } finally {

Reply via email to