From 9cc1925e403dfb4217fc584e9e64f32f83082213 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 14:13:38 -0300 Subject: [PATCH 01/25] use jhipster:java:domain generator --- .../__snapshots__/generator.spec.js.snap | 3 + .../__snapshots__/matrix.spec.js.snap | 90 +++++++++++++++++++ generators/spring-boot/generator.js | 14 ++- generators/spring-boot/matrix.spec.js | 6 +- .../common/field_validators.ejs | 0 .../domain/_persistClass_.kt.jhi.ejs} | 0 ...rsistClass_.kt.jhi.jakarta_validation.ejs} | 0 .../domain/_persistClass_Test.kt.ejs} | 0 test/__snapshots__/app.spec.js.snap | 42 +++++++++ test/__snapshots__/server.spec.js.snap | 6 ++ 10 files changed, 157 insertions(+), 4 deletions(-) rename generators/spring-boot/templates/{src/main/kotlin/package => domain/src/main/kotlin/_package_/_entityPackage_}/common/field_validators.ejs (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.ejs => domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.javax_validation.ejs => domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_validation.ejs} (100%) rename generators/spring-boot/templates/{src/test/kotlin/package/domain/EntityTest.kt.ejs => domain/src/test/kotlin/_package_/_entityPackage_/domain/_persistClass_Test.kt.ejs} (100%) diff --git a/generators/spring-boot/__snapshots__/generator.spec.js.snap b/generators/spring-boot/__snapshots__/generator.spec.js.snap index 549d00685..1798d27a5 100644 --- a/generators/spring-boot/__snapshots__/generator.spec.js.snap +++ b/generators/spring-boot/__snapshots__/generator.spec.js.snap @@ -410,6 +410,9 @@ exports[`SubGenerator kotlin of kotlin JHipster blueprint > run > should succeed "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/__snapshots__/matrix.spec.js.snap b/generators/spring-boot/__snapshots__/matrix.spec.js.snap index 7ec5cb7a0..30e97426a 100644 --- a/generators/spring-boot/__snapshots__/matrix.spec.js.snap +++ b/generators/spring-boot/__snapshots__/matrix.spec.js.snap @@ -2021,6 +2021,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/com/mycompany/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/SimpleEntityTest.kt": { "stateCleared": "modified", }, @@ -2704,6 +2707,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/com/mycompany/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/SimpleEntityTest.kt": { "stateCleared": "modified", }, @@ -3809,6 +3815,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/com/mycompany/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/SimpleEntityTest.kt": { "stateCleared": "modified", }, @@ -4381,6 +4390,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/com/mycompany/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/SimpleEntityTest.kt": { "stateCleared": "modified", }, @@ -4872,6 +4884,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/tech/jhipster/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/SimpleTest.kt": { "stateCleared": "modified", }, @@ -5414,6 +5429,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/test/kotlin/tech/jhipster/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/SimpleTest.kt": { "stateCleared": "modified", }, @@ -11782,6 +11800,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -12336,6 +12357,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -12839,6 +12863,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -13375,6 +13402,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -13857,6 +13887,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -14402,6 +14435,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -14947,6 +14983,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -15567,6 +15606,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -17217,6 +17259,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -18286,6 +18331,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -19346,6 +19394,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -20472,6 +20523,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -22760,6 +22814,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -23368,6 +23425,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -23865,6 +23925,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -24419,6 +24482,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -24919,6 +24985,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -25464,6 +25533,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -25970,6 +26042,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -26632,6 +26707,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/com/mycompany/domain/AnotherSimpleTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/domain/MicroserviceTest.kt": { "stateCleared": "modified", }, @@ -28198,6 +28276,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -29207,6 +29288,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -30207,6 +30291,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, @@ -31240,6 +31327,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/test/kotlin/tech/jhipster/domain/AnotherSimpleEntityTest.kt": { "stateCleared": "modified", }, + "src/test/kotlin/tech/jhipster/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/tech/jhipster/domain/MicroserviceEntityTest.kt": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 0a2bd6b1e..80461d2ec 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -53,6 +53,7 @@ export default class extends BaseApplicationGenerator { await this.dependsOnJHipster('jhipster-kotlin:migration'); await this.dependsOnJHipster('jhipster-kotlin:kotlin'); await this.dependsOnJHipster('server'); + await this.dependsOnJHipster('jhipster:java:domain'); await this.dependsOnJHipster('jhipster-kotlin:ktlint'); } @@ -133,7 +134,6 @@ export default class extends BaseApplicationGenerator { // Ignore files from generators file => [ - 'jhipster:java:domain', 'jhipster:spring-cloud:gateway', 'jhipster:spring-data-cassandra', 'jhipster:spring-data-couchbase', @@ -146,7 +146,9 @@ export default class extends BaseApplicationGenerator { // Kotling blueprint does not implements these files file => { const sourceBasename = basename(file.sourceFile); - return ['_persistClass_Asserts.java', '_persistClass_TestSamples.java'].includes(sourceBasename) ? undefined : file; + return ['_persistClass_Asserts.java', '_persistClass_TestSamples.java', 'AssertUtils.java'].includes(sourceBasename) + ? undefined + : file; }, file => { let { resolvedSourceFile, sourceFile, destinationFile, namespace } = file; @@ -159,6 +161,7 @@ export default class extends BaseApplicationGenerator { sourceFile = isKotlinGeneratorFile(file) ? convertToKotlinFile(sourceFile) : join(namespace.split(':').pop(), convertToKotlinFile(sourceFile)); + return { ...file, sourceFile, @@ -365,6 +368,13 @@ export default class extends BaseApplicationGenerator { sections: entityServerFiles, context: { ...application, ...entity, entity }, rootTemplatesPath: application.reactive ? ['reactive', ''] : [''], + customizeTemplatePath: file => { + const sourceBasename = basename(file.sourceFile); + // Files migrated to modularized templates + return ['Entity.java.jhi', 'Entity.java.jhi.javax_validation', 'EntityTest.java'].includes(sourceBasename) + ? undefined + : file; + }, }); if (application.databaseTypeCouchbase) { diff --git a/generators/spring-boot/matrix.spec.js b/generators/spring-boot/matrix.spec.js index d243c435b..2350678ea 100644 --- a/generators/spring-boot/matrix.spec.js +++ b/generators/spring-boot/matrix.spec.js @@ -3,8 +3,11 @@ import { isMatch } from 'lodash-es'; import { defaultHelpers as helpers, result, buildServerMatrix, entitiesServerSamples } from 'generator-jhipster/testing'; +const databaseType = ['sql', 'mongodb', 'cassandra', 'couchbase', 'neo4j']; + describe('Matrix test of SubGenerator kotlin of kotlin JHipster blueprint', () => { - Object.entries(buildServerMatrix({ databaseType: ['sql', 'mongodb', 'cassandra', 'couchbase', 'neo4j'] })).forEach(([name, config]) => { + Object.entries(buildServerMatrix({ databaseType })).forEach(([name, config], _idx) => { + // if (_idx !== 0) return; if ( isMatch(config, { websocket: true, applicationType: 'gateway' }) || isMatch(config, { websocket: true, applicationType: 'microservice' }) @@ -14,7 +17,6 @@ describe('Matrix test of SubGenerator kotlin of kotlin JHipster blueprint', () = if (isMatch(config, { skipUserManagement: false, applicationType: 'microservice' })) { config.skipUserManagement = true; } - // if (name !== 'microservice-jwt-reactive(false)-maven-enableTranslation(false)-tech.jhipster-jhi-Entity-DTO-skipCommitHook(false)-cucumber-websocket(false)-skipUserManagement(false)-serviceDiscoveryType(no)') return; describe(name, () => { beforeAll(async function () { await helpers diff --git a/generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/common/field_validators.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs rename to generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/common/field_validators.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.ejs b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.ejs rename to generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_validation.ejs b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_validation.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_validation.ejs rename to generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_validation.ejs diff --git a/generators/spring-boot/templates/src/test/kotlin/package/domain/EntityTest.kt.ejs b/generators/spring-boot/templates/domain/src/test/kotlin/_package_/_entityPackage_/domain/_persistClass_Test.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/test/kotlin/package/domain/EntityTest.kt.ejs rename to generators/spring-boot/templates/domain/src/test/kotlin/_package_/_entityPackage_/domain/_persistClass_Test.kt.ejs diff --git a/test/__snapshots__/app.spec.js.snap b/test/__snapshots__/app.spec.js.snap index bb2b95ae9..9a5526519 100644 --- a/test/__snapshots__/app.spec.js.snap +++ b/test/__snapshots__/app.spec.js.snap @@ -401,6 +401,9 @@ exports[`JHipster generator for App generator > App with skip client > Gradle > "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -847,6 +850,9 @@ exports[`JHipster generator for App generator > App with skip client > Maven > c "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -1308,6 +1314,9 @@ exports[`JHipster generator for App generator > Application with DB option > cou "src/test/kotlin/com/mycompany/myapp/config/WebConfigurerTestController.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -1760,6 +1769,9 @@ exports[`JHipster generator for App generator > Application with DB option > mar "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -2206,6 +2218,9 @@ exports[`JHipster generator for App generator > Application with DB option > mon "src/test/kotlin/com/mycompany/myapp/config/WebConfigurerTestController.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -2550,6 +2565,9 @@ exports[`JHipster generator for App generator > Application with other options > "src/test/kotlin/com/test/reactui/config/TestSecurityConfiguration.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/test/reactui/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/test/reactui/security/SecurityUtilsUnitTest.kt": { "stateCleared": "modified", }, @@ -2951,6 +2969,9 @@ exports[`JHipster generator for App generator > Auth options > HTTP session auth "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/repository/timezone/DateTimeWrapper.kt": { "stateCleared": "modified", }, @@ -3397,6 +3418,9 @@ exports[`JHipster generator for App generator > Auth options > JWT authenticatio "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -3894,6 +3918,9 @@ exports[`JHipster generator for App generator > Default configuration with > Gra "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -4394,6 +4421,9 @@ exports[`JHipster generator for App generator > Default configuration with > Gra "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -4861,6 +4891,9 @@ exports[`JHipster generator for App generator > Default configuration with > Mav "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -5325,6 +5358,9 @@ exports[`JHipster generator for App generator > Default configuration with > ang "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -5786,6 +5822,9 @@ exports[`JHipster generator for App generator > Default configuration with > rea "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -6259,6 +6298,9 @@ exports[`JHipster generator for App generator > Testing options > Cucumber tests "src/test/kotlin/com/mycompany/myapp/cucumber/stepdefs/UserStepDefs.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, diff --git a/test/__snapshots__/server.spec.js.snap b/test/__snapshots__/server.spec.js.snap index 097868afc..452d3cf3d 100644 --- a/test/__snapshots__/server.spec.js.snap +++ b/test/__snapshots__/server.spec.js.snap @@ -1241,6 +1241,9 @@ exports[`JHipster server generator > generate server with caffeine > creates exp "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, @@ -2605,6 +2608,9 @@ exports[`JHipster server generator > generate server with ehcache > creates expe "src/test/kotlin/com/mycompany/myapp/config/timezone/HibernateTimeZoneIT.kt": { "stateCleared": "modified", }, + "src/test/kotlin/com/mycompany/myapp/domain/AuthorityTest.kt": { + "stateCleared": "modified", + }, "src/test/kotlin/com/mycompany/myapp/management/SecurityMetersServiceTests.kt": { "stateCleared": "modified", }, From 751777ea19f40e4ace63784618df18fc1bb2bae6 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 14:26:44 -0300 Subject: [PATCH 02/25] use jhipster:spring-data-couchbase generator --- generators/spring-boot/generator.js | 52 ++----------------- ...stClass_.kt.jhi.spring_data_couchbase.ejs} | 0 .../_entityClass_Repository.kt.ejs} | 0 .../config/DatabaseConfiguration.kt.ejs} | 0 .../CouchbaseSearchRepository.kt.ejs | 0 .../JHipsterCouchbaseRepository.kt.ejs | 0 ...PersistentTokenRepository_couchbase.kt.ejs | 0 .../config/CouchbaseTestContainer.kt.ejs | 0 .../config/EmbeddedCouchbase.kt.ejs | 0 .../CouchbaseSearchRepositoryTest.kt.ejs | 0 10 files changed, 5 insertions(+), 47 deletions(-) rename generators/spring-boot/templates/{couchbase/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_couchbase.ejs => spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_couchbase.ejs} (100%) rename generators/spring-boot/templates/{couchbase/src/main/kotlin/package/repository/EntityRepository.kt.ejs => spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/config/DatabaseConfiguration_couchbase.kt.ejs => spring-data-couchbase/src/main/kotlin/_package_/config/DatabaseConfiguration.kt.ejs} (100%) rename generators/spring-boot/templates/{couchbase/src/main/kotlin/package => spring-data-couchbase/src/main/kotlin/_package_}/repository/CouchbaseSearchRepository.kt.ejs (100%) rename generators/spring-boot/templates/{couchbase/src/main/kotlin/package => spring-data-couchbase/src/main/kotlin/_package_}/repository/JHipsterCouchbaseRepository.kt.ejs (100%) rename generators/spring-boot/templates/{couchbase/src/main/kotlin/package => spring-data-couchbase/src/main/kotlin/_package_}/repository/PersistentTokenRepository_couchbase.kt.ejs (100%) rename generators/spring-boot/templates/{couchbase/src/test/kotlin/package => spring-data-couchbase/src/test/kotlin/_package_}/config/CouchbaseTestContainer.kt.ejs (100%) rename generators/spring-boot/templates/{couchbase/src/test/kotlin/package => spring-data-couchbase/src/test/kotlin/_package_}/config/EmbeddedCouchbase.kt.ejs (100%) rename generators/spring-boot/templates/{couchbase/src/test/kotlin/package => spring-data-couchbase/src/test/kotlin/_package_}/repository/CouchbaseSearchRepositoryTest.kt.ejs (100%) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 80461d2ec..5d9bebe39 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -9,7 +9,6 @@ import { files as serverFiles } from 'jhipster-7-templates/esm/generators/server import { convertToKotlinFile } from '../kotlin/support/files.js'; import migration from './migration.cjs'; import { serverFiles as sqlFiles } from './files-sql.js'; -import { entityCouchbaseFiles } from './entity-files-couchbase.js'; const { jhipsterConstants, jhipster7DockerContainers } = migration; const { @@ -29,8 +28,6 @@ const { TEST_DIR, } = jhipsterConstants; -const { couchbaseFiles } = migration; - const jhipster7TemplatesPackage = dirname(fileURLToPath(import.meta.resolve('jhipster-7-templates/package.json'))); const SERVER_MAIN_SRC_KOTLIN_DIR = `${MAIN_DIR}kotlin/`; @@ -136,7 +133,6 @@ export default class extends BaseApplicationGenerator { [ 'jhipster:spring-cloud:gateway', 'jhipster:spring-data-cassandra', - 'jhipster:spring-data-couchbase', 'jhipster:spring-data-mongodb', 'jhipster:spring-data-neo4j', 'jhipster:spring-data-relational', @@ -311,6 +307,11 @@ export default class extends BaseApplicationGenerator { await this.writeFiles({ sections: serverFiles, context: application, + customizeTemplatePath: file => { + const sourceBasename = basename(file.sourceFile); + // Files migrated to modularized templates + return ['DatabaseConfiguration_couchbase.java'].includes(sourceBasename) ? undefined : file; + }, }); }, async writeSqlFiles({ application }) { @@ -322,41 +323,6 @@ export default class extends BaseApplicationGenerator { context: application, }); }, - cleanupCouchbaseFiles({ application }) { - if (!application.databaseTypeCouchbase) return; - - if (this.isJhipsterVersionLessThan('7.1.1')) { - this.removeFile( - `${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/CustomReactiveCouchbaseRepository.kt`, - ); - this.removeFile(`${SERVER_TEST_SRC_KOTLIN_DIR}${application.packageFolder}config/DatabaseConfigurationIT.kt`); - this.removeFile(`${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/N1qlCouchbaseRepository.kt`); - this.removeFile( - `${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/ReactiveN1qlCouchbaseRepository.kt`, - ); - this.removeFile(`${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/CustomN1qlCouchbaseRepository.kt`); - this.removeFile(`${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/CustomCouchbaseRepository.kt`); - this.removeFile(`${SERVER_MAIN_SRC_KOTLIN_DIR}${application.packageFolder}repository/SearchCouchbaseRepository.kt`); - this.removeFile(`${SERVER_TEST_SRC_KOTLIN_DIR}${application.packageFolder}repository/CustomCouchbaseRepositoryTest.kt`); - } - }, - async writeCouchbaseFiles({ application }) { - if (!application.databaseTypeCouchbase) return; - - await this.writeFiles({ - sections: couchbaseFiles, - context: application, - rootTemplatesPath: ['couchbase'], - customizeTemplatePath: file => - file.sourceFile.includes('.java') - ? { - ...file, - resolvedSourceFile: this.templatePath(`couchbase/${convertToKotlinFile(file.sourceFile)}`), - destinationFile: convertToKotlinFile(file.destinationFile), - } - : file, - }); - }, }); } @@ -376,14 +342,6 @@ export default class extends BaseApplicationGenerator { : file; }, }); - - if (application.databaseTypeCouchbase) { - await this.writeFiles({ - sections: entityCouchbaseFiles, - context: { ...application, ...entity, entity }, - rootTemplatesPath: 'couchbase', - }); - } } }, diff --git a/generators/spring-boot/templates/couchbase/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_couchbase.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_couchbase.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_couchbase.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_couchbase.ejs diff --git a/generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/EntityRepository.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/EntityRepository.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/config/DatabaseConfiguration_couchbase.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/config/DatabaseConfiguration.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/config/DatabaseConfiguration_couchbase.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/config/DatabaseConfiguration.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/CouchbaseSearchRepository.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/CouchbaseSearchRepository.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/CouchbaseSearchRepository.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/CouchbaseSearchRepository.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/JHipsterCouchbaseRepository.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/JHipsterCouchbaseRepository.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/JHipsterCouchbaseRepository.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/JHipsterCouchbaseRepository.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/PersistentTokenRepository_couchbase.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/PersistentTokenRepository_couchbase.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/main/kotlin/package/repository/PersistentTokenRepository_couchbase.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/main/kotlin/_package_/repository/PersistentTokenRepository_couchbase.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/test/kotlin/package/config/CouchbaseTestContainer.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/config/CouchbaseTestContainer.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/test/kotlin/package/config/CouchbaseTestContainer.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/config/CouchbaseTestContainer.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/test/kotlin/package/config/EmbeddedCouchbase.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/config/EmbeddedCouchbase.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/test/kotlin/package/config/EmbeddedCouchbase.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/config/EmbeddedCouchbase.kt.ejs diff --git a/generators/spring-boot/templates/couchbase/src/test/kotlin/package/repository/CouchbaseSearchRepositoryTest.kt.ejs b/generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/repository/CouchbaseSearchRepositoryTest.kt.ejs similarity index 100% rename from generators/spring-boot/templates/couchbase/src/test/kotlin/package/repository/CouchbaseSearchRepositoryTest.kt.ejs rename to generators/spring-boot/templates/spring-data-couchbase/src/test/kotlin/_package_/repository/CouchbaseSearchRepositoryTest.kt.ejs From a32a80bc0774af797457c56fd477bc623cf61e49 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 17:00:53 -0300 Subject: [PATCH 03/25] templates --- generators/spring-boot/generator.js | 85 +++++++++++++------ ...stClass_.kt.jhi.spring_data_cassandra.ejs} | 0 .../_persistClass_.kt.jhi.elastic_search.ejs} | 0 .../_entityClass_SearchRepository.kt.ejs} | 0 ...sistClass_.kt.jhi.spring_data_mongodb.ejs} | 0 ...ersistClass_.kt.jhi.spring_data_neo4j.ejs} | 0 ..._persistClass_.kt.jhi.hibernate_cache.ejs} | 0 ...lass_.kt.jhi.jakarta_lifecycle_events.ejs} | 0 ...sistClass_.kt.jhi.jakarta_persistence.ejs} | 0 ...Class_.kt.jhi.spring_data_persistable.ejs} | 0 ...istClass_.kt.jhi.spring_data_reactive.ejs} | 0 .../domain/_persistClass_Callback.kt.ejs} | 0 ...ss_RepositoryInternalImpl_reactive.kt.ejs} | 2 +- .../_entityClass_SqlHelper_reactive.kt.ejs} | 0 .../_entityClass_RowMapper_reactive.kt.ejs} | 0 .../_entityClass_Repository.kt.ejs} | 0 .../_entityClass_Repository_reactive.kt.ejs} | 0 17 files changed, 58 insertions(+), 29 deletions(-) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_cassandra.ejs => spring-data-cassandra/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_cassandra.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.elastic_search.ejs => spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.elastic_search.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/search/EntitySearchRepository.kt.ejs => spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/repository/search/_entityClass_SearchRepository.kt.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_mongodb.ejs => spring-data-mongodb/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_mongodb.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_neo4j.ejs => spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.hibernate_cache.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.hibernate_cache.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.javax_lifecycle_events.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_lifecycle_events.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.javax_persistence.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_persistable.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_reactive.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_reactive.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/domain/EntityCallback.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_Callback.kt.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/EntityRepositoryInternalImpl_reactive.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs} (99%) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/EntitySqlHelper_reactive.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_SqlHelper_reactive.kt.ejs} (100%) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/rowmapper/EntityRowMapper.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/rowmapper/_entityClass_RowMapper_reactive.kt.ejs} (100%) rename generators/spring-boot/templates/src/main/kotlin/{package/repository/EntityRepository.kt.ejs => _package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs} (100%) rename generators/spring-boot/templates/src/main/kotlin/{package/repository/EntityRepository_reactive.kt.ejs => _package_/_entityPackage_/repository/_entityClass_Repository_reactive.kt.ejs} (100%) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 5d9bebe39..5712cbfee 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -25,13 +25,11 @@ const { DOCKER_ELASTICSEARCH_CONTAINER, ELASTICSEARCH_VERSION, MAIN_DIR, - TEST_DIR, } = jhipsterConstants; const jhipster7TemplatesPackage = dirname(fileURLToPath(import.meta.resolve('jhipster-7-templates/package.json'))); const SERVER_MAIN_SRC_KOTLIN_DIR = `${MAIN_DIR}kotlin/`; -const SERVER_TEST_SRC_KOTLIN_DIR = `${TEST_DIR}kotlin/`; const JAVA_VERSION = '11'; @@ -55,33 +53,23 @@ export default class extends BaseApplicationGenerator { } get [BaseApplicationGenerator.COMPOSING]() { + const mainComposing = super.composing; return this.asComposingTaskGroup({ async composingTemplateTask() { await this.composeCurrentJHipsterCommand(); }, - ...super.composing, - async composing() { - const { applicationType, databaseType } = this.jhipsterConfigWithDefaults; - - await this.composeWithJHipster('docker'); - - if (applicationType === 'gateway') { + async composeGateway() { + if (this.jhipsterConfigWithDefaults.applicationType === 'gateway') { // Use gateway package.json scripts. await this.composeWithJHipster('jhipster:spring-cloud:gateway'); } - - const generatorOptions = { skipPriorities: ['postWriting'] }; - if (databaseType === 'sql') { - await this.composeWithJHipster('jhipster:spring-data-relational', { generatorOptions }); - } else if (databaseType === 'cassandra') { - await this.composeWithJHipster('jhipster:spring-data-cassandra', { generatorOptions }); - } else if (databaseType === 'couchbase') { - await this.composeWithJHipster('jhipster:spring-data-couchbase', { generatorOptions }); - } else if (databaseType === 'mongodb') { - await this.composeWithJHipster('jhipster:spring-data-mongodb', { generatorOptions }); - } else if (databaseType === 'neo4j') { - await this.composeWithJHipster('jhipster:spring-data-neo4j', { generatorOptions }); - } + }, + ...mainComposing, + async composing(...args) { + const { skipPriorities } = this.options; + this.options.skipPriorities = ['postWriting']; + mainComposing.composing.call(this, ...args); + this.options.skipPriorities = skipPriorities; }, }); } @@ -136,16 +124,37 @@ export default class extends BaseApplicationGenerator { 'jhipster:spring-data-mongodb', 'jhipster:spring-data-neo4j', 'jhipster:spring-data-relational', - ].includes(file.namespace) + 'jhipster:spring-data-elasticsearch', + 'jhipster:spring-cloud-stream:kafka', + 'jhipster:spring-cloud-stream:pulsar', + 'jhipster:gatling', + 'jhipster:cucumber', + 'jhipster:spring-cache', + ].includes(file.namespace) && !file.sourceFile.includes('_entityPackage_') ? undefined : file, // Kotling blueprint does not implements these files file => { const sourceBasename = basename(file.sourceFile); - return ['_persistClass_Asserts.java', '_persistClass_TestSamples.java', 'AssertUtils.java'].includes(sourceBasename) + return [ + '_persistClass_Asserts.java', + '_persistClass_TestSamples.java', + 'AssertUtils.java', + '_entityClass_Repository_r2dbc.java', + ].includes(sourceBasename) ? undefined : file; }, + file => { + // Use v8 files due to needles + if (file.sourceFile.includes('resources/logback')) { + return { + ...file, + resolvedSourceFile: this.fetchFromInstalledJHipster('server/templates/', file.sourceFile), + }; + } + return file; + }, file => { let { resolvedSourceFile, sourceFile, destinationFile, namespace } = file; // Already resolved kotlin files @@ -154,9 +163,18 @@ export default class extends BaseApplicationGenerator { } if (sourceFile.includes('.java')) { - sourceFile = isKotlinGeneratorFile(file) - ? convertToKotlinFile(sourceFile) - : join(namespace.split(':').pop(), convertToKotlinFile(sourceFile)); + const isCommonFile = filename => { + const sourceBasename = basename(filename); + return ( + file.namespace !== 'spring-data-couchbase' && + ['_entityClass_Repository.java', '_entityClass_Repository_reactive.java'].includes(sourceBasename) + ); + }; + + sourceFile = + isKotlinGeneratorFile(file) || isCommonFile(sourceFile) + ? convertToKotlinFile(sourceFile) + : join(namespace.split(':').pop(), convertToKotlinFile(sourceFile)); return { ...file, @@ -337,7 +355,18 @@ export default class extends BaseApplicationGenerator { customizeTemplatePath: file => { const sourceBasename = basename(file.sourceFile); // Files migrated to modularized templates - return ['Entity.java.jhi', 'Entity.java.jhi.javax_validation', 'EntityTest.java'].includes(sourceBasename) + return [ + 'EntityTest.java', + 'EntityRepository.java', + 'EntityRepository_reactive.java', + 'EntityRowMapper.java', + 'EntitySqlHelper_reactive.java', + 'EntityRepositoryInternalImpl_reactive.java', + 'EntityCallback.java', + 'EntitySqlHelper_reactive.java', + 'EntityRepositoryInternalImpl_reactive.java', + 'EntitySearchRepository.java', + ].includes(sourceBasename) || sourceBasename.startsWith('Entity.java.jhi') ? undefined : file; }, diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_cassandra.ejs b/generators/spring-boot/templates/spring-data-cassandra/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_cassandra.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_cassandra.ejs rename to generators/spring-boot/templates/spring-data-cassandra/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_cassandra.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.elastic_search.ejs b/generators/spring-boot/templates/spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.elastic_search.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.elastic_search.ejs rename to generators/spring-boot/templates/spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.elastic_search.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/search/EntitySearchRepository.kt.ejs b/generators/spring-boot/templates/spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/repository/search/_entityClass_SearchRepository.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/search/EntitySearchRepository.kt.ejs rename to generators/spring-boot/templates/spring-data-elasticsearch/src/main/kotlin/_package_/_entityPackage_/repository/search/_entityClass_SearchRepository.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_mongodb.ejs b/generators/spring-boot/templates/spring-data-mongodb/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_mongodb.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_mongodb.ejs rename to generators/spring-boot/templates/spring-data-mongodb/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_mongodb.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_neo4j.ejs b/generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_neo4j.ejs rename to generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.hibernate_cache.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.hibernate_cache.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.hibernate_cache.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.hibernate_cache.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_lifecycle_events.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_lifecycle_events.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_lifecycle_events.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_lifecycle_events.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_persistence.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.javax_persistence.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_persistable.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_persistable.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_reactive.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_reactive.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/Entity.kt.jhi.spring_data_reactive.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_reactive.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/EntityCallback.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_Callback.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/EntityCallback.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_Callback.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryInternalImpl_reactive.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs similarity index 99% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryInternalImpl_reactive.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs index 802ea7ab0..f4138fdc0 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryInternalImpl_reactive.kt.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs @@ -75,7 +75,7 @@ import <%= rel.otherEntity.entityAbsolutePackage %>.domain.<%= rel.otherEntity.p import <%= entityAbsolutePackage %>.domain.enumeration.<%= element %> <%_ }); _%> -<%_ [...reactiveOtherEntities, entity].forEach(otherEntity => { +<%_ [...reactiveOtherEntities, locals].forEach(otherEntity => { if (otherEntity.entityAbsolutePackage) { _%> import <%= otherEntity.entityAbsolutePackage %>.repository.rowmapper.<%= otherEntity.entityClass %>RowMapper <%_ } else { _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntitySqlHelper_reactive.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_SqlHelper_reactive.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntitySqlHelper_reactive.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_SqlHelper_reactive.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/rowmapper/EntityRowMapper.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/rowmapper/_entityClass_RowMapper_reactive.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/rowmapper/EntityRowMapper.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/rowmapper/_entityClass_RowMapper_reactive.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepository.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepository.kt.ejs rename to generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepository_reactive.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository_reactive.kt.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepository_reactive.kt.ejs rename to generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository_reactive.kt.ejs From a5731ae9059cb9ed5b0d11e3e393c6db254a06db Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 17:41:59 -0300 Subject: [PATCH 04/25] adjusts --- .../__snapshots__/matrix.spec.js.snap | 51 +++++++++++++++++++ generators/spring-boot/generator.js | 2 + 2 files changed, 53 insertions(+) diff --git a/generators/spring-boot/__snapshots__/matrix.spec.js.snap b/generators/spring-boot/__snapshots__/matrix.spec.js.snap index 30e97426a..463dcbbd8 100644 --- a/generators/spring-boot/__snapshots__/matrix.spec.js.snap +++ b/generators/spring-boot/__snapshots__/matrix.spec.js.snap @@ -2359,6 +2359,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/main/kotlin/com/mycompany/domain/Authority.kt": { "stateCleared": "modified", }, + "src/main/kotlin/com/mycompany/domain/AuthorityCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/com/mycompany/domain/SimpleEntity.kt": { "stateCleared": "modified", }, @@ -3683,6 +3686,12 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user/user.json": { "stateCleared": "modified", }, + "src/main/resources/config/couchmove/changelog/V0.2__create_indexes.n1ql": { + "stateCleared": "modified", + }, + "src/main/resources/config/couchmove/changelog/V0__create_collections.n1ql": { + "stateCleared": "modified", + }, "src/main/resources/config/couchmove/changelog/V20220129000100__simple.n1ql": { "stateCleared": "modified", }, @@ -5192,12 +5201,18 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/main/kotlin/tech/jhipster/domain/Authority.kt": { "stateCleared": "modified", }, + "src/main/kotlin/tech/jhipster/domain/AuthorityCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/tech/jhipster/domain/Simple.kt": { "stateCleared": "modified", }, "src/main/kotlin/tech/jhipster/domain/User.kt": { "stateCleared": "modified", }, + "src/main/kotlin/tech/jhipster/domain/UserCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/tech/jhipster/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, @@ -11731,6 +11746,12 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user/user.json": { "stateCleared": "modified", }, + "src/main/resources/config/couchmove/changelog/V0.2__create_indexes.n1ql": { + "stateCleared": "modified", + }, + "src/main/resources/config/couchmove/changelog/V0__create_collections.n1ql": { + "stateCleared": "modified", + }, "src/main/resources/config/couchmove/changelog/V20220129000100__simple.n1ql": { "stateCleared": "modified", }, @@ -12240,6 +12261,12 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user/user.json": { "stateCleared": "modified", }, + "src/main/resources/config/couchmove/changelog/V0.2__create_indexes.n1ql": { + "stateCleared": "modified", + }, + "src/main/resources/config/couchmove/changelog/V0__create_collections.n1ql": { + "stateCleared": "modified", + }, "src/main/resources/config/couchmove/changelog/V20220129000100__simple.n1ql": { "stateCleared": "modified", }, @@ -15309,6 +15336,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/main/kotlin/com/mycompany/domain/Authority.kt": { "stateCleared": "modified", }, + "src/main/kotlin/com/mycompany/domain/AuthorityCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/com/mycompany/domain/Microservice.kt": { "stateCleared": "modified", }, @@ -15318,6 +15348,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/main/kotlin/com/mycompany/domain/User.kt": { "stateCleared": "modified", }, + "src/main/kotlin/com/mycompany/domain/UserCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/com/mycompany/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, @@ -22730,6 +22763,12 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user/user.json": { "stateCleared": "modified", }, + "src/main/resources/config/couchmove/changelog/V0.2__create_indexes.n1ql": { + "stateCleared": "modified", + }, + "src/main/resources/config/couchmove/changelog/V0__create_collections.n1ql": { + "stateCleared": "modified", + }, "src/main/resources/config/couchmove/changelog/V20220129000100__simple.n1ql": { "stateCleared": "modified", }, @@ -23290,6 +23329,12 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user/user.json": { "stateCleared": "modified", }, + "src/main/resources/config/couchmove/changelog/V0.2__create_indexes.n1ql": { + "stateCleared": "modified", + }, + "src/main/resources/config/couchmove/changelog/V0__create_collections.n1ql": { + "stateCleared": "modified", + }, "src/main/resources/config/couchmove/changelog/V20220129000100__simple.n1ql": { "stateCleared": "modified", }, @@ -26392,6 +26437,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/main/kotlin/com/mycompany/domain/Authority.kt": { "stateCleared": "modified", }, + "src/main/kotlin/com/mycompany/domain/AuthorityCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/com/mycompany/domain/Microservice.kt": { "stateCleared": "modified", }, @@ -26401,6 +26449,9 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/main/kotlin/com/mycompany/domain/User.kt": { "stateCleared": "modified", }, + "src/main/kotlin/com/mycompany/domain/UserCallback.kt": { + "stateCleared": "modified", + }, "src/main/kotlin/com/mycompany/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 5712cbfee..5f4222e3a 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -116,6 +116,8 @@ export default class extends BaseApplicationGenerator { file.sourceFile.includes('gradle/wrapper/')) ? undefined : file, + // Ignore gradle convention plugins + file => (file.sourceFile.includes('buildSrc/src/main/groovy/') ? undefined : file), // Ignore files from generators file => [ From 59d24f5a001968d2342114662326351cf9ba9b7f Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 18:21:11 -0300 Subject: [PATCH 05/25] add field_validators --- .../package/common/field_validators.ejs | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs diff --git a/generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs b/generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs new file mode 100644 index 000000000..c66a0bdf8 --- /dev/null +++ b/generators/spring-boot/templates/src/main/kotlin/package/common/field_validators.ejs @@ -0,0 +1,73 @@ +<%# + Copyright 2013-2024 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://www.jhipster.tech/ + for more information. + + Licensed 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. +-%> +<%# Returns a string of all validator annotations for the entity field. -%> +<% +let result = ''; + +if (field.fieldValidate) { + const validators = []; + const MAX_VALUE = 2147483647; + const isBlob = field.fieldTypeBytes; + + if (field.fieldValidationRequired && !isBlob) { + // reactive tests need a default validation message because lookup is blocking + validators.push('@get: NotNull' + (reactive ? '(message = "must not be null")' : '')); + } + if (field.fieldValidationMinLength && !field.fieldValidationMaxLength) { + validators.push('@get: Size(min = ' + field.fieldValidateRulesMinlength + ')'); + } + if (field.fieldValidationMaxLength && !field.fieldValidationMinLength) { + validators.push('@get: Size(max = ' + field.fieldValidateRulesMaxlength + ')'); + } + if (field.fieldValidationMinLength && field.fieldValidationMaxLength) { + validators.push('@get: Size(min = ' + field.fieldValidateRulesMinlength + ', max = ' + field.fieldValidateRulesMaxlength + ')'); + } + // Not supported anymore because the server can't check the size of the blob before downloading it completely. + // if (rules.includes('minbytes') && !rules.includes('maxbytes')) { + // validators.push('@get: Size(min = ' + field.fieldValidateRulesMinbytes + ')'); + // } + // if (rules.includes('maxbytes') && !rules.includes('minbytes')) { + // validators.push('@get: Size(max = ' + field.fieldValidateRulesMaxbytes + ')'); + // } + // if (rules.includes('minbytes') && rules.includes('maxbytes')) { + // validators.push('@get: Size(min = ' + field.fieldValidateRulesMinbytes + ', max = ' + field.fieldValidateRulesMaxbytes + ')'); + // } + if (field.fieldValidationMin) { + if (field.fieldTypeFloat || field.fieldTypeDouble || field.fieldTypeBigDecimal) { + validators.push('@get: DecimalMin(value = "' + field.fieldValidateRulesMin + '")'); + } else { + const isLong = (field.fieldValidateRulesMin > MAX_VALUE || field.fieldTypeLong) ? 'L' : ''; + validators.push('@get: Min(value = ' + field.fieldValidateRulesMin + isLong + ')'); + } + } + if (field.fieldValidationMax) { + if (field.fieldTypeFloat || field.fieldTypeDouble || field.fieldTypeBigDecimal) { + validators.push('@get: DecimalMax(value = "' + field.fieldValidateRulesMax + '")'); + } else { + const isLong = (field.fieldValidateRulesMax > MAX_VALUE || field.fieldTypeLong) ? 'L' : ''; + validators.push('@get: Max(value = ' + field.fieldValidateRulesMax + isLong + ')'); + } + } + if (field.fieldValidationPattern) { + validators.push('@get: Pattern(regexp = "' + field.fieldValidateRulesPatternJava + '")'); + } + result = validators.join('\n '); + result += '\n'; +} -%> +<%- result -%> From fa680eba818f18b6eef349124d66e8438c6533d7 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 18:31:01 -0300 Subject: [PATCH 06/25] templates adjusts --- .../_persistClass_.kt.jhi.spring_data_neo4j.ejs | 4 ++-- .../_persistClass_.kt.jhi.jakarta_persistence.ejs | 6 +++--- ...ityClass_RepositoryInternalImpl_reactive.kt.ejs | 2 +- .../package/service/mapper/EntityMapper.kt.ejs | 14 +++++++------- .../kotlin/package/web/rest/EntityResource.kt.ejs | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs b/generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs index b41c536ce..10100d45b 100644 --- a/generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs +++ b/generators/spring-boot/templates/spring-data-neo4j/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_neo4j.ejs @@ -53,8 +53,8 @@ import org.springframework.data.neo4j.core.schema.Relationship <%_ } -%> <%_ for (const relationship of relationships) { -%> - <%_ const relationshipForwardReference = "HAS_" + _.toUpper(_.snakeCase(relationship.relationshipName)) %> - <%_ const relationshipBackReference = "HAS_" + _.toUpper(_.snakeCase(relationship.otherEntityRelationshipName)) %> + <%_ const relationshipForwardReference = "HAS_" + this._.toUpper(this._.snakeCase(relationship.relationshipName)) %> + <%_ const relationshipBackReference = "HAS_" + this._.toUpper(this._.snakeCase(relationship.otherEntityRelationshipName)) %> <&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&> <%_ if (relationship.ownerSide) { _%> @Relationship(value = "<%= relationshipBackReference %>", direction = Relationship.Direction.INCOMING) diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs index 70749bd6c..96f08ceaa 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.jakarta_persistence.ejs @@ -92,11 +92,11 @@ import org.hibernate.annotations.Type <%- include('relationship_validators', { relationship }); -%> <%_ } _%> @JoinTable(name = "<%= relationship.joinTable.name %>", - joinColumns = [<%= entity.primaryKey.fields.length > 1 ? '{' : '' %> - <%_ entity.primaryKey.fields.forEach((field, idx) => { _%> + joinColumns = [<%= primaryKey.fields.length > 1 ? '{' : '' %> + <%_ primaryKey.fields.forEach((field, idx) => { _%> <%= idx === 0 ? '' : ',' %>JoinColumn(name = "<%= `${entityTableName}_${field.columnName}` %>") <%_ }); _%> - <%= entity.primaryKey.fields.length > 1 ? '}' : '' %>], + <%= primaryKey.fields.length > 1 ? '}' : '' %>], inverseJoinColumns = [<%= relationship.otherEntity.primaryKey.fields.length > 1 ? '{' : '' %> <%_ relationship.otherEntity.primaryKey.fields.forEach((field, idx) => { _%> <%= idx === 0 ? '' : ',' %>JoinColumn(name = "<%= `${relationship.columnName}_${field.columnName}` %>") diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs index f4138fdc0..f72b2b220 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs @@ -122,7 +122,7 @@ class <%= entityClass %>RepositoryInternalImpl( if (rel.relationshipManyToMany && rel.ownerSide) { const joinTableName = getJoinTableName(entityTableName, rel.relationshipName, prodDatabaseType); _%> - private val <%= rel.relationshipName %>Link = EntityManager.LinkTable("<%= joinTableName %>", "<%= entity.entityTableName %>_<%= getColumnName(entity.primaryKey.name) %>", "<%= rel.joinColumnNames[0] %>") + private val <%= rel.relationshipName %>Link = EntityManager.LinkTable("<%= joinTableName %>", "<%= entity.entityTableName %>_<%= getColumnName(primaryKey.name) %>", "<%= rel.joinColumnNames[0] %>") <%_ } }); _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/service/mapper/EntityMapper.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/service/mapper/EntityMapper.kt.ejs index 5cf467fcf..3013bceb1 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/service/mapper/EntityMapper.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/service/mapper/EntityMapper.kt.ejs @@ -40,7 +40,7 @@ _%> import <%= entityAbsoluteClass %> import <%= entityAbsolutePackage %>.service.dto.<%= dtoClass %> -<%_ for (const otherEntity of _.uniq(dtoRelationships.map(relationship => relationship.otherEntity).filter(otherEntity => otherEntity !== entity))) { _%> +<%_ for (const otherEntity of this._.uniq(dtoRelationships.map(relationship => relationship.otherEntity).filter(otherEntity => otherEntity !== entity))) { _%> import <%= otherEntity.entityAbsoluteClass.replace('undefined',entityAbsolutePackage ) %> import <%= otherEntity.entityAbsolutePackage || entityAbsolutePackage %>.service.dto.<%= otherEntity.dtoClass %> <%_ } _%> @@ -66,7 +66,7 @@ interface <%= entityClass %>Mapper : const mappings = []; for (relationship of dtoRelationships) { renMapAnotEnt = true; - let qualifiedByName = relationship.otherEntity.entityInstance + _.upperFirst(relationship.otherEntityField); + let qualifiedByName = relationship.otherEntity.entityInstance + this._.upperFirst(relationship.otherEntityField); qualifiedByName = qualifiedByName + (relationship.collection ? 'Set' : ''); mappings.push(`Mapping(target = "${relationship.propertyName}", source = "${relationship.propertyName}", qualifiedByName=["${qualifiedByName}"])`); } @@ -117,7 +117,7 @@ interface <%= entityClass %>Mapper : <%_ const mappings3 = []; for (const {otherEntity, relatedField, collection} of otherEntitiesFields) { - const mapperName = otherEntity.entityInstance + _.upperFirst(relatedField.propertyName); + const mapperName = otherEntity.entityInstance + this._.upperFirst(relatedField.propertyName); _%> @Named("<%= mapperName %>") @@ -137,14 +137,14 @@ interface <%= entityClass %>Mapper : <%- [...new Set(mappings3)].join(',') %> ) <%_ } _%> - fun toDto<%= _.upperFirst(mapperName) %>(<%= otherEntity.persistInstance %>: <%- otherEntity.persistClass %>): <%- otherEntity.dtoClass %> + fun toDto<%= this._.upperFirst(mapperName) %>(<%= otherEntity.persistInstance %>: <%- otherEntity.persistClass %>): <%- otherEntity.dtoClass %> <%_ if (collection) { _%> - <%_ const collectionMapperName = otherEntity.entityInstance + _.upperFirst(relatedField.propertyName) + 'Set'; _%> + <%_ const collectionMapperName = otherEntity.entityInstance + this._.upperFirst(relatedField.propertyName) + 'Set'; _%> @Named("<%= collectionMapperName %>") - fun toDto<%= _.upperFirst(mapperName) %>Set(<%= otherEntity.persistInstance %>: Set<<%- otherEntity.persistClass %>>): Set<<%- otherEntity.dtoClass %>> { - return <%= otherEntity.persistInstance %>.map(this::toDto<%= _.upperFirst(mapperName) %>).toSet() + fun toDto<%= this._.upperFirst(mapperName) %>Set(<%= otherEntity.persistInstance %>: Set<<%- otherEntity.persistClass %>>): Set<<%- otherEntity.dtoClass %>> { + return <%= otherEntity.persistInstance %>.map(this::toDto<%= this._.upperFirst(mapperName) %>).toSet() } <%_ } _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/web/rest/EntityResource.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/web/rest/EntityResource.kt.ejs index fbeab38eb..82821ef12 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/web/rest/EntityResource.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/web/rest/EntityResource.kt.ejs @@ -113,7 +113,7 @@ import org.elasticsearch.index.query.QueryBuilders.queryStringQuery <%_ let entityName = entityInstance; if (clientRootFolder && !skipUiGrouping) { - entityName = _.camelCase(`${clientRootFolder}${entityClass}`) + entityName = this._.camelCase(`${clientRootFolder}${entityClass}`) } _%> @@ -140,7 +140,7 @@ _%><%- include('../../common/inject_template', {viaService: viaService, construc companion object { <%_ let entityName = entityInstance; if (clientRootFolder && !skipUiGrouping) { - entityName = _.camelCase(`${clientRootFolder}${entityClass}`); + entityName = this._.camelCase(`${clientRootFolder}${entityClass}`); } _%> const val ENTITY_NAME = "<%= entityName %>" } From 766af2878fdd7742e33083f15140786fcd86bb9b Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 18:43:33 -0300 Subject: [PATCH 07/25] adjusts --- generators/migration/generator.js | 26 +++++++++++++++-------- generators/spring-boot/generator.js | 32 ++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/generators/migration/generator.js b/generators/migration/generator.js index 552d51fcc..414e4df1c 100644 --- a/generators/migration/generator.js +++ b/generators/migration/generator.js @@ -2,18 +2,26 @@ import BaseApplicationGenerator from 'generator-jhipster/generators/base-applica import { passthrough } from '@yeoman/transform'; export default class extends BaseApplicationGenerator { - async beforeQueue() { - await this.dependsOnJHipster('jhipster:java:build-tool'); - } - get [BaseApplicationGenerator.PREPARING]() { return this.asPreparingTaskGroup({ async source({ application, source }) { - if (application.buildToolGradle) { - // Add a noop needles for spring-gateway generator - source.addJavaDefinition = () => {}; - source.addJavaDependencies = () => {}; - } + this.queueTaskGroup( + { + postWriting() { + source.addAllowBlockingCallsInside = () => undefined; + source.addApplicationPropertiesContent = () => undefined; + source.addIntegrationTestAnnotation = () => undefined; + source.addTestSpringFactory = () => undefined; + + if (application.buildToolGradle) { + // Add a noop needles for spring-gateway generator + source.addJavaDefinition = () => {}; + source.addJavaDependencies = () => {}; + } + }, + }, + { queueName: this.runningState.queueName }, + ); }, }); } diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 5f4222e3a..928bbd7f0 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -2,8 +2,9 @@ import { basename, dirname, join } from 'path'; import { fileURLToPath } from 'url'; import BaseApplicationGenerator from 'generator-jhipster/generators/spring-boot'; import { prepareSqlApplicationProperties } from 'generator-jhipster/generators/spring-data-relational/support'; -import { files as entityServerFiles } from 'jhipster-7-templates/esm/generators/entity-server'; import { getEnumInfo } from 'generator-jhipster/generators/base-application/support'; +import { createNeedleCallback } from 'generator-jhipster/generators/base/support'; +import { files as entityServerFiles } from 'jhipster-7-templates/esm/generators/entity-server'; import { files as serverFiles } from 'jhipster-7-templates/esm/generators/server'; import { convertToKotlinFile } from '../kotlin/support/files.js'; @@ -268,6 +269,35 @@ export default class extends BaseApplicationGenerator { searchEngine: ({ searchEngine }) => (searchEngine === 'no' ? false : searchEngine), }); }, + addCacheNeedles({ source, application }) { + if (application.cacheProviderEhcache) { + const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`; + const needle = `${application.cacheProvider}-add-entry`; + const useJcacheConfiguration = application.cacheProviderRedis; + const addEntryToCacheCallback = entry => + createNeedleCallback({ + needle, + contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''});`, + }); + + source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); + source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { + const entry = `${entityAbsoluteClass}.class.getName()`; + this.editFile( + cacheConfigurationFile, + addEntryToCacheCallback(entry), + ...(relationships ?? []) + .filter(rel => rel.collection) + .map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)), + ); + }; + } else { + // Add noop + source.addEntryToCache = () => {}; + // Add noop + source.addEntityToCache = () => {}; + } + }, }); } From 64aacf39b34ba908dfb6f50cb10715e166ec1fd5 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 18:51:35 -0300 Subject: [PATCH 08/25] ignore spring-websocket --- generators/spring-boot/generator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 928bbd7f0..8ec059527 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -133,6 +133,7 @@ export default class extends BaseApplicationGenerator { 'jhipster:gatling', 'jhipster:cucumber', 'jhipster:spring-cache', + 'jhipster:spring-websocket', ].includes(file.namespace) && !file.sourceFile.includes('_entityPackage_') ? undefined : file, From 4f0aedaee68baa4026cb163c9ca4d5695d4bd7d2 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 18:58:02 -0300 Subject: [PATCH 09/25] adjust --- generators/spring-boot/generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 8ec059527..a2e916e16 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -69,7 +69,7 @@ export default class extends BaseApplicationGenerator { async composing(...args) { const { skipPriorities } = this.options; this.options.skipPriorities = ['postWriting']; - mainComposing.composing.call(this, ...args); + await mainComposing.composing.call(this, ...args); this.options.skipPriorities = skipPriorities; }, }); From dba7596369e173ad57f09868dcb3930a7c679891 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:03:05 -0300 Subject: [PATCH 10/25] fix docker --- generators/spring-boot/generator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index a2e916e16..ff3f5a7ea 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -59,7 +59,9 @@ export default class extends BaseApplicationGenerator { async composingTemplateTask() { await this.composeCurrentJHipsterCommand(); }, - async composeGateway() { + async composeWithPostWriting() { + await this.composeWithJHipster('docker'); + if (this.jhipsterConfigWithDefaults.applicationType === 'gateway') { // Use gateway package.json scripts. await this.composeWithJHipster('jhipster:spring-cloud:gateway'); From 82c967753a6ca0a475182b1d6d5f74c9ae9ef6ab Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:15:39 -0300 Subject: [PATCH 11/25] templates adjusts --- generators/spring-boot/generator.js | 2 ++ .../_entityClass_RepositoryInternalImpl_reactive.kt.ejs | 3 +-- .../_entityClass_RepositoryWithBagRelationships.kt.ejs} | 2 +- .../_entityClass_RepositoryWithBagRelationshipsImpl.kt.ejs} | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/EntityRepositoryWithBagRelationships.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationships.kt.ejs} (97%) rename generators/spring-boot/templates/{src/main/kotlin/package/repository/EntityRepositoryWithBagRelationshipsImpl.kt.ejs => spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationshipsImpl.kt.ejs} (99%) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index ff3f5a7ea..d2e6c40ae 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -399,6 +399,8 @@ export default class extends BaseApplicationGenerator { 'EntityRepositoryInternalImpl_reactive.java', 'EntityCallback.java', 'EntitySqlHelper_reactive.java', + 'EntityRepositoryWithBagRelationships.java', + 'EntityRepositoryWithBagRelationshipsImpl.java', 'EntityRepositoryInternalImpl_reactive.java', 'EntitySearchRepository.java', ].includes(sourceBasename) || sourceBasename.startsWith('Entity.java.jhi') diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs index f72b2b220..bee3781cb 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryInternalImpl_reactive.kt.ejs @@ -120,9 +120,8 @@ class <%= entityClass %>RepositoryInternalImpl( <%_ }); _%> <%_ relationships.forEach(function(rel) { if (rel.relationshipManyToMany && rel.ownerSide) { - const joinTableName = getJoinTableName(entityTableName, rel.relationshipName, prodDatabaseType); _%> - private val <%= rel.relationshipName %>Link = EntityManager.LinkTable("<%= joinTableName %>", "<%= entity.entityTableName %>_<%= getColumnName(primaryKey.name) %>", "<%= rel.joinColumnNames[0] %>") + private val <%= rel.relationshipName %>Link = EntityManager.LinkTable("<%= rel.joinTable.name %>", "<%= entityTableName %>_<%= primaryKey.fields[0].columnName %>", "<%= rel.joinColumnNames[0] %>") <%_ } }); _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationships.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationships.kt.ejs similarity index 97% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationships.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationships.kt.ejs index 100aec969..8ab401803 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationships.kt.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationships.kt.ejs @@ -19,7 +19,7 @@ package <%= entityAbsolutePackage %>.repository import java.util.Optional -<%_ if (fieldsContainUUID) { _%> +<%_ if (anyFieldIsUUID) { _%> import java.util.UUID <%_ } _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationshipsImpl.kt.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationshipsImpl.kt.ejs similarity index 99% rename from generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationshipsImpl.kt.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationshipsImpl.kt.ejs index 3beb57ae2..e35e9f18a 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/repository/EntityRepositoryWithBagRelationshipsImpl.kt.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_RepositoryWithBagRelationshipsImpl.kt.ejs @@ -20,7 +20,7 @@ package <%= entityAbsolutePackage %>.repository import java.util.Collections import java.util.Optional -<%_ if (fieldsContainUUID) { _%> +<%_ if (anyFieldIsUUID) { _%> import java.util.UUID <%_ } _%> From ba8eebea9b7043797e8bd5726d7409243faa714f Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:20:05 -0300 Subject: [PATCH 12/25] templates adjusts --- generators/migration/generator.js | 3 +++ .../_entityPackage_}/domain/relationship_validators.ejs | 0 2 files changed, 3 insertions(+) rename generators/spring-boot/templates/{src/main/kotlin/package => spring-data-relational/src/main/kotlin/_package_/_entityPackage_}/domain/relationship_validators.ejs (100%) diff --git a/generators/migration/generator.js b/generators/migration/generator.js index 414e4df1c..aba1cc9a6 100644 --- a/generators/migration/generator.js +++ b/generators/migration/generator.js @@ -64,6 +64,9 @@ export default class extends BaseApplicationGenerator { } }, async postWritingTemplateTask({ application }) { + this.editFile('src/main/resources/logback-spring.xml', contents => contents.replaceAll('jakarta.', 'javax.')); + this.editFile('src/test/resources/logback.xml', contents => contents.replaceAll('jakarta.', 'javax.')); + if (application.buildToolGradle) { // JHipster 8 have needles fixed this.editFile('build.gradle', contents => contents.replaceAll('//jhipster', '// jhipster')); diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/relationship_validators.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/relationship_validators.ejs similarity index 100% rename from generators/spring-boot/templates/src/main/kotlin/package/domain/relationship_validators.ejs rename to generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/relationship_validators.ejs From 099e77c872302d3f9e2c2dbc92caf30440830ed8 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:30:36 -0300 Subject: [PATCH 13/25] needles adjusts --- generators/migration/generator.js | 29 +++++++------- generators/spring-boot/generator.js | 60 ++++++++++++++++------------- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/generators/migration/generator.js b/generators/migration/generator.js index aba1cc9a6..77d5effcf 100644 --- a/generators/migration/generator.js +++ b/generators/migration/generator.js @@ -5,23 +5,22 @@ export default class extends BaseApplicationGenerator { get [BaseApplicationGenerator.PREPARING]() { return this.asPreparingTaskGroup({ async source({ application, source }) { - this.queueTaskGroup( - { - postWriting() { - source.addAllowBlockingCallsInside = () => undefined; - source.addApplicationPropertiesContent = () => undefined; - source.addIntegrationTestAnnotation = () => undefined; - source.addTestSpringFactory = () => undefined; + this.queueTask({ + method: () => { + source.addAllowBlockingCallsInside = () => undefined; + source.addApplicationPropertiesContent = () => undefined; + source.addIntegrationTestAnnotation = () => undefined; + source.addTestSpringFactory = () => undefined; - if (application.buildToolGradle) { - // Add a noop needles for spring-gateway generator - source.addJavaDefinition = () => {}; - source.addJavaDependencies = () => {}; - } - }, + if (application.buildToolGradle) { + // Add a noop needles for spring-gateway generator + source.addJavaDefinition = () => {}; + source.addJavaDependencies = () => {}; + } }, - { queueName: this.runningState.queueName }, - ); + taskName: `${this.runningState.methodName}(delayed)`, + queueName: this.runningState.queueName, + }); }, }); } diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index d2e6c40ae..5b3a38e4d 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -273,33 +273,39 @@ export default class extends BaseApplicationGenerator { }); }, addCacheNeedles({ source, application }) { - if (application.cacheProviderEhcache) { - const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`; - const needle = `${application.cacheProvider}-add-entry`; - const useJcacheConfiguration = application.cacheProviderRedis; - const addEntryToCacheCallback = entry => - createNeedleCallback({ - needle, - contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''});`, - }); - - source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); - source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { - const entry = `${entityAbsoluteClass}.class.getName()`; - this.editFile( - cacheConfigurationFile, - addEntryToCacheCallback(entry), - ...(relationships ?? []) - .filter(rel => rel.collection) - .map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)), - ); - }; - } else { - // Add noop - source.addEntryToCache = () => {}; - // Add noop - source.addEntityToCache = () => {}; - } + this.queueTask({ + method: () => { + if (application.cacheProviderEhcache) { + const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`; + const needle = `${application.cacheProvider}-add-entry`; + const useJcacheConfiguration = application.cacheProviderRedis; + const addEntryToCacheCallback = entry => + createNeedleCallback({ + needle, + contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''});`, + }); + + source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); + source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { + const entry = `${entityAbsoluteClass}.class.getName()`; + this.editFile( + cacheConfigurationFile, + addEntryToCacheCallback(entry), + ...(relationships ?? []) + .filter(rel => rel.collection) + .map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)), + ); + }; + } else { + // Add noop + source.addEntryToCache = () => {}; + // Add noop + source.addEntityToCache = () => {}; + } + }, + taskName: `${this.runningState.methodName}(delayed)`, + queueName: this.runningState.queueName, + }); }, }); } From 2f56f1ac3bffddb546cd52658f26bc4878049e75 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:40:16 -0300 Subject: [PATCH 14/25] more adjusts --- generators/spring-boot/generator.js | 4 ++-- .../_persistClass_.kt.jhi.spring_data_persistable.ejs | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 5b3a38e4d..ea7c4126a 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -282,12 +282,12 @@ export default class extends BaseApplicationGenerator { const addEntryToCacheCallback = entry => createNeedleCallback({ needle, - contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''});`, + contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''})`, }); source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { - const entry = `${entityAbsoluteClass}.class.getName()`; + const entry = `${entityAbsoluteClass}::class.java.name`; this.editFile( cacheConfigurationFile, addEntryToCacheCallback(entry), diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs index ae14399df..c4f79f9e1 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs @@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties <&_ } -&> <&_ if (fragment.annotationSection) { -&> -@JsonIgnoreProperties(value = [ "new" ]) +@JsonIgnoreProperties(value = { "new" }) <&_ } -&> <&_ if (fragment.additionalInterfacesSection) { -&> @@ -41,10 +41,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties <&_ } -&> <&_ if (fragment.classAdditionalFieldsMethodsSection) { -&> - - <%_ if (primaryKey.name !== 'id') { -%> +<%_ if (primaryKey.name !== 'id') { -%> override fun getId() = this.<%= primaryKey.name %> - <%_ } -%> +<%_ } -%> @Transient override fun isNew() = !this.isPersisted From dd0ff32a1f4d3ec0772a1e65a3bb6b8557a4d10c Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Tue, 30 Jul 2024 19:44:09 -0300 Subject: [PATCH 15/25] more templates adjusts --- .../__snapshots__/generator.spec.js.snap | 24 ------------------- .../kotlin/package/domain/Authority.kt.ejs | 8 ++++++- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/generators/migration/__snapshots__/generator.spec.js.snap b/generators/migration/__snapshots__/generator.spec.js.snap index 443629037..7c2aa9afa 100644 --- a/generators/migration/__snapshots__/generator.spec.js.snap +++ b/generators/migration/__snapshots__/generator.spec.js.snap @@ -2,32 +2,8 @@ exports[`SubGenerator migration of kotlin JHipster blueprint > run > should succeed 1`] = ` { - ".mvn/jvm.config": { - "stateCleared": "modified", - }, - ".mvn/wrapper/maven-wrapper.jar": { - "stateCleared": "modified", - }, - ".mvn/wrapper/maven-wrapper.properties": { - "stateCleared": "modified", - }, ".yo-rc.json": { "stateCleared": "modified", }, - "mvnw": { - "stateCleared": "modified", - }, - "mvnw.cmd": { - "stateCleared": "modified", - }, - "pom.xml": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/myapp/GeneratedByJHipster.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/myapp/package-info.java": { - "stateCleared": "modified", - }, } `; diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs index 6c4ffb869..cd3ed3d62 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs @@ -104,7 +104,13 @@ data class Authority( <%_ if (databaseTypeSql && reactive) { _%> override fun getId() = name - override fun isNew() = true + @Transient + override fun isNew() = !this.isPersisted + + fun setIsPersisted(): <%= persistClass %> { + this.isPersisted = true + return this + } <%_ } _%> companion object { From 0f2691a10e04422d16508fe55e4e20262d465f11 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Tue, 30 Jul 2024 20:02:40 -0300 Subject: [PATCH 16/25] fix Authority.kt persistable api --- .../src/main/kotlin/package/domain/Authority.kt.ejs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs index cd3ed3d62..0550f0907 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs @@ -87,7 +87,11 @@ data class Authority( <%_ if (databaseTypeSql && !reactive) { _%> @Column(length = 50) <%_ } _%> - var name: String? = null + var name: String? = null, +<%_ if (databaseTypeSql && reactive) { _%> + @Transient + private var isPersisted: Boolean = false, +<%_ } _%> ) : Serializable<% if (databaseTypeSql && reactive) { %>, Persistable<% } %> { @@ -104,10 +108,9 @@ data class Authority( <%_ if (databaseTypeSql && reactive) { _%> override fun getId() = name - @Transient override fun isNew() = !this.isPersisted - fun setIsPersisted(): <%= persistClass %> { + fun setIsPersisted(): Authority { this.isPersisted = true return this } From cb1f56bffcd27aab61ffcab8f39b7d11e42cdd09 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 31 Jul 2024 08:00:06 -0300 Subject: [PATCH 17/25] fix persistable template --- .../_persistClass_.kt.jhi.spring_data_persistable.ejs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs index c4f79f9e1..ef2a0d3e2 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs @@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties <&_ } -&> <&_ if (fragment.annotationSection) { -&> -@JsonIgnoreProperties(value = { "new" }) +@JsonIgnoreProperties(value = [ "new" ]) <&_ } -&> <&_ if (fragment.additionalInterfacesSection) { -&> @@ -37,19 +37,18 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties <&_ if (fragment.classAdditionalFieldsSection) { -&> @Transient - private var isPersisted: Boolean, + private var isPersisted: Boolean = false, <&_ } -&> <&_ if (fragment.classAdditionalFieldsMethodsSection) { -&> <%_ if (primaryKey.name !== 'id') { -%> override fun getId() = this.<%= primaryKey.name %> -<%_ } -%> - @Transient +<%_ } -%> override fun isNew() = !this.isPersisted fun setIsPersisted(): <%= persistClass %> { this.isPersisted = true return this } - <&_ } -&> +<&_ } -&> From c4269f899bae290808fa4408015b8b922b3c97ae Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 31 Jul 2024 08:32:59 -0300 Subject: [PATCH 18/25] Use _entityClass_Repository for reactive neo4j --- .../_entityPackage_/repository/_entityClass_Repository.kt.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs index 7bcfbb26b..009ea67b8 100644 --- a/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs @@ -38,7 +38,7 @@ import org.springframework.data.mongodb.repository.Query import org.springframework.data.mongodb.repository.MongoRepository <%_ } _%> <%_ if (databaseTypeNeo4j) { _%> -import org.springframework.data.neo4j.repository.Neo4jRepository +import org.springframework.data.neo4j.repository.<% if (reactive) { %>Reactive<% } %>Neo4jRepository <%_ } _%> <%_ if (databaseTypeCassandra) { _%> import org.springframework.data.cassandra.repository.CassandraRepository @@ -66,7 +66,7 @@ import java.util.UUID @Suppress("unused") <%_ } _%> @Repository -interface <%=entityClass%>Repository : <% if (containsBagRelationships && databaseTypeSql) { %><%= entityClass %>RepositoryWithBagRelationships, <% } %><% if (databaseTypeSql) { %>JpaRepository<% } %><% if (databaseTypeMongodb) { %>MongoRepository<% } %><% if (databaseTypeNeo4j) { %>Neo4jRepository<% } %><% if (databaseTypeCassandra) { %>CassandraRepository<% } %><<%=persistClass%>, <%= primaryKey.type %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= persistClass %>><% } %><% if (searchEngineCouchbase) { %>, SearchCouchbaseRepository<<%= persistClass %>, <%= primaryKey.type %>><% } %> { +interface <%=entityClass%>Repository : <% if (containsBagRelationships && databaseTypeSql) { %><%= entityClass %>RepositoryWithBagRelationships, <% } %><% if (databaseTypeSql) { %>JpaRepository<% } %><% if (databaseTypeMongodb) { %>MongoRepository<% } %><% if (databaseTypeNeo4j) { %><% if (reactive) { %>Reactive<% } %>Neo4jRepository<% } %><% if (databaseTypeCassandra) { %>CassandraRepository<% } %><<%=persistClass%>, <%= primaryKey.type %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= persistClass %>><% } %><% if (searchEngineCouchbase) { %>, SearchCouchbaseRepository<<%= persistClass %>, <%= primaryKey.type %>><% } %> { <%_ for (const relationship of relationships) { _%> <%_ if (relationship.relationshipManyToOne && relationship.otherEntityName === 'user' && databaseTypeSql) { _%> From b2a32ed29cabbf43011aba29167bc53c7cfddf2b Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 08:58:04 -0300 Subject: [PATCH 19/25] ignore UserCallback.kt --- generators/spring-boot/__snapshots__/matrix.spec.js.snap | 9 --------- generators/spring-boot/generator.js | 5 +++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/generators/spring-boot/__snapshots__/matrix.spec.js.snap b/generators/spring-boot/__snapshots__/matrix.spec.js.snap index 463dcbbd8..edd2f2835 100644 --- a/generators/spring-boot/__snapshots__/matrix.spec.js.snap +++ b/generators/spring-boot/__snapshots__/matrix.spec.js.snap @@ -5210,9 +5210,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew "src/main/kotlin/tech/jhipster/domain/User.kt": { "stateCleared": "modified", }, - "src/main/kotlin/tech/jhipster/domain/UserCallback.kt": { - "stateCleared": "modified", - }, "src/main/kotlin/tech/jhipster/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, @@ -15348,9 +15345,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro "src/main/kotlin/com/mycompany/domain/User.kt": { "stateCleared": "modified", }, - "src/main/kotlin/com/mycompany/domain/UserCallback.kt": { - "stateCleared": "modified", - }, "src/main/kotlin/com/mycompany/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, @@ -26449,9 +26443,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol "src/main/kotlin/com/mycompany/domain/User.kt": { "stateCleared": "modified", }, - "src/main/kotlin/com/mycompany/domain/UserCallback.kt": { - "stateCleared": "modified", - }, "src/main/kotlin/com/mycompany/repository/AnotherSimpleRepository.kt": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index ea7c4126a..ed8185956 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -169,6 +169,11 @@ export default class extends BaseApplicationGenerator { } if (sourceFile.includes('.java')) { + // Kotlint User template does not implements Persistable api. Ignore for now. + if (application.user && destinationFile.endsWith('UserCallback.java')) { + return undefined; + } + const isCommonFile = filename => { const sourceBasename = basename(filename); return ( From 2be1597a1635bfb571c9aa8729ffbdfd4ad7f05d Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 09:23:33 -0300 Subject: [PATCH 20/25] persistable adjusts --- .../domain/_persistClass_.kt.jhi.spring_data_persistable.ejs | 1 + .../templates/src/main/kotlin/package/domain/Authority.kt.ejs | 1 + 2 files changed, 2 insertions(+) diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs index ef2a0d3e2..20c58a327 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs @@ -22,6 +22,7 @@ -%> <&_ if (fragment.importSection) { -&> import org.springframework.data.domain.Persistable +import org.springframework.data.annotation.Transient <%_ if (!relationshipsContainOtherSideIgnore) { _%> import com.fasterxml.jackson.annotation.JsonIgnoreProperties <%_ } _%> diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs index 0550f0907..8736625cb 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs @@ -38,6 +38,7 @@ import org.springframework.data.neo4j.core.schema.Node <%_ if (databaseTypeSql) { _%> <%_ if (reactive) { _%> import org.springframework.data.annotation.Id +import org.springframework.data.annotation.Transient import org.springframework.data.domain.Persistable import org.springframework.data.relational.core.mapping.Table <%_ } else { _%> From f03ddb9463a1f48d1c709685a820fa99205f8666 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 10:16:33 -0300 Subject: [PATCH 21/25] ignore AuthorityCallback --- generators/spring-boot/generator.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index ed8185956..45dd8475c 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -169,8 +169,11 @@ export default class extends BaseApplicationGenerator { } if (sourceFile.includes('.java')) { - // Kotlint User template does not implements Persistable api. Ignore for now. - if (application.user && destinationFile.endsWith('UserCallback.java')) { + // Kotlint User template does not implements Persistable api and AuthorityCallback is not working as expected. Ignore for now. + if ( + application.user && + (destinationFile.endsWith('UserCallback.java') || destinationFile.endsWith('AuthorityCallback.java')) + ) { return undefined; } From 6438192a9004c6598322329c04f3b5d45fe4390d Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 10:26:56 -0300 Subject: [PATCH 22/25] Authority adjusts --- .../src/main/kotlin/package/domain/Authority.kt.ejs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs index 8736625cb..2b55a26bd 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs @@ -89,13 +89,14 @@ data class Authority( @Column(length = 50) <%_ } _%> var name: String? = null, + +) : Serializable<% if (databaseTypeSql && reactive) { %>, Persistable<% } %> { + <%_ if (databaseTypeSql && reactive) { _%> @Transient private var isPersisted: Boolean = false, -<%_ } _%> - -) : Serializable<% if (databaseTypeSql && reactive) { %>, Persistable<% } %> { +<%_ } _%> override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is Authority) return false From 18ee9b74a37505990da6cca101139c491e64cafe Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 10:27:59 -0300 Subject: [PATCH 23/25] Revert "ignore AuthorityCallback" This reverts commit f03ddb9463a1f48d1c709685a820fa99205f8666. --- generators/spring-boot/generator.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index 45dd8475c..ed8185956 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -169,11 +169,8 @@ export default class extends BaseApplicationGenerator { } if (sourceFile.includes('.java')) { - // Kotlint User template does not implements Persistable api and AuthorityCallback is not working as expected. Ignore for now. - if ( - application.user && - (destinationFile.endsWith('UserCallback.java') || destinationFile.endsWith('AuthorityCallback.java')) - ) { + // Kotlint User template does not implements Persistable api. Ignore for now. + if (application.user && destinationFile.endsWith('UserCallback.java')) { return undefined; } From dd2a4d699f61ec3d03125b46993861d3639598bb Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 31 Jul 2024 10:40:39 -0300 Subject: [PATCH 24/25] Update Authority.kt.ejs --- .../templates/src/main/kotlin/package/domain/Authority.kt.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs index 2b55a26bd..0cc9c33cb 100644 --- a/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs +++ b/generators/spring-boot/templates/src/main/kotlin/package/domain/Authority.kt.ejs @@ -94,7 +94,7 @@ data class Authority( <%_ if (databaseTypeSql && reactive) { _%> @Transient - private var isPersisted: Boolean = false, + private var isPersisted: Boolean = false <%_ } _%> override fun equals(other: Any?): Boolean { From cbf6e7cff1d50186ec5276c514259280da703dd1 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 31 Jul 2024 10:29:39 -0300 Subject: [PATCH 25/25] persistable adjusts --- .../_entityPackage_/domain/_persistClass_.kt.jhi.ejs | 2 ++ .../domain/_persistClass_.kt.jhi.spring_data_persistable.ejs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs index bfb1aa418..bf494df7e 100644 --- a/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs +++ b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.ejs @@ -28,6 +28,7 @@ classStaticFieldsSection: 0, classFieldsSection: 0, classAdditionalFieldsSection: 0, + classInnerAdditionalFieldsSection: 0, classAdditionalFieldsMethodsSection: 0, classAdditionalRelationshipsSection: 0, classAdditionalRelationshipsMethodsSection: 0, @@ -124,6 +125,7 @@ data class <%= persistClass %>( <&- fragments.classAdditionalRelationshipsSection() -&> // jhipster-needle-entity-add-field - JHipster will add fields here ) :<&- fragments.extendsSection() -&> Serializable<&- fragments.additionalInterfacesSection() -&> { +<&- fragments.classInnerAdditionalFieldsSection() -&> <%_ // An embedded entity should not reference entities that embed it, unless the other entities are also embedded diff --git a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs index 20c58a327..4b99c9afc 100644 --- a/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs +++ b/generators/spring-boot/templates/spring-data-relational/src/main/kotlin/_package_/_entityPackage_/domain/_persistClass_.kt.jhi.spring_data_persistable.ejs @@ -36,9 +36,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties , Persistable<<%= primaryKey.type %>> <&_ } -&> -<&_ if (fragment.classAdditionalFieldsSection) { -&> +<&_ if (fragment.classInnerAdditionalFieldsSection) { -&> @Transient - private var isPersisted: Boolean = false, + private var isPersisted: Boolean = false <&_ } -&> <&_ if (fragment.classAdditionalFieldsMethodsSection) { -&>