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/migration/generator.js b/generators/migration/generator.js index 552d51fcc..77d5effcf 100644 --- a/generators/migration/generator.js +++ b/generators/migration/generator.js @@ -2,18 +2,25 @@ 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.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 = () => {}; + } + }, + taskName: `${this.runningState.methodName}(delayed)`, + queueName: this.runningState.queueName, + }); }, }); } @@ -56,6 +63,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/__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..edd2f2835 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", }, @@ -2356,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", }, @@ -2704,6 +2710,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", }, @@ -3677,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", }, @@ -3809,6 +3824,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 +4399,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 +4893,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", }, @@ -5177,6 +5201,9 @@ 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", }, @@ -5414,6 +5441,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", }, @@ -11713,6 +11743,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", }, @@ -11782,6 +11818,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", }, @@ -12219,6 +12258,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", }, @@ -12336,6 +12381,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 +12887,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 +13426,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 +13911,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 +14459,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 +15007,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", }, @@ -15270,6 +15333,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", }, @@ -15567,6 +15633,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 +17286,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 +18358,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 +19421,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 +20550,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", }, @@ -22676,6 +22757,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", }, @@ -22760,6 +22847,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", }, @@ -23233,6 +23323,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", }, @@ -23368,6 +23464,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 +23964,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 +24521,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 +25024,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 +25572,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 +26081,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", }, @@ -26317,6 +26431,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", }, @@ -26632,6 +26749,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 +28318,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 +29330,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 +30333,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 +31369,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..ed8185956 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -2,14 +2,14 @@ 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'; 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 { @@ -26,15 +26,11 @@ const { DOCKER_ELASTICSEARCH_CONTAINER, ELASTICSEARCH_VERSION, MAIN_DIR, - 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/`; -const SERVER_TEST_SRC_KOTLIN_DIR = `${TEST_DIR}kotlin/`; const JAVA_VERSION = '11'; @@ -53,37 +49,30 @@ 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'); } get [BaseApplicationGenerator.COMPOSING]() { + const mainComposing = super.composing; return this.asComposingTaskGroup({ async composingTemplateTask() { await this.composeCurrentJHipsterCommand(); }, - ...super.composing, - async composing() { - const { applicationType, databaseType } = this.jhipsterConfigWithDefaults; - + async composeWithPostWriting() { await this.composeWithJHipster('docker'); - if (applicationType === 'gateway') { + 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']; + await mainComposing.composing.call(this, ...args); + this.options.skipPriorities = skipPriorities; }, }); } @@ -130,23 +119,47 @@ 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 => [ - 'jhipster:java:domain', 'jhipster:spring-cloud:gateway', 'jhipster:spring-data-cassandra', - 'jhipster:spring-data-couchbase', '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', + 'jhipster:spring-websocket', + ].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'].includes(sourceBasename) ? undefined : file; + 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; @@ -156,9 +169,24 @@ export default class extends BaseApplicationGenerator { } if (sourceFile.includes('.java')) { - sourceFile = isKotlinGeneratorFile(file) - ? convertToKotlinFile(sourceFile) - : join(namespace.split(':').pop(), convertToKotlinFile(sourceFile)); + // 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 ( + 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, sourceFile, @@ -249,6 +277,41 @@ export default class extends BaseApplicationGenerator { searchEngine: ({ searchEngine }) => (searchEngine === 'no' ? false : searchEngine), }); }, + addCacheNeedles({ source, application }) { + 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.java.name`; + 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, + }); + }, }); } @@ -308,6 +371,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 }) { @@ -319,41 +387,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, - }); - }, }); } @@ -365,15 +398,27 @@ 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 [ + 'EntityTest.java', + 'EntityRepository.java', + 'EntityRepository_reactive.java', + 'EntityRowMapper.java', + 'EntitySqlHelper_reactive.java', + 'EntityRepositoryInternalImpl_reactive.java', + 'EntityCallback.java', + 'EntitySqlHelper_reactive.java', + 'EntityRepositoryWithBagRelationships.java', + 'EntityRepositoryWithBagRelationshipsImpl.java', + 'EntityRepositoryInternalImpl_reactive.java', + 'EntitySearchRepository.java', + ].includes(sourceBasename) || sourceBasename.startsWith('Entity.java.jhi') + ? undefined + : file; + }, }); - - if (application.databaseTypeCouchbase) { - await this.writeFiles({ - sections: entityCouchbaseFiles, - context: { ...application, ...entity, entity }, - rootTemplatesPath: 'couchbase', - }); - } } }, 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/domain/src/main/kotlin/_package_/_entityPackage_/common/field_validators.ejs b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/common/field_validators.ejs new file mode 100644 index 000000000..c66a0bdf8 --- /dev/null +++ b/generators/spring-boot/templates/domain/src/main/kotlin/_package_/_entityPackage_/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 -%> 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 99% 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 index bfb1aa418..bf494df7e 100644 --- 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 @@ -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/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/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/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 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 94% 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 index b41c536ce..10100d45b 100644 --- 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 @@ -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/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 96% 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 index 70749bd6c..96f08ceaa 100644 --- 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 @@ -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/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 88% 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 index ae14399df..4b99c9afc 100644 --- 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 @@ -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 <%_ } _%> @@ -35,22 +36,20 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties , Persistable<<%= primaryKey.type %>> <&_ } -&> -<&_ if (fragment.classAdditionalFieldsSection) { -&> +<&_ if (fragment.classInnerAdditionalFieldsSection) { -&> @Transient - private var isPersisted: Boolean, + private var isPersisted: Boolean = false <&_ } -&> <&_ if (fragment.classAdditionalFieldsMethodsSection) { -&> - - <%_ if (primaryKey.name !== 'id') { -%> +<%_ if (primaryKey.name !== 'id') { -%> override fun getId() = this.<%= primaryKey.name %> - <%_ } -%> - @Transient +<%_ } -%> override fun isNew() = !this.isPersisted fun setIsPersisted(): <%= persistClass %> { this.isPersisted = true return this } - <&_ } -&> +<&_ } -&> 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/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 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 96% 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..bee3781cb 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 { _%> @@ -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(entity.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 <%_ } _%> 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 92% 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 index 7bcfbb26b..009ea67b8 100644 --- 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 @@ -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) { _%> 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 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..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 @@ -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 { _%> @@ -87,10 +88,15 @@ data class Authority( <%_ if (databaseTypeSql && !reactive) { _%> @Column(length = 50) <%_ } _%> - var name: String? = null + var name: String? = null, ) : Serializable<% if (databaseTypeSql && reactive) { %>, Persistable<% } %> { +<%_ if (databaseTypeSql && reactive) { _%> + @Transient + private var isPersisted: Boolean = false + +<%_ } _%> override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is Authority) return false @@ -104,7 +110,12 @@ data class Authority( <%_ if (databaseTypeSql && reactive) { _%> override fun getId() = name - override fun isNew() = true + override fun isNew() = !this.isPersisted + + fun setIsPersisted(): Authority { + this.isPersisted = true + return this + } <%_ } _%> companion object { 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 %>" } 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", },