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 2023/07/24 17:00:30 UTC
[camel] branch main updated: refactor!: remove itemType param in get/collection operation (#10802)
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 9491637fc0a refactor!: remove itemType param in get/collection operation (#10802)
9491637fc0a is described below
commit 9491637fc0a824ac7c9b5f3c5730548f477f5bde
Author: Claude Mamo <82...@users.noreply.github.com>
AuthorDate: Mon Jul 24 19:00:23 2023 +0200
refactor!: remove itemType param in get/collection operation (#10802)
* refactor!: remove itemType param in get/collection operation and instead use `.split().body().unmarshal().json(...)`
* refactor: remove unused import
* fix: commit generated catalog
---
.../org/apache/camel/catalog/components/dhis2.json | 4 +-
components/camel-dhis2/camel-dhis2-api/pom.xml | 5 ++
.../apache/camel/component/dhis2/api/Dhis2Get.java | 20 ++-----
.../component/dhis2/api/ItemTypeConverter.java | 69 ++++++++++++++++++++++
.../component/dhis2/api/Dhis2GetTestCase.java | 6 +-
.../camel-dhis2/camel-dhis2-component/pom.xml | 5 +-
.../component/dhis2/Dhis2EndpointUriFactory.java | 3 +-
.../dhis2/Dhis2GetEndpointConfiguration.java | 13 +---
.../Dhis2GetEndpointConfigurationConfigurer.java | 7 ---
.../dhis2/internal/Dhis2ApiCollection.java | 2 +-
.../dhis2/internal/Dhis2GetApiMethod.java | 3 +-
.../org/apache/camel/component/dhis2/dhis2.json | 4 +-
.../src/main/docs/dhis2-component.adoc | 19 +++---
.../apache/camel/component/dhis2/Dhis2GetIT.java | 8 ++-
components/camel-dhis2/pom.xml | 2 +-
15 files changed, 111 insertions(+), 59 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json
index 7f9597faf1b..d4d90dcfdb5 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json
@@ -63,14 +63,14 @@
},
"apis": {
"delete": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
- "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator collection(String path, String itemType, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, String fields, S [...]
+ "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.io.InputStream collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, String fields, String filter, or [...]
"post": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
"put": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
"resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval)" ] } } }
},
"apiProperties": {
"delete": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java. [...]
- "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...]
+ "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...]
"post": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.ut [...]
"put": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.uti [...]
"resourceTables": { "methods": { "analytics": { "properties": { "interval": { "index": 0, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "lastYears": { "index": 1, "kind": "parameter", "displayName": "Last Years", "group": "common", "label": "", "required": false, "type": "integer", "ja [...]
diff --git a/components/camel-dhis2/camel-dhis2-api/pom.xml b/components/camel-dhis2/camel-dhis2-api/pom.xml
index c9948de5d65..f1ec88a3d6d 100644
--- a/components/camel-dhis2/camel-dhis2-api/pom.xml
+++ b/components/camel-dhis2/camel-dhis2-api/pom.xml
@@ -37,6 +37,11 @@
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-support</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
index 9ccdd50ae0d..0410bca6b8e 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
@@ -17,10 +17,10 @@
package org.apache.camel.component.dhis2.api;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.camel.support.InputStreamIterator;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.hisp.dhis.integration.sdk.api.IterableDhis2Response;
import org.hisp.dhis.integration.sdk.api.operation.GetOperation;
@@ -75,12 +75,11 @@ public class Dhis2Get {
return getOperation;
}
- public <T> Iterator<T> collection(
- String path, String itemType, String arrayName, Boolean paging, String fields, String filter,
+ public InputStream collection(
+ String path, String arrayName, Boolean paging, String fields, String filter,
RootJunctionEnum rootJunction,
Map<String, Object> queryParams) {
GetOperation getOperation = newGetOperation(path, fields, filter, rootJunction, queryParams);
- Iterable<T> iterable;
IterableDhis2Response iteratorDhis2Response;
if (paging == null || paging) {
@@ -89,17 +88,8 @@ public class Dhis2Get {
iteratorDhis2Response = getOperation.withoutPaging().transfer();
}
- if (itemType == null) {
- iterable = (Iterable<T>) iteratorDhis2Response.returnAs(Map.class, arrayName);
- } else {
- try {
- iterable = (Iterable<T>) iteratorDhis2Response.returnAs(Class.forName(itemType), arrayName);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- return iterable.iterator();
+ Iterable<Map> iterable = iteratorDhis2Response.returnAs(Map.class, arrayName);
+ return new InputStreamIterator(new ItemTypeConverter(dhis2Client), iterable.iterator());
}
}
diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java
new file mode 100644
index 00000000000..32a6a16198f
--- /dev/null
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java
@@ -0,0 +1,69 @@
+/*
+ * 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.dhis2.api;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverter;
+import org.hisp.dhis.integration.sdk.api.Dhis2Client;
+
+public class ItemTypeConverter implements TypeConverter {
+
+ private final Dhis2Client dhis2Client;
+
+ public ItemTypeConverter(Dhis2Client dhis2Client) {
+ this.dhis2Client = dhis2Client;
+ }
+
+ @Override
+ public boolean allowNull() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T convertTo(Class<T> type, Object value) throws TypeConversionException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T mandatoryConvertTo(Class<T> type, Object value)
+ throws TypeConversionException, NoTypeConversionAvailableException {
+ return (T) dhis2Client.getConverterFactory().createConverter().convert(value).getBytes();
+ }
+
+ @Override
+ public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value)
+ throws TypeConversionException, NoTypeConversionAvailableException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T tryConvertTo(Class<T> type, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
index 706143d5fe2..0a2e0688099 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
@@ -184,7 +184,7 @@ public class Dhis2GetTestCase {
"https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(), getOperation));
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.collection("bunnies", null, "bunnies", null, null, null, null, Map.of("foo", "bar"));
+ dhis2Get.collection("bunnies", "bunnies", null, null, null, null, Map.of("foo", "bar"));
verify(getOperation, times(1)).withParameter("foo", "bar");
}
@@ -216,7 +216,7 @@ public class Dhis2GetTestCase {
new JacksonConverterFactory(), getOperation));
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.collection("bunnies", null, "bunnies", null, null, null, RootJunctionEnum.OR, null);
+ dhis2Get.collection("bunnies", "bunnies", null, null, null, RootJunctionEnum.OR, null);
verify(getOperation, times(1)).withOrRootJunction();
}
@@ -246,7 +246,7 @@ public class Dhis2GetTestCase {
"https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(), getOperation));
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.collection("bunnies", null, "bunnies", null, null, null, RootJunctionEnum.AND, null);
+ dhis2Get.collection("bunnies", "bunnies", null, null, null, RootJunctionEnum.AND, null);
verify(getOperation, times(1)).withAndRootJunction();
}
}
diff --git a/components/camel-dhis2/camel-dhis2-component/pom.xml b/components/camel-dhis2/camel-dhis2-component/pom.xml
index 81875dbfcd5..3203d9118c5 100644
--- a/components/camel-dhis2/camel-dhis2-component/pom.xml
+++ b/components/camel-dhis2/camel-dhis2-component/pom.xml
@@ -44,6 +44,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jackson</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dhis2-api</artifactId>
@@ -110,7 +114,6 @@
<proxyClass>org.apache.camel.component.dhis2.api.Dhis2Get</proxyClass>
<fromJavasource />
<nullableOptions>
- <nullableOption>itemType</nullableOption>
<nullableOption>paging</nullableOption>
<nullableOption>fields</nullableOption>
<nullableOption>filter</nullableOption>
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
index fa21d0b2950..6883b987744 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
@@ -21,7 +21,7 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component.
private static final Set<String> SECRET_PROPERTY_NAMES;
private static final Set<String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(40);
+ Set<String> props = new HashSet<>(39);
props.add("apiName");
props.add("arrayName");
props.add("backoffErrorThreshold");
@@ -39,7 +39,6 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component.
props.add("inBody");
props.add("initialDelay");
props.add("interval");
- props.add("itemType");
props.add("lastYears");
props.add("lazyStartProducer");
props.add("methodName");
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
index 256b3c7fe06..c6fca4984f8 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
@@ -15,7 +15,7 @@ import org.apache.camel.spi.UriParams;
*/
@ApiParams(apiName = "get",
description = "",
- apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.util.Iterator collection(String path, String itemType, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum ro [...]
+ apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.io.InputStream collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java [...]
@UriParams
@Configurer(extended = true)
public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
@@ -30,9 +30,6 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
private String filter;
@UriParam
@ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection")})
- private String itemType;
- @UriParam
- @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection")})
private Boolean paging;
@UriParam
@ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "collection"), @ApiMethod(methodName = "resource")})
@@ -68,14 +65,6 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
this.filter = filter;
}
- public String getItemType() {
- return itemType;
- }
-
- public void setItemType(String itemType) {
- this.itemType = itemType;
- }
-
public Boolean getPaging() {
return paging;
}
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
index 9670058b051..e11ca4c17b4 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
@@ -26,7 +26,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
map.put("Client", org.hisp.dhis.integration.sdk.api.Dhis2Client.class);
map.put("Fields", java.lang.String.class);
map.put("Filter", java.lang.String.class);
- map.put("ItemType", java.lang.String.class);
map.put("MethodName", java.lang.String.class);
map.put("Paging", java.lang.Boolean.class);
map.put("Password", java.lang.String.class);
@@ -53,8 +52,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Fields": target.setFields(property(camelContext, java.lang.String.class, value)); return true;
case "filter":
case "Filter": target.setFilter(property(camelContext, java.lang.String.class, value)); return true;
- case "itemtype":
- case "ItemType": target.setItemType(property(camelContext, java.lang.String.class, value)); return true;
case "methodname":
case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true;
case "paging":
@@ -93,8 +90,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Fields": return java.lang.String.class;
case "filter":
case "Filter": return java.lang.String.class;
- case "itemtype":
- case "ItemType": return java.lang.String.class;
case "methodname":
case "MethodName": return java.lang.String.class;
case "paging":
@@ -129,8 +124,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Fields": return target.getFields();
case "filter":
case "Filter": return target.getFilter();
- case "itemtype":
- case "ItemType": return target.getItemType();
case "methodname":
case "MethodName": return target.getMethodName();
case "paging":
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
index 61be650c8c8..47a39791123 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
@@ -45,7 +45,7 @@ public final class Dhis2ApiCollection extends ApiCollection<Dhis2ApiName, Dhis2C
apiMethods.put(Dhis2ResourceTablesApiMethod.class, Dhis2ApiName.RESOURCE_TABLES);
aliases.clear();
- nullableArgs = Arrays.asList("itemType", "paging", "fields", "filter", "rootJunction", "queryParams");
+ nullableArgs = Arrays.asList("paging", "fields", "filter", "rootJunction", "queryParams");
apiHelpers.put(Dhis2ApiName.GET, new ApiMethodHelper<>(Dhis2GetApiMethod.class, aliases, nullableArgs));
apiMethods.put(Dhis2GetApiMethod.class, Dhis2ApiName.GET);
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
index c07d20b8896..eba3705f7ca 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
@@ -20,10 +20,9 @@ import static org.apache.camel.support.component.ApiMethodArg.arg;
public enum Dhis2GetApiMethod implements ApiMethod {
COLLECTION(
- java.util.Iterator.class,
+ java.io.InputStream.class,
"collection",
arg("path", String.class),
- arg("itemType", String.class),
arg("arrayName", String.class),
arg("paging", Boolean.class),
arg("fields", String.class),
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
index 7f9597faf1b..d4d90dcfdb5 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
@@ -63,14 +63,14 @@
},
"apis": {
"delete": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
- "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator collection(String path, String itemType, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, String fields, S [...]
+ "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.io.InputStream collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, String fields, String filter, or [...]
"post": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
"put": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
"resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval)" ] } } }
},
"apiProperties": {
"delete": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java. [...]
- "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...]
+ "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...]
"post": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.ut [...]
"put": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.uti [...]
"resourceTables": { "methods": { "analytics": { "properties": { "interval": { "index": 0, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "lastYears": { "index": 1, "kind": "parameter", "displayName": "Last Years", "group": "common", "label": "", "required": false, "type": "integer", "ja [...]
diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
index 45fd301893e..b90930ca418 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
+++ b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
@@ -92,7 +92,7 @@ public class MyRouteBuilder extends RouteBuilder {
Signatures:
-* java.util.Iterator collection(java.lang.String path, java.lang.String itemType, java.lang.Boolean paging, java.lang.String fields, java.lang.String filter, java.util.Map<String, Object> queryParams)
+* java.util.Iterator collection(java.lang.String path, java.lang.Boolean paging, java.lang.String fields, java.lang.String filter, java.util.Map<String, Object> queryParams)
The get/collection API method has the parameters listed in the table below:
@@ -100,7 +100,6 @@ The get/collection API method has the parameters listed in the table below:
|===
| Parameter | Description | Type
| path | Resource URL path | String
-| itemType | Fully-qualified Java class name to deserialise items into| String
| arrayName | JSON property name holding the array to read | String
| paging | Turn paging on/off | Boolean
| fields | Comma-delimited list of fields to fetch | String
@@ -122,8 +121,8 @@ public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("direct:getCollection")
- .to("dhis2://get/collection?path=organisationUnits&itemType=org.hisp.dhis.api.model.v2_39_1.OrganisationUnit&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
- .split().body().log("${body}");
+ .to("dhis2://get/collection?path=organisationUnits&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
+ .split().body().unmarshal().json(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class).log("${body}");
}
}
----
@@ -140,8 +139,10 @@ public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("direct:getCollection")
- .to("dhis2://get/collection?path=organisationUnits&fields=code&itemType=org.hisp.dhis.api.model.v2_39_1.OrganisationUnit&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
- .split().body().log("${body}");
+ .to("dhis2://get/collection?path=organisationUnits&fields=code&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
+ .split().body()
+ .unmarshal().json(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class)
+ .log("${body}");
}
}
----
@@ -158,8 +159,10 @@ public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("direct:getCollection")
- .to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&itemType=org.hisp.dhis.api.model.v2_39_1.User&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
- .split().body().log("${body}");
+ .to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
+ .split().body()
+ .unmarshal().json(org.hisp.dhis.api.model.v2_39_1.User.class)
+ .log("${body}");
}
}
----
diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
index 32da52ce2f9..6870dc21718 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
@@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection;
import org.apache.camel.component.dhis2.internal.Dhis2GetApiMethod;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,14 +44,13 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
public void testCollection() throws Exception {
final Map<String, Object> headers = new HashMap<String, Object>();
headers.put("CamelDhis2.path", "organisationUnits");
- headers.put("CamelDhis2.itemType", "org.hisp.dhis.api.model.v2_39_1.OrganisationUnit");
headers.put("CamelDhis2.arrayName", "organisationUnits");
headers.put("CamelDhis2.paging", true);
headers.put("CamelDhis2.fields", null);
headers.put("CamelDhis2.filter", null);
headers.put("CamelDhis2.queryParams", new HashMap<>());
- final java.util.Iterator result = requestBodyAndHeaders("direct://COLLECTION", null, headers);
+ final Object result = requestBodyAndHeaders("direct://COLLECTION", null, headers);
assertNotNull(result, "collection result");
LOG.debug("collection: {}", result);
@@ -76,7 +76,9 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
public void configure() {
// test route for collection
from("direct://COLLECTION")
- .to("dhis2://" + PATH_PREFIX + "/collection");
+ .to("dhis2://" + PATH_PREFIX + "/collection").split().body()
+ .unmarshal()
+ .json(OrganisationUnit.class);
// test route for resource
from("direct://RESOURCE")
diff --git a/components/camel-dhis2/pom.xml b/components/camel-dhis2/pom.xml
index 5347584413a..1de9dd1a005 100644
--- a/components/camel-dhis2/pom.xml
+++ b/components/camel-dhis2/pom.xml
@@ -34,7 +34,7 @@
<description>Camel DHIS2 Component</description>
<properties>
- <dhis2-java-sdk.version>2.0.0</dhis2-java-sdk.version>
+ <dhis2-java-sdk.version>2.1.0</dhis2-java-sdk.version>
<!-- DHIS2 container is not available on these platforms -->
<skipITs.ppc64le>true</skipITs.ppc64le>