You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/20 10:23:56 UTC
(camel) branch main updated: CAMEL-17641: Generate json metadata for pojo beans in camel-core that end users can use such as AggregationStrategy implementations. And have that information in camel-catalog for tooling assistance.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 2ba94c08df1 CAMEL-17641: Generate json metadata for pojo beans in camel-core that end users can use such as AggregationStrategy implementations. And have that information in camel-catalog for tooling assistance.
2ba94c08df1 is described below
commit 2ba94c08df132541f3a53ff5a8b1efd03b516140
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 20 11:23:44 2024 +0100
CAMEL-17641: Generate json metadata for pojo beans in camel-core that end users can use such as AggregationStrategy implementations. And have that information in camel-catalog for tooling assistance.
---
.../beans/CassandraIdempotentRepository.json | 2 +-
.../org/apache/camel/catalog/CamelCatalogTest.java | 2 +-
.../CassandraIdempotentRepositoryConfigurer.java | 10 ++---
.../camel/bean/CassandraIdempotentRepository.json | 2 +-
.../cassandra/CassandraIdempotentRepository.java | 44 ++++++++++------------
.../NamedCassandraIdempotentRepository.java | 8 ++--
6 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/CassandraIdempotentRepository.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/CassandraIdempotentRepository.json
index 78269b7e649..abab9ac67b7 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/CassandraIdempotentRepository.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/CassandraIdempotentRepository.json
@@ -10,7 +10,7 @@
"groupId": "org.apache.camel",
"artifactId": "camel-cassandraql",
"version": "4.5.0-SNAPSHOT",
- "properties": { "session": { "index": 0, "kind": "property", "displayName": "Session", "required": true, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "description": "Cassandra session" }, "table": { "index": 1, "kind": "property", "displayName": "Table", "required": false, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraId [...]
+ "properties": { "session": { "index": 0, "kind": "property", "displayName": "Session", "required": true, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "description": "Cassandra session" }, "table": { "index": 1, "kind": "property", "displayName": "Table", "required": false, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraId [...]
}
}
diff --git a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 05740bbacb7..9aa8a3be5f0 100644
--- a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -1647,7 +1647,7 @@ public class CamelCatalogTest {
PojoBeanModel model = catalog.pojoBeanModel("ZipAggregationStrategy");
assertNotNull(model);
- assertEquals("bean", model.getKind());
+ assertEquals(Kind.bean, model.getKind());
assertEquals("ZipAggregationStrategy", model.getName());
assertEquals("org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy", model.getJavaType());
assertEquals(6, model.getOptions().size());
diff --git a/components/camel-cassandraql/src/generated/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryConfigurer.java b/components/camel-cassandraql/src/generated/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryConfigurer.java
index a775cce13b5..bdf047cb598 100644
--- a/components/camel-cassandraql/src/generated/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryConfigurer.java
+++ b/components/camel-cassandraql/src/generated/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryConfigurer.java
@@ -22,9 +22,9 @@ public class CassandraIdempotentRepositoryConfigurer extends org.apache.camel.su
org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository target = (org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "pkcolumns":
- case "PKColumns": target.setPKColumns(property(camelContext, java.lang.String.class, value)); return true;
+ case "PkColumns": target.setPkColumns(property(camelContext, java.lang.String.class, value)); return true;
case "prefixpkvalues":
- case "PrefixPKValues": target.setPrefixPKValues(property(camelContext, java.lang.String[].class, value)); return true;
+ case "PrefixPKValues": target.setPrefixPKValues(property(camelContext, java.lang.String.class, value)); return true;
case "readconsistencylevel":
case "ReadConsistencyLevel": target.setReadConsistencyLevel(property(camelContext, com.datastax.oss.driver.api.core.ConsistencyLevel.class, value)); return true;
case "session":
@@ -43,9 +43,9 @@ public class CassandraIdempotentRepositoryConfigurer extends org.apache.camel.su
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "pkcolumns":
- case "PKColumns": return java.lang.String.class;
+ case "PkColumns": return java.lang.String.class;
case "prefixpkvalues":
- case "PrefixPKValues": return java.lang.String[].class;
+ case "PrefixPKValues": return java.lang.String.class;
case "readconsistencylevel":
case "ReadConsistencyLevel": return com.datastax.oss.driver.api.core.ConsistencyLevel.class;
case "session":
@@ -65,7 +65,7 @@ public class CassandraIdempotentRepositoryConfigurer extends org.apache.camel.su
org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository target = (org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "pkcolumns":
- case "PKColumns": return target.getPKColumns();
+ case "PkColumns": return target.getPkColumns();
case "prefixpkvalues":
case "PrefixPKValues": return target.getPrefixPKValues();
case "readconsistencylevel":
diff --git a/components/camel-cassandraql/src/generated/resources/META-INF/services/org/apache/camel/bean/CassandraIdempotentRepository.json b/components/camel-cassandraql/src/generated/resources/META-INF/services/org/apache/camel/bean/CassandraIdempotentRepository.json
index 78269b7e649..abab9ac67b7 100644
--- a/components/camel-cassandraql/src/generated/resources/META-INF/services/org/apache/camel/bean/CassandraIdempotentRepository.json
+++ b/components/camel-cassandraql/src/generated/resources/META-INF/services/org/apache/camel/bean/CassandraIdempotentRepository.json
@@ -10,7 +10,7 @@
"groupId": "org.apache.camel",
"artifactId": "camel-cassandraql",
"version": "4.5.0-SNAPSHOT",
- "properties": { "session": { "index": 0, "kind": "property", "displayName": "Session", "required": true, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "description": "Cassandra session" }, "table": { "index": 1, "kind": "property", "displayName": "Table", "required": false, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraId [...]
+ "properties": { "session": { "index": 0, "kind": "property", "displayName": "Session", "required": true, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraIdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "description": "Cassandra session" }, "table": { "index": 1, "kind": "property", "displayName": "Table", "required": false, "type": "object", "javaType": "org.apache.camel.processor.idempotent.cassandra.CassandraId [...]
}
}
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
index c66d4d7a8dd..ede41ff3113 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
@@ -61,12 +61,12 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
@Metadata(description = "The table name for storing the data", defaultValue = "CAMEL_IDEMPOTENT")
private String table = "CAMEL_IDEMPOTENT";
@Metadata(description = "Values used as primary key prefix. Multiple values can be separated by comma.",
- displayName = "Prefix Primary Key Values", javaType = "java.lang.String")
- private String[] prefixPKValues = new String[0];
+ displayName = "Prefix Primary Key Values")
+ private String prefixPKValues;
@Metadata(description = "Primary key columns. Multiple values can be separated by comma.",
displayName = "Primary Key Columns",
javaType = "java.lang.String", defaultValue = "KEY")
- private String[] pkColumns = { "KEY" };
+ private String pkColumns = "KEY";
@Metadata(description = "Time to live in seconds used for inserts", displayName = "Time to Live")
private Integer ttl;
@Metadata(description = "Write consistency level",
@@ -95,7 +95,8 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
return false;
} else {
LOGGER.debug("Row with {} columns to check key", row.getColumnDefinitions());
- return row.getColumnDefinitions().size() >= pkColumns.length;
+ int len = pkColumns.split(",").length;
+ return row.getColumnDefinitions().size() >= len;
}
}
@@ -105,7 +106,11 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
}
protected Object[] getPKValues(String key) {
- return append(prefixPKValues, key);
+ if (prefixPKValues != null) {
+ return append(prefixPKValues.split(","), key);
+ } else {
+ return new Object[] { key };
+ }
}
// -------------------------------------------------------------------------
// Lifecycle methods
@@ -130,7 +135,7 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
// Add key to repository
protected void initInsertStatement() {
- Insert insert = generateInsert(table, pkColumns, true, ttl);
+ Insert insert = generateInsert(table, pkColumns.split(","), true, ttl);
SimpleStatement statement = applyConsistencyLevel(insert.build(), writeConsistencyLevel);
LOGGER.debug("Generated Insert {}", statement);
insertStatement = getSession().prepare(statement);
@@ -147,7 +152,7 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
// Check if key is in repository
protected void initSelectStatement() {
- Select select = generateSelect(table, pkColumns, pkColumns);
+ Select select = generateSelect(table, pkColumns.split(","), pkColumns.split(","));
SimpleStatement statement = applyConsistencyLevel(select.build(), readConsistencyLevel);
LOGGER.debug("Generated Select {}", statement);
selectStatement = getSession().prepare(statement);
@@ -169,7 +174,7 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
// Remove key from repository
protected void initDeleteStatement() {
- Delete delete = generateDelete(table, pkColumns, true);
+ Delete delete = generateDelete(table, pkColumns.split(","), true);
SimpleStatement statement = applyConsistencyLevel(delete.build(), writeConsistencyLevel);
LOGGER.debug("Generated Delete {}", statement);
deleteStatement = getSession().prepare(statement);
@@ -217,18 +222,6 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
this.table = table;
}
- public String[] getPKColumns() {
- return pkColumns;
- }
-
- public void setPKColumns(String... pkColumns) {
- this.pkColumns = pkColumns;
- }
-
- public void setPKColumns(String value) {
- this.pkColumns = value.split(",");
- }
-
public Integer getTtl() {
return ttl;
}
@@ -253,16 +246,19 @@ public class CassandraIdempotentRepository extends ServiceSupport implements Ide
this.readConsistencyLevel = readConsistencyLevel;
}
- public String[] getPrefixPKValues() {
+ public String getPrefixPKValues() {
return prefixPKValues;
}
- public void setPrefixPKValues(String[] prefixPKValues) {
+ public void setPrefixPKValues(String prefixPKValues) {
this.prefixPKValues = prefixPKValues;
}
- public void setPrefixPKValues(String values) {
- this.prefixPKValues = values.split(",");
+ public String getPkColumns() {
+ return pkColumns;
}
+ public void setPkColumns(String pkColumns) {
+ this.pkColumns = pkColumns;
+ }
}
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
index 451c1e348b5..dfe42be15a5 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
@@ -25,22 +25,22 @@ import com.datastax.oss.driver.api.core.CqlSession;
public class NamedCassandraIdempotentRepository extends CassandraIdempotentRepository {
public NamedCassandraIdempotentRepository() {
- setPKColumns("NAME", "KEY");
+ setPkColumns("NAME,KEY");
setName("DEFAULT");
}
public NamedCassandraIdempotentRepository(CqlSession session, String name) {
super(session);
- setPKColumns("NAME", "KEY");
+ setPkColumns("NAME,KEY");
setName(name);
}
public String getName() {
- return getPrefixPKValues()[0];
+ return getPrefixPKValues().split(",")[0];
}
public final void setName(String name) {
- setPrefixPKValues(new String[] { name });
+ setPrefixPKValues(name);
}
}