diff --git a/e2e/pom.xml b/e2e/pom.xml
index 59c20fbc..8484912e 100644
--- a/e2e/pom.xml
+++ b/e2e/pom.xml
@@ -4,7 +4,7 @@
io.github.zenwave360.zenwave-sdk
zenwave-sdk
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
${project.groupId}:${project.artifactId}
e2e
diff --git a/e2e/src/test/resources/projects/customer-address-relational/pom.xml b/e2e/src/test/resources/projects/customer-address-relational/pom.xml
index ea36ca86..7a41624d 100644
--- a/e2e/src/test/resources/projects/customer-address-relational/pom.xml
+++ b/e2e/src/test/resources/projects/customer-address-relational/pom.xml
@@ -194,7 +194,7 @@
jsonschema2pojo
- io.zenwave360.example.core.domain.events
+ io.zenwave360.example.core.outbound.events.dtos
true
true
@@ -214,7 +214,7 @@
provider
- io.zenwave360.example.core.domain.events
+ io.zenwave360.example.core.outbound.events.dtos
io.zenwave360.example.core.outbound.events
io.zenwave360.example.adapters.commands
diff --git a/e2e/src/test/resources/projects/online-food-delivery-mongo/models/delivery.zdl b/e2e/src/test/resources/projects/online-food-delivery-mongo/models/delivery.zdl
index d2471f40..147db4b1 100644
--- a/e2e/src/test/resources/projects/online-food-delivery-mongo/models/delivery.zdl
+++ b/e2e/src/test/resources/projects/online-food-delivery-mongo/models/delivery.zdl
@@ -61,9 +61,25 @@ apis {
}
}
+// == Aggregates =============================
+
+/**
+ * Delivery Aggregate
+ */
+aggregate DeliveryAggregate (Delivery) {
+
+ createDelivery(DeliveryInput) withEvents DeliveryStatusUpdated
+
+ onOrderStatusUpdated(OrderStatusUpdated) withEvents DeliveryStatusUpdated
+
+ updateDeliveryStatus(DeliveryStatusInput) withEvents DeliveryStatusUpdated
+
+}
+
+
// == Entities =============================
-@aggregate
+//@aggregate
entity Delivery {
orderId String required
customer Customer {
@@ -120,7 +136,7 @@ input DeliveryStatusInput {
}
@rest("/delivery")
-service DeliveryService for (Delivery) {
+service DeliveryService for (DeliveryAggregate) {
@asyncapi({api: OrdersAsyncAPI, channel: "OrderCreatedChannel"})
createDelivery(DeliveryInput) Delivery withEvents DeliveryStatusUpdated
diff --git a/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml b/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml
index 6920bea0..64317650 100644
--- a/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml
+++ b/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml
@@ -80,7 +80,7 @@
${project.basedir}/src/main/resources/apis/asyncapi.yml
jsonschema2pojo
- ${basePackage}.core.domain.events
+ ${basePackage}.core.outbound.events.dtos
true
true
@@ -97,7 +97,7 @@
${project.basedir}/src/main/resources/apis/asyncapi.yml
provider
- ${basePackage}.core.domain.events
+ ${basePackage}.core.outbound.events.dtos
${basePackage}.core.outbound.events
${basePackage}.adapters.commands
diff --git a/plugins/asyncapi-jsonschema2pojo/pom.xml b/plugins/asyncapi-jsonschema2pojo/pom.xml
index 0c2e7f25..bb72b8cc 100644
--- a/plugins/asyncapi-jsonschema2pojo/pom.xml
+++ b/plugins/asyncapi-jsonschema2pojo/pom.xml
@@ -4,7 +4,7 @@
io.github.zenwave360.zenwave-sdk
plugins-parent
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
${project.groupId}:${project.artifactId}
io.github.zenwave360.zenwave-sdk.plugins
diff --git a/plugins/asyncapi-spring-cloud-streams3/pom.xml b/plugins/asyncapi-spring-cloud-streams3/pom.xml
index 2710f28c..6767132c 100644
--- a/plugins/asyncapi-spring-cloud-streams3/pom.xml
+++ b/plugins/asyncapi-spring-cloud-streams3/pom.xml
@@ -4,7 +4,7 @@
io.github.zenwave360.zenwave-sdk
plugins-parent
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
${project.groupId}:${project.artifactId}
io.github.zenwave360.zenwave-sdk.plugins
diff --git a/plugins/asyncapi-spring-cloud-streams3/src/main/resources/io/zenwave360/sdk/plugins/SpringCloudStream3Generator/producer/mocks/EventsProducerInMemoryContext.java.hbs b/plugins/asyncapi-spring-cloud-streams3/src/main/resources/io/zenwave360/sdk/plugins/SpringCloudStream3Generator/producer/mocks/EventsProducerInMemoryContext.java.hbs
index fb38c8ed..3d4a71ee 100644
--- a/plugins/asyncapi-spring-cloud-streams3/src/main/resources/io/zenwave360/sdk/plugins/SpringCloudStream3Generator/producer/mocks/EventsProducerInMemoryContext.java.hbs
+++ b/plugins/asyncapi-spring-cloud-streams3/src/main/resources/io/zenwave360/sdk/plugins/SpringCloudStream3Generator/producer/mocks/EventsProducerInMemoryContext.java.hbs
@@ -6,8 +6,8 @@ public class EventsProducerInMemoryContext {
{{#each services as |service|}}
private {{service.apiClassName}}Captor {{asInstanceName service.apiClassName}}Captor = new {{service.apiClassName}}Captor();
- public T {{asInstanceName service.apiClassName}}() {
- return (T) {{asInstanceName service.apiClassName}}Captor;
+ public {{service.apiClassName}}Captor {{asInstanceName service.apiClassName}}() {
+ return {{asInstanceName service.apiClassName}}Captor;
}
{{/each}}
}
diff --git a/plugins/backend-application-default/pom.xml b/plugins/backend-application-default/pom.xml
index e293ac90..9827c189 100644
--- a/plugins/backend-application-default/pom.xml
+++ b/plugins/backend-application-default/pom.xml
@@ -4,7 +4,7 @@
io.github.zenwave360.zenwave-sdk
plugins-parent
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
${project.groupId}:${project.artifactId}
io.github.zenwave360.zenwave-sdk.plugins
diff --git a/plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationDefaultHelpers.java b/plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationDefaultHelpers.java
index c9be63e6..5db1fada 100644
--- a/plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationDefaultHelpers.java
+++ b/plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationDefaultHelpers.java
@@ -2,12 +2,11 @@
import java.util.*;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import io.zenwave360.sdk.utils.NamingUtils;
import io.zenwave360.sdk.zdl.ZDLFindUtils;
-import io.zenwave360.sdk.zdl.ZDLHttpUtils;
import io.zenwave360.sdk.zdl.ZDLJavaSignatureUtils;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import com.github.jknack.handlebars.Options;
@@ -26,6 +25,50 @@ public class BackendApplicationDefaultHelpers {
this.generator = generator;
}
+ public String logMethodCall(Map method, Options options) {
+ var zdl = options.get("zdl");
+ var methodName = (String) method.get("name");
+ var parameters = ZDLJavaSignatureUtils.methodParametersCallSignature(method, (Map) zdl, generator.inputDTOSuffix);
+ var parameterPlaceHolders = Arrays.stream(parameters.split(", ")).map(p -> "{}").collect(Collectors.joining(" "));
+ if(parameters.isEmpty()) {
+ return String.format("log.debug(\"Request %s\");", methodName);
+ }
+ return String.format("log.debug(\"Request %s: %s\", %s);", methodName, parameterPlaceHolders, parameters);
+ }
+
+ public Map findAggregateCommandsForMethod(Map method, Options options) {
+ var zdl = options.get("zdl");
+ var aggregatesCommandsForMethod = ZDLFindUtils.findAggregateCommandsForMethod((Map) zdl, method);
+ if(aggregatesCommandsForMethod.isEmpty()) {
+ return Map.of("templateFile", "aggregates-void-methodBody");
+ }
+ if(aggregatesCommandsForMethod.size() == 1) {
+ var aggregate = JSONPath.get(aggregatesCommandsForMethod, "$[0].aggregate");
+ var entity = JSONPath.get(aggregatesCommandsForMethod, "$[0].entity");
+ var command = JSONPath.get(aggregatesCommandsForMethod, "$[0].command");
+ var crudMethod = JSONPath.get(aggregatesCommandsForMethod, "$[0].crudMethod");
+ if(aggregate != null && command != null) {
+ return Map.of("templateFile", "aggregates-commands-methodBody", "aggregatesCommandsForMethod", aggregatesCommandsForMethod);
+ }
+ if(aggregate != null && crudMethod != null) {
+ return Map.of("templateFile", "aggregates-crud-methodBody", "aggregatesCommandsForMethod", aggregatesCommandsForMethod);
+ }
+ if(entity != null && crudMethod != null) {
+ return Map.of("templateFile", "entities-crud-methodBody", "entity", entity, "crudMethod", crudMethod);
+ }
+ if(entity != null) {
+ return Map.of("templateFile", "entities-methodBody", "entity", entity);
+ }
+ }
+ return Map.of("templateFile", "aggregates-commands-methodBody", "aggregatesCommandsForMethod", aggregatesCommandsForMethod);
+ }
+ public boolean isWriteMethod(Map method, Options options) {
+ var methodName = (String) method.get("name");
+ var hasId = method.get("paramId") != null;
+ return hasId || methodName.startsWith("create") || methodName.startsWith("update") || methodName.startsWith("delete");
+ }
+
+ @Deprecated
public boolean isCrudMethod(String crudMethodPrefix, Options options) {
var entity = (Map) options.hash("entity");
var entityName = (String) entity.get("name");
@@ -42,12 +85,40 @@ public boolean isCrudMethod(String crudMethodPrefix, Options options) {
return isCrudMethod;
}
+ public List