Skip to content

Commit 5ea658b

Browse files
authored
Merge pull request #65 from ZenWave360/features/kotlin
feature/kotlin + release 2.1.0
2 parents 16e1bd5 + 8dd126d commit 5ea658b

File tree

18 files changed

+117
-76
lines changed

18 files changed

+117
-76
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ aux_links:
1313
ga_tracking: G-PWPE0ZF877
1414
ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings (true by default)
1515

16-
exclude: e2e
16+
exclude: e2e,release-notes
1717

1818
footer_content: "ZenWave360 © 2022-2024 - Domain Driven Design (DDD) and API-First for Event Driven Microservices."

e2e/src/test/java/io/zenwave360/sdk/e2e/TestMonolithClinicalProject.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ public void fixControllers() throws Exception {
134134
TextUtils.replaceInFile(new File(targetFolder + "/src/main/java/com/example/clinical/adapters/web/masterdata/MasterDataApiController.java"),
135135
"masterDataService.listMasterDataOfType\\(type, lang\\)",
136136
"masterDataService.listMasterDataOfType(MasterDataType.valueOf(type), lang)");
137+
138+
TextUtils.replaceInFile(new File(targetFolder + "/src/main/java/com/example/clinical/modules/documents/mappers/DocumentServiceMapper.java"),
139+
"DocumentInfo asDocumentInfo\\(List<Long> documentIds\\);",
140+
"default DocumentInfo asDocumentInfo(List<Long> documentIds) { return new DocumentInfo(); }");
141+
TextUtils.replaceInFile(new File(targetFolder + "/src/main/java/com/example/clinical/modules/documents/mappers/DocumentServiceMapper.java"),
142+
"DocumentInfo update\\(@MappingTarget DocumentInfo entity, List<Long> documentIds\\);",
143+
" default DocumentInfo update(@MappingTarget DocumentInfo entity, List<Long> documentIds) { return entity; }");
137144
}
138145

139146
@Test

plugins/asyncapi-spring-cloud-streams3/src/main/resources/io/zenwave360/sdk/plugins/SpringCloudStream3Generator/producer/partials/runtime-headers.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
}
2929
continue;
3030
}
31-
if (location.startsWith("/")) {
32-
var expression = location.substring(1);
31+
if (location.startsWith("#/")) {
32+
var expression = location.substring(2);
3333
try {
3434
var parts = java.util.Arrays.asList(expression.split("/"));
3535
var value = payload;

plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationDefaultHelpers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public Object skipEntityRepository(Map entity, Options options) {
475475

476476
public Object skipEntityId(Map entity, Options options) {
477477
var zdl = options.get("zdl");
478-
return is(Map.of("zdl", zdl, "entity", entity), "vo", "input");
478+
return is(Map.of("zdl", zdl, "entity", entity), "embedded", "vo", "input", "abstract");
479479
};
480480

481481
public Object addExtends(Object entity, Options options) {

plugins/backend-application-default/src/main/java/io/zenwave360/sdk/plugins/BackendApplicationProjectTemplates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class BackendApplicationProjectTemplates extends ProjectTemplates {
2727

2828
protected Function<Map<String, Object>, Boolean> skipEntityRepository = (model) -> is(model, "persistence") // if polyglot persistence -> skip
2929
|| !(is(model, "aggregate") || ZDLFindUtils.isAggregateRoot(JSONPath.get(model, "zdl"), JSONPath.get(model, "$.entity.name")));
30-
protected Function<Map<String, Object>, Boolean> skipEntityId = (model) -> is(model, "embedded", "vo", "input", "abstract");
30+
// protected Function<Map<String, Object>, Boolean> skipEntityId = (model) -> is(model, "embedded", "vo", "input", "abstract");
3131
protected Function<Map<String, Object>, Boolean> skipEntity = (model) -> is(model, "vo", "input");
3232
// protected Function<Map<String, Object>, Boolean> skipEntityInput = (model) -> inputDTOSuffix == null || inputDTOSuffix.isEmpty();
3333

plugins/customizations/kotlin-backend-application/src/main/java/io/zenwave360/sdk/plugins/kotlin/BackendApplicationKotlinHelpers.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ public String methodParametersSignature(Map<String, Object> method, Options opti
3232

3333
public String mapperInputSignature(String inputType, Options options) {
3434
var zdl = (Map) options.get("zdl");
35-
var signature = ZDLJavaSignatureUtils.mapperInputSignature(inputType, zdl);
36-
signature = signature.replace("java.util.Map input", "java.util.Map<String,Any?> input");
37-
return ZDLJavaSignatureUtils.toKotlinMethodSignature(signature);
35+
return ZDLJavaSignatureUtils.kotlinMapperInputSignature(inputType, zdl);
3836
}
3937

4038
public String returnType(Map<String, Object> method, Options options) {
@@ -47,6 +45,12 @@ public String fieldType(Map field, Options options) {
4745
return fixKotlinCollectionTypes(ZDLJavaSignatureUtils.fieldType(field, prefix, suffix));
4846
};
4947

48+
public boolean isRequired(Map field, Options options) {
49+
var isRequired = JSONPath.get(field, "validations.required") != null;
50+
var isArray = JSONPath.get(field, "isArray", false);
51+
return isRequired && !isArray;
52+
}
53+
5054
public String relationshipFieldType(Map field, Options options) {
5155
String prefix = (String) options.hash.getOrDefault("prefix", "");
5256
String suffix = (String) options.hash.getOrDefault("suffix", "");

plugins/customizations/kotlin-backend-application/src/main/resources/io/zenwave360/sdk/plugins/kotlin/BackendApplicationDefaultGenerator/src/main/kotlin/core/domain/vo/Entity.kt.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class {{entity.className}}(
2525
{{#each entity.fields as |field|}}
2626
{{~#if field.isArray}}
2727
fun add{{capitalize field.name}}({{field.name}}: {{javaType field}}): {{entity.className}} {
28-
this.{{field.name}}.add({{field.name}})
28+
this.{{field.name}} += {{field.name}}
2929
return this
3030
}
3131
{{~/if}}

plugins/customizations/kotlin-backend-application/src/main/resources/io/zenwave360/sdk/plugins/kotlin/BackendApplicationDefaultGenerator/src/main/kotlin/core/inbound/dtos/EntityInput.kt.hbs

Lines changed: 0 additions & 56 deletions
This file was deleted.

plugins/customizations/kotlin-backend-application/src/main/resources/io/zenwave360/sdk/plugins/kotlin/BackendApplicationDefaultGenerator/src/main/kotlin/core/inbound/dtos/InputOrOutput.kt.hbs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import jakarta.validation.constraints.*
1212
data class {{entity.className}}(
1313
{{#each entity.fields as |field|}}
1414
{{{fieldValidationAnnotations field}}}
15-
{{~#if @last}}
16-
val {{field.name}}: {{{fieldType field}}}{{#unless field.isArray}}?{{/unless}} {{{fieldTypeInitializer field}}}
17-
{{~else}}
18-
val {{field.name}}: {{{fieldType field}}}{{#unless field.isArray}}?{{/unless}} {{{fieldTypeInitializer field}}},
19-
{{~/if}}
15+
val {{field.name}}: {{{fieldType field}}}{{#unless field.isArray}}?{{/unless}} {{{fieldTypeInitializer field}}}{{~#unless @last}},{{~/unless}}
2016
{{/each}}
2117
) {{addExtends entity}} : Serializable {
2218

plugins/zdl-to-asyncapi/src/main/java/io/zenwave360/sdk/plugins/ZDLToAsyncAPIGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ public GeneratedProjectFiles generate(Map<String, Object> contextModel) {
148148
schemas.put(entityName, asyncAPISchema);
149149
}
150150
if (schemaFormat == SchemaFormat.avro) {
151-
EntitiesToAvroConverter toAvroConverter = new EntitiesToAvroConverter().withIdType(idType).withNamespace(avroPackage);
151+
var avroIdType = "string".equals(idType) ? "string" : "long";
152+
EntitiesToAvroConverter toAvroConverter = new EntitiesToAvroConverter().withIdType(avroIdType).withNamespace(avroPackage);
152153
generatedProjectFiles.singleFiles.addAll(convertToAvro(toAvroConverter, schema, model));
153154
}
154155
}

0 commit comments

Comments
 (0)