@@ -22,7 +22,13 @@ import BaseApplicationGenerator from '../base-application/index.mjs';
2222import { GENERATOR_JAVA , GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs' ;
2323import writeTask from './files.mjs' ;
2424import cleanupTask from './cleanup.mjs' ;
25- import { packageInfoTransform , generatedAnnotationTransform , checkJava } from './support/index.mjs' ;
25+ import {
26+ packageInfoTransform ,
27+ generatedAnnotationTransform ,
28+ checkJava ,
29+ javaMainPackageTemplatesBlock ,
30+ javaTestPackageTemplatesBlock ,
31+ } from './support/index.mjs' ;
2632import { JavaApplication } from './types.mjs' ;
2733import { BaseApplicationGeneratorDefinition , GenericApplicationDefinition } from '../base-application/tasks.mjs' ;
2834import { GenericSourceTypeDefinition } from '../base/tasks.mjs' ;
@@ -40,6 +46,8 @@ export default class JavaGenerator extends BaseApplicationGenerator<GeneratorDef
4046 generateEntities ! : boolean ;
4147 useJakartaValidation ! : boolean ;
4248 generateEnums ! : boolean ;
49+ generateBuiltInUser ! : boolean ;
50+ generateBuiltInUserTests ! : boolean ;
4351
4452 async beforeQueue ( ) {
4553 if ( ! this . fromBlueprint ) {
@@ -132,11 +140,33 @@ export default class JavaGenerator extends BaseApplicationGenerator<GeneratorDef
132140 if ( ! this . generateEntities ) return ;
133141
134142 const { useJakartaValidation } = this ;
135- for ( const entity of entities . filter ( entity => ! entity . skipServer && ! entity . builtIn ) ) {
136- await this . writeFiles ( {
137- sections : entityServerFiles ,
138- context : { ...application , ...entity , useJakartaValidation } ,
139- } ) ;
143+ for ( const entity of entities . filter ( entity => ! entity . skipServer ) ) {
144+ if ( entity . builtIn ) {
145+ if ( ( entity as any ) . builtInUser ) {
146+ await this . writeFiles ( {
147+ blocks : [
148+ javaMainPackageTemplatesBlock ( {
149+ condition : ( ) => this . generateBuiltInUser ,
150+ templates : [ '_entityPackage_/domain/_persistClass_.java.jhi' ] ,
151+ } ) ,
152+ javaMainPackageTemplatesBlock ( {
153+ condition : ctx => ctx . useJakartaValidation && this . generateBuiltInUser ,
154+ templates : [ '_entityPackage_/domain/_persistClass_.java.jhi.jakarta_validation' ] ,
155+ } ) ,
156+ javaTestPackageTemplatesBlock ( {
157+ condition : ( ) => this . generateBuiltInUser || this . generateBuiltInUserTests ,
158+ templates : [ '_entityPackage_/domain/_persistClass_Test.java' , '_entityPackage_/domain/_persistClass_TestSamples.java' ] ,
159+ } ) ,
160+ ] ,
161+ context : { ...application , ...entity , useJakartaValidation } ,
162+ } ) ;
163+ }
164+ } else {
165+ await this . writeFiles ( {
166+ sections : entityServerFiles ,
167+ context : { ...application , ...entity , useJakartaValidation } ,
168+ } ) ;
169+ }
140170 }
141171 } ,
142172
0 commit comments