diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogConstants.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogConstants.java index ce1cee41..ca3b41b3 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogConstants.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogConstants.java @@ -44,6 +44,7 @@ private DaogenCatalogConstants() {} public static final String GEN_PROP_PACKAGE_MODEL = "package-model"; public static final String GEN_PROP_PACKAGE_HELPER = "package-helper"; + public static final String GEN_PROP_PACKAGE_HELPER_MICROPROFILE = "package-helper-microprofile"; public static final String GEN_PROP_PACKAGE_FACADE_DEF = "package-facade-def"; public static final String GEN_PROP_PACKAGE_FACADE_DATA_IMPL = "package-facade-data-impl"; public static final String GEN_PROP_PACKAGE_RSE = "package-rse"; @@ -111,6 +112,8 @@ private DaogenCatalogConstants() {} public static final String PREFIX_HELPER = "Helper"; public static final String PREFIX_WRAPPER = "Wrapper"; + + public static final String PREFIX_MPSCHEMA = "MPSchema"; public static final String PREFIX_RESTLOAD = "Load"; @@ -149,6 +152,10 @@ public static String rseName( DaogenCatalogEntity entity ) { public static String wrapperName( DaogenCatalogEntity entity ) { return PREFIX_WRAPPER+entity.toClassName(); } + + public static String mpSchemaName( DaogenCatalogEntity entity ) { + return PREFIX_MPSCHEMA+entity.toClassName(); + } public static String finderlName( DaogenCatalogEntity entity ) { return entity.toClassName()+SUFFIX_FINDER; diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogField.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogField.java index 77a96dba..7ad6c935 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogField.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenCatalogField.java @@ -18,8 +18,9 @@ public class DaogenCatalogField extends BasicIdConfigType { public static final String ATT_COMMENTS = "comments"; public static final String ATT_UDT = "udt"; public static final String ATT_STRUCT_TYPE = "structType"; - + public static final String ATT_STRUCT_SQL_TYPE = "structSqlType="; public static final String ATT_VIRTUAL = "virtual"; + public static final String ATT_EXAMPLE_DATA = "exampleData"; /** * @@ -48,6 +49,8 @@ public class DaogenCatalogField extends BasicIdConfigType { private String virtual; + private String exampleData; + public boolean isUserType() { return BooleanUtils.isTrue( this.getUdt() ); } @@ -140,6 +143,15 @@ public void setVirtual(String virtual) { this.virtual = virtual; } + public String getExampleData() { + return exampleData; + } + + public void setExampleData(String exampleData) { + this.exampleData = exampleData; + } + + public String describe() { List list = new ArrayList<>(); list.add( StringUtils.concat( ":" , ATT_SQL_TYPE, this.getSqlType() ) ); @@ -151,6 +163,7 @@ public String describe() { list.add( StringUtils.concat( ":" , ATT_UDT, this.getUdt() ) ); list.add( StringUtils.concat( ":" , ATT_STRUCT_TYPE, this.getStructType() ) ); list.add( StringUtils.concat( ":" , ATT_VIRTUAL, this.getVirtual() ) ); + list.add( StringUtils.concat( ":" , ATT_EXAMPLE_DATA, this.getExampleData() ) ); return StringUtils.concat( ",", list ); } diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java index 81097f99..b9f32c97 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java @@ -35,7 +35,7 @@ public abstract class DaogenBasicGenerator extends SimpleJavaGenerator implement protected static final String CLOSE_AND_THROWS = " ) throws "; - protected static final String AT_OVERRIDE = "@Override"; + public static final String AT_OVERRIDE = "@Override"; protected static final String REAL_CLASS_COMMENT = TAB+"// [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten)"; @@ -71,7 +71,7 @@ public abstract class DaogenBasicGenerator extends SimpleJavaGenerator implement protected static final String RETURN_RES_LIT = "return res;"; - protected static final String PUBLIC_SPACE_LIT = "public "; + public static final String PUBLIC_SPACE_LIT = "public "; protected static final String PUBLIC_STATIC_SPACE_LIT = "public static "; @@ -162,7 +162,7 @@ protected boolean isJdkVersionEquals( Integer jdkVerson ) { return this.getJdkTargetVersion().intValue() == jdkVerson.intValue(); } - protected boolean isJdkVersionAtLeast( Integer jdkVerson ) { + public boolean isJdkVersionAtLeast( Integer jdkVerson ) { return this.getJdkTargetVersion().intValue() >= jdkVerson.intValue(); } @@ -270,7 +270,7 @@ public String getEntityHelperName() { public String getEntityWrapperName() { return DaogenCatalogConstants.wrapperName( this.getCurrentEntity() ); } - + public String getEntityFacadeDefName() { return DaogenCatalogConstants.facadeDefName( this.getCurrentEntity() ); } @@ -377,7 +377,7 @@ public String getClassBaseWrapper() { return classBaseWrapper; } - protected void setClassBaseWrapper(String classBaseWrapper) { + public void setClassBaseWrapper(String classBaseWrapper) { this.classBaseWrapper = classBaseWrapper; } @@ -472,7 +472,7 @@ protected void beforeClass() { } } - protected void generateSerial( boolean condition ) throws IOException { + public void generateSerial( boolean condition ) throws IOException { if ( condition ) { this.addSerialVerUID(); this.writeSerialHelpers(); @@ -494,4 +494,13 @@ protected void writeSerialHelpers() { this.getWriter().println(); } + @Override + public void setExtendsClass(String extendsClass) { + super.setExtendsClass(extendsClass); + } + + @Override + public void setImplementsInterface(String implementsInterface) { + super.setImplementsInterface(implementsInterface); + } } diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/MicroProfileSchemaWrapperGenerator.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/MicroProfileSchemaWrapperGenerator.java new file mode 100644 index 00000000..22e1244f --- /dev/null +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/MicroProfileSchemaWrapperGenerator.java @@ -0,0 +1,58 @@ +package org.fugerit.java.daogen.base.gen; + +import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.lang.helpers.StringUtils; +import org.fugerit.java.daogen.base.config.*; +import org.fugerit.java.daogen.base.gen.util.WrapperUtils; + +import java.io.IOException; + +public class MicroProfileSchemaWrapperGenerator extends DaogenBasicGenerator { + + public static final String KEY = "MicroProfileSchemaWrapperGenerator"; + + @Override + public String getKey() { + return KEY; + } + + public void init( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity ) throws ConfigException { + super.init( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_SRC_MAIN_JAVA ), + fullObjectName( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE ), DaogenCatalogConstants.mpSchemaName( entity ) ), + STYLE_CLASS, daogenConfig, entity ); + this.getImportList().add( "org.eclipse.microprofile.openapi.annotations.media.Schema" ); + WrapperUtils.init( daogenConfig, entity, this ); + new DaogenBasicDecorator() { + @Override + public void addBeforeClass() throws DAOException { + super.addBeforeClass(); + if ( StringUtils.isNotEmpty( entity.getComments() ) ) { + this.accessGenerator().println( String.format( "@Schema( description = \"%s\")" , entity.getComments() ) ); + } + } + }.init( this ); + } + + @Override + public String getEntityWrapperName() { + return DaogenCatalogConstants.mpSchemaName( this.getCurrentEntity() ); + } + + @Override + public void generateDaogenBody() throws IOException { + WrapperUtils.generateBody( this, f -> { + if (StringUtils.isNotEmpty( f.getComments() ) ) { + String base = "@Schema( description = \"%s\" %s)"; + String extra = ""; + if ( StringUtils.isNotEmpty( f.getExampleData() ) ) { + extra = String.format( ", example =\"%s\"", f.getExampleData() ); + } + return String.format( base , f.getComments(), extra ); + } else { + return null; + } + } ); + } + +} diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/WrapperGenerator.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/WrapperGenerator.java index 6bfcd29d..fd624be0 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/WrapperGenerator.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/WrapperGenerator.java @@ -12,6 +12,7 @@ import org.fugerit.java.daogen.base.config.DaogenCatalogField; import org.fugerit.java.daogen.base.config.DaogenCatalogRelation; import org.fugerit.java.daogen.base.config.DaogenClassConfigHelper; +import org.fugerit.java.daogen.base.gen.util.WrapperUtils; public class WrapperGenerator extends DaogenBasicGenerator { @@ -26,119 +27,12 @@ public void init( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity ) super.init( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_SRC_MAIN_JAVA ), fullObjectName( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER ), DaogenCatalogConstants.wrapperName( entity ) ), STYLE_CLASS, daogenConfig, entity ); - String daoWrapperNgMode = daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED ); - logger.info( "{} -> {}", DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, daoWrapperNgMode ); - if ( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED.equalsIgnoreCase( daoWrapperNgMode ) ) { - this.setClassBaseWrapper( DaogenClassConfigHelper.addImport( daogenConfig , DaogenClassConfigHelper.DAO_WRAPPER_BASE, this.getImportList() ) ); - this.setExtendsClass( this.getClassBaseWrapper()+"<"+this.getEntityModelName()+">" ); - } else if ( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_ENABLED.equalsIgnoreCase( daoWrapperNgMode ) ) { - String wrapperNgClass = DaogenClassConfigHelper.findClassConfigProp( daogenConfig, DaogenClassConfigHelper.DAO_WRAPPER_NG_BASE, DaogenClassConfigHelper.DAO_BASE_CLASS ); - if ( StringUtils.isNotEmpty( wrapperNgClass ) ) { - this.setClassBaseWrapper( DaogenClassConfigHelper.addImport( daogenConfig , DaogenClassConfigHelper.DAO_WRAPPER_NG_BASE, this.getImportList() ) ); - this.setExtendsClass( this.getClassBaseWrapper()+"<"+this.getEntityModelName()+">" ); - } - } else { - throw new ConfigException( "Invalid "+DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE+" parameter : "+daoWrapperNgMode ); - } - this.getImportList().add( this.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_MODEL )+"."+this.getEntityModelName() ); - this.setImplementsInterface( this.getEntityModelName() ); - for ( DaogenCatalogRelation relation : this.getCurrentEntity().getRelations() ) { - DaogenCatalogEntity entityTo = this.getDaogenConfig().getListMap( relation.getTo() ); - this.getImportList().add( this.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_MODEL )+"."+DaogenCatalogConstants.modelName( entityTo ) ); - } - } - - private void generateRelations() { - if ( !this.getCurrentEntity().getRelations().isEmpty() ) { - this.getWriter().println( TAB+"/*" ); - this.getWriter().println( TAB+" * fields generated for relations " ); - this.getWriter().println( TAB+" */" ); - this.getWriter().println(); - for ( DaogenCatalogRelation relation : this.getCurrentEntity().getRelations() ) { - DaogenCatalogEntity entityTo = this.getDaogenConfig().getListMap( relation.getTo() ); - String baseType = DaogenCatalogConstants.modelName( entityTo ); - String className = GeneratorNameHelper.toClassName( relation.getName() ); - if ( DaogenCatalogRelation.MODE_MANY.equalsIgnoreCase( relation.getMode() ) ) { - baseType = "java.util.List<"+baseType+">"; - } - // metodo set - this.getWriter().println( TAB+AT_OVERRIDE ); - this.getWriter().println( TAB+"public void set"+className+"( "+baseType+" value ) {" ); - this.getWriter().println( TAB_2+"this.unwrapModel().set"+className+"( value );" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - // metodo get - this.getWriter().println( TAB+AT_OVERRIDE ); - this.getWriter().println( TAB+PUBLIC_SPACE_LIT+baseType+" get"+className+"() {" ); - this.getWriter().println( TAB_2+"return this.unwrapModel().get"+className+"();" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - } - } + WrapperUtils.init( daogenConfig, entity, this ); } @Override public void generateDaogenBody() throws IOException { - String daoWrapperNgMode = this.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED ); - this.generateSerial( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED.equalsIgnoreCase( daoWrapperNgMode ) ); - this.getWriter().println( TAB+PUBLIC_SPACE_LIT+this.getEntityWrapperName()+"( "+this.getEntityModelName()+" wrapped ) {" ); - this.getWriter().println( TAB_2+"super( wrapped );" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - this.getWriter().println( TAB+PUBLIC_SPACE_LIT+this.getEntityModelName()+" unwrap( "+this.getEntityWrapperName()+" wrapper ) {" ); - this.getWriter().println( TAB_2+""+this.getEntityModelName()+" res = wrapper;" ); - if ( this.isJdkVersionAtLeast( DaogenCatalogConstants.GEN_PROP_JDK_TARGET_VERSION_17 ) ) { - this.getWriter().println( TAB_2+"while ( res instanceof "+this.getEntityWrapperName()+" wrappedinstance ) { " ); - this.getWriter().println( TAB_3+"res = wrappedinstance.unwrapModel();" ); - } else { - this.getWriter().println( TAB_2+"while ( res instanceof "+this.getEntityWrapperName()+" ) { " ); - this.getWriter().println( TAB_3+"res = (("+this.getEntityWrapperName()+")res).unwrapModel();" ); - } - this.getWriter().println( TAB_2+"}" ); - this.getWriter().println( TAB_2+"return res;" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - - boolean relationLast = "true".equalsIgnoreCase( this.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_RELATIONS_LAST ) ); - if ( !relationLast ) { - this.generateRelations(); - } - - this.getWriter().println( TAB+"/*" ); - this.getWriter().println( TAB+" * fields generated for entity attributes " ); - this.getWriter().println( TAB+" */" ); - for ( DaogenCatalogField field : this.getCurrentEntity().getAllFields() ) { - // property - String javaSuffix = GeneratorNameHelper.toClassName( field.getId() ); - String realJavaType = this.getDaogenConfig().getTypeMapper().mapForModel( field ); - // metodo set - this.getWriter().println( TAB+AT_OVERRIDE ); - this.getWriter().println( TAB+"public void set"+javaSuffix+"( "+realJavaType+" value ) {" ); - this.getWriter().println( TAB_2+"this.unwrapModel().set"+javaSuffix+"( value );" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - // metodo get - this.getWriter().println( TAB+AT_OVERRIDE ); - this.getWriter().println( TAB+PUBLIC_SPACE_LIT+realJavaType+" get"+javaSuffix+"() {" ); - this.getWriter().println( TAB_2+"return this.unwrapModel().get"+javaSuffix+"();" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - } - - if ( relationLast ) { - this.generateRelations(); - } - - if ( BooleanUtils.isTrue( this.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_CHECK_EMPTY_INTERFACE ) ) ) { - this.getWriter().println( TAB+AT_OVERRIDE ); - this.getWriter().println( TAB+"public boolean isEmpty() {" ); - this.getWriter().println( TAB_2+"return this.unwrapModel().isEmpty();" ); - this.getWriter().println( TAB+"}" ); - this.getWriter().println(); - } - + WrapperUtils.generateBody( this, f -> null ); } - - } diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/WrapperUtils.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/WrapperUtils.java new file mode 100644 index 00000000..c834d924 --- /dev/null +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/WrapperUtils.java @@ -0,0 +1,136 @@ +package org.fugerit.java.daogen.base.gen.util; + +import lombok.extern.slf4j.Slf4j; +import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.core.javagen.GeneratorNameHelper; +import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.core.lang.helpers.StringUtils; +import org.fugerit.java.daogen.base.config.*; +import org.fugerit.java.daogen.base.gen.DaogenBasicGenerator; + +import java.io.IOException; +import java.util.function.Consumer; +import java.util.function.Function; + +@Slf4j +public class WrapperUtils { + + private WrapperUtils() {} + + public static void init(DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity, DaogenBasicGenerator gen ) throws ConfigException { + String daoWrapperNgMode = daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED ); + log.info( "{} -> {}", DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, daoWrapperNgMode ); + if ( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED.equalsIgnoreCase( daoWrapperNgMode ) ) { + gen.setClassBaseWrapper( DaogenClassConfigHelper.addImport( daogenConfig , DaogenClassConfigHelper.DAO_WRAPPER_BASE, gen.getImportList() ) ); + gen.setExtendsClass( gen.getClassBaseWrapper()+"<"+gen.getEntityModelName()+">" ); + } else if ( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_ENABLED.equalsIgnoreCase( daoWrapperNgMode ) ) { + String wrapperNgClass = DaogenClassConfigHelper.findClassConfigProp( daogenConfig, DaogenClassConfigHelper.DAO_WRAPPER_NG_BASE, DaogenClassConfigHelper.DAO_BASE_CLASS ); + if ( StringUtils.isNotEmpty( wrapperNgClass ) ) { + gen.setClassBaseWrapper( DaogenClassConfigHelper.addImport( daogenConfig , DaogenClassConfigHelper.DAO_WRAPPER_NG_BASE, gen.getImportList() ) ); + gen.setExtendsClass( gen.getClassBaseWrapper()+"<"+gen.getEntityModelName()+">" ); + } + } else { + throw new ConfigException( "Invalid "+DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE+" parameter : "+daoWrapperNgMode ); + } + gen.getImportList().add( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_MODEL )+"."+gen.getEntityModelName() ); + gen.setImplementsInterface( gen.getEntityModelName() ); + for ( DaogenCatalogRelation relation : gen.getCurrentEntity().getRelations() ) { + DaogenCatalogEntity entityTo = gen.getDaogenConfig().getListMap( relation.getTo() ); + gen.getImportList().add( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_MODEL )+"."+DaogenCatalogConstants.modelName( entityTo ) ); + } + } + + public static void generateRelations(DaogenBasicGenerator gen ) { + if ( !gen.getCurrentEntity().getRelations().isEmpty() ) { + gen.getWriter().println( DaogenBasicGenerator.TAB+"/*" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+" * fields generated for relations " ); + gen.getWriter().println( DaogenBasicGenerator.TAB+" */" ); + gen.getWriter().println(); + for ( DaogenCatalogRelation relation : gen.getCurrentEntity().getRelations() ) { + DaogenCatalogEntity entityTo = gen.getDaogenConfig().getListMap( relation.getTo() ); + String baseType = DaogenCatalogConstants.modelName( entityTo ); + String className = GeneratorNameHelper.toClassName( relation.getName() ); + if ( DaogenCatalogRelation.MODE_MANY.equalsIgnoreCase( relation.getMode() ) ) { + baseType = "java.util.List<"+baseType+">"; + } + // metodo set + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.AT_OVERRIDE ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"public void set"+className+"( "+baseType+" value ) {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"this.unwrapModel().set"+className+"( value );" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + // metodo get + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.AT_OVERRIDE ); + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.PUBLIC_SPACE_LIT+baseType+" get"+className+"() {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"return this.unwrapModel().get"+className+"();" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + } + } + } + + public static void generateBody( DaogenBasicGenerator gen, Function getterDecorator ) throws IOException { + String daoWrapperNgMode = gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE, DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED ); + gen.generateSerial( DaogenCatalogConstants.GEN_PROP_DAO_WRAPPER_NG_MODE_DISABLED.equalsIgnoreCase( daoWrapperNgMode ) ); + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.PUBLIC_SPACE_LIT+gen.getEntityWrapperName()+"( "+gen.getEntityModelName()+" wrapped ) {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"super( wrapped );" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.PUBLIC_SPACE_LIT+gen.getEntityModelName()+" unwrap( "+gen.getEntityWrapperName()+" wrapper ) {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+""+gen.getEntityModelName()+" res = wrapper;" ); + if ( gen.isJdkVersionAtLeast( DaogenCatalogConstants.GEN_PROP_JDK_TARGET_VERSION_17 ) ) { + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"while ( res instanceof "+gen.getEntityWrapperName()+" wrappedinstance ) { " ); + gen.getWriter().println( DaogenBasicGenerator.TAB_3+"res = wrappedinstance.unwrapModel();" ); + } else { + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"while ( res instanceof "+gen.getEntityWrapperName()+" ) { " ); + gen.getWriter().println( DaogenBasicGenerator.TAB_3+"res = (("+gen.getEntityWrapperName()+")res).unwrapModel();" ); + } + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"}" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"return res;" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + + boolean relationLast = "true".equalsIgnoreCase( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_RELATIONS_LAST ) ); + if ( !relationLast ) { + generateRelations( gen ); + } + + gen.getWriter().println( DaogenBasicGenerator.TAB+"/*" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+" * fields generated for entity attributes " ); + gen.getWriter().println( DaogenBasicGenerator.TAB+" */" ); + for ( DaogenCatalogField field : gen.getCurrentEntity().getAllFields() ) { + // property + String javaSuffix = GeneratorNameHelper.toClassName( field.getId() ); + String realJavaType = gen.getDaogenConfig().getTypeMapper().mapForModel( field ); + // metodo set + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.AT_OVERRIDE ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"public void set"+javaSuffix+"( "+realJavaType+" value ) {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"this.unwrapModel().set"+javaSuffix+"( value );" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + // metodo get + String decorateGet = getterDecorator.apply( field ); + if ( StringUtils.isNotEmpty( decorateGet ) ) { + gen.getWriter().println( DaogenBasicGenerator.TAB+decorateGet ); + } + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.AT_OVERRIDE ); + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.PUBLIC_SPACE_LIT+realJavaType+" get"+javaSuffix+"() {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"return this.unwrapModel().get"+javaSuffix+"();" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + } + + if ( relationLast ) { + generateRelations( gen ); + } + + if ( BooleanUtils.isTrue( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_CHECK_EMPTY_INTERFACE ) ) ) { + gen.getWriter().println( DaogenBasicGenerator.TAB+DaogenBasicGenerator.AT_OVERRIDE ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"public boolean isEmpty() {" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"return this.unwrapModel().isEmpty();" ); + gen.getWriter().println( DaogenBasicGenerator.TAB+"}" ); + gen.getWriter().println(); + } + } + +} diff --git a/fj-daogen-base/src/main/resources/config/daogen-config-1-0.xsd b/fj-daogen-base/src/main/resources/config/daogen-config-1-0.xsd index c88c01f7..a3183ffa 100644 --- a/fj-daogen-base/src/main/resources/config/daogen-config-1-0.xsd +++ b/fj-daogen-base/src/main/resources/config/daogen-config-1-0.xsd @@ -156,14 +156,21 @@ The entry point for daogen-config documentation is : https://marsdocs.fugerit.or The package to be used for model interfaces, for each entity. (e.g. 'org.fugerit.java.daogen.sample.def.model'). - The relevant generators and decorators will only by run if this property is set. + The relevant generators and decorators will only run if this property is set. The package to be used for basic model implementation classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.helper'). - The relevant generators and decorators will only by run if this property is set. + The relevant generators and decorators will only run if this property is set. + + + + + The package to be used model helper on miprofile specification. + (e.g. 'org.fugerit.java.daogen.sample.impl.helper' or 'org.fugerit.java.daogen.sample.impl.microprofile'). + The relevant generators and decorators will only run if this property is set. diff --git a/fj-daogen-base/src/main/resources/config/default-generator-catalog.xml b/fj-daogen-base/src/main/resources/config/default-generator-catalog.xml index 8a31f7ff..d2087997 100644 --- a/fj-daogen-base/src/main/resources/config/default-generator-catalog.xml +++ b/fj-daogen-base/src/main/resources/config/default-generator-catalog.xml @@ -19,6 +19,9 @@ + diff --git a/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml b/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml index 6b992ee2..2d5ff93b 100644 --- a/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml +++ b/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml @@ -19,6 +19,7 @@ struct_prefix="OBJ_" package-model="org.fugerit.java.daogen.sample.def.model" package-helper="org.fugerit.java.daogen.sample.impl.helper" + package-helper-microprofile="org.fugerit.java.daogen.sample.impl.helper" dao-helper-ng-mode="enabled" dao-wrapper-ng-mode="enabled" dao-finder-ng-mode="enabled" @@ -45,7 +46,7 @@ - + diff --git a/fj-daogen-sample/pom.xml b/fj-daogen-sample/pom.xml index a2bfb9e8..dfaa67d3 100644 --- a/fj-daogen-sample/pom.xml +++ b/fj-daogen-sample/pom.xml @@ -86,6 +86,12 @@ javax.ws.rs-api ${javax-rs-api-version} + + + org.eclipse.microprofile.openapi + microprofile-openapi-api + 3.1.2 + diff --git a/fj-daogen-sample/src/main/daogen/fugerit-sample-daogen-config.xml b/fj-daogen-sample/src/main/daogen/fugerit-sample-daogen-config.xml index dfa202f1..f6e39e7a 100644 --- a/fj-daogen-sample/src/main/daogen/fugerit-sample-daogen-config.xml +++ b/fj-daogen-sample/src/main/daogen/fugerit-sample-daogen-config.xml @@ -18,6 +18,7 @@ struct_prefix="OBJ_" package-model="org.fugerit.java.daogen.sample.def.model" package-helper="org.fugerit.java.daogen.sample.impl.helper" + package-helper-microprofile="org.fugerit.java.daogen.sample.impl.helper" package-struct="org.fugerit.java.daogen.sample.impl.struct" package-rse="org.fugerit.java.daogen.sample.impl.rse" package-facade-def="org.fugerit.java.daogen.sample.def.facade" @@ -38,8 +39,8 @@ - - + + diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaAddress.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaAddress.java new file mode 100644 index 00000000..451bd245 --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaAddress.java @@ -0,0 +1,127 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; +import org.fugerit.java.daogen.sample.def.model.ModelUser; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaAddress, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +@Schema( description = "Contains addresses data") +public class MPSchemaAddress extends BasicWrapper implements ModelAddress { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 55955275663L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaAddress( ModelAddress wrapped ) { + super( wrapped ); + } + + public ModelAddress unwrap( MPSchemaAddress wrapper ) { + ModelAddress res = wrapper; + while ( res instanceof MPSchemaAddress ) { + res = ((MPSchemaAddress)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for relations + */ + + @Override + public void setUser( ModelUser value ) { + this.unwrapModel().setUser( value ); + } + + @Override + public ModelUser getUser() { + return this.unwrapModel().getUser(); + } + + /* + * fields generated for entity attributes + */ + @Override + public void setId( java.math.BigDecimal value ) { + this.unwrapModel().setId( value ); + } + + @Schema( description = "Address system id" ) + @Override + public java.math.BigDecimal getId() { + return this.unwrapModel().getId(); + } + + @Override + public void setIdUser( java.math.BigDecimal value ) { + this.unwrapModel().setIdUser( value ); + } + + @Schema( description = "User linked to to address" ) + @Override + public java.math.BigDecimal getIdUser() { + return this.unwrapModel().getIdUser(); + } + + @Override + public void setDateInsert( java.util.Date value ) { + this.unwrapModel().setDateInsert( value ); + } + + @Override + public java.util.Date getDateInsert() { + return this.unwrapModel().getDateInsert(); + } + + @Override + public void setDateUpdate( java.util.Date value ) { + this.unwrapModel().setDateUpdate( value ); + } + + @Override + public java.util.Date getDateUpdate() { + return this.unwrapModel().getDateUpdate(); + } + + @Override + public void setInfo( java.lang.String value ) { + this.unwrapModel().setInfo( value ); + } + + @Schema( description = "Address info" ) + @Override + public java.lang.String getInfo() { + return this.unwrapModel().getInfo(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaLogData.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaLogData.java new file mode 100644 index 00000000..cfe3c24f --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaLogData.java @@ -0,0 +1,88 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelLogData; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaLogData, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +public class MPSchemaLogData extends BasicWrapper implements ModelLogData { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 563094774199L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaLogData( ModelLogData wrapped ) { + super( wrapped ); + } + + public ModelLogData unwrap( MPSchemaLogData wrapper ) { + ModelLogData res = wrapper; + while ( res instanceof MPSchemaLogData ) { + res = ((MPSchemaLogData)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for entity attributes + */ + @Override + public void setId( java.math.BigDecimal value ) { + this.unwrapModel().setId( value ); + } + + @Override + public java.math.BigDecimal getId() { + return this.unwrapModel().getId(); + } + + @Override + public void setLogTime( java.util.Date value ) { + this.unwrapModel().setLogTime( value ); + } + + @Override + public java.util.Date getLogTime() { + return this.unwrapModel().getLogTime(); + } + + @Override + public void setInfo( java.lang.String value ) { + this.unwrapModel().setInfo( value ); + } + + @Override + public java.lang.String getInfo() { + return this.unwrapModel().getInfo(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaTestTwoFieldKey.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaTestTwoFieldKey.java new file mode 100644 index 00000000..0c176c24 --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaTestTwoFieldKey.java @@ -0,0 +1,88 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelTestTwoFieldKey; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaTestTwoFieldKey, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +public class MPSchemaTestTwoFieldKey extends BasicWrapper implements ModelTestTwoFieldKey { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 859066783467L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaTestTwoFieldKey( ModelTestTwoFieldKey wrapped ) { + super( wrapped ); + } + + public ModelTestTwoFieldKey unwrap( MPSchemaTestTwoFieldKey wrapper ) { + ModelTestTwoFieldKey res = wrapper; + while ( res instanceof MPSchemaTestTwoFieldKey ) { + res = ((MPSchemaTestTwoFieldKey)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for entity attributes + */ + @Override + public void setIdOne( java.math.BigDecimal value ) { + this.unwrapModel().setIdOne( value ); + } + + @Override + public java.math.BigDecimal getIdOne() { + return this.unwrapModel().getIdOne(); + } + + @Override + public void setIdTwo( java.math.BigDecimal value ) { + this.unwrapModel().setIdTwo( value ); + } + + @Override + public java.math.BigDecimal getIdTwo() { + return this.unwrapModel().getIdTwo(); + } + + @Override + public void setInfo( java.lang.String value ) { + this.unwrapModel().setInfo( value ); + } + + @Override + public java.lang.String getInfo() { + return this.unwrapModel().getInfo(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUpload.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUpload.java new file mode 100644 index 00000000..81e620fd --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUpload.java @@ -0,0 +1,99 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelUpload; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaUpload, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +@Schema( description = "Contains upload blob") +public class MPSchemaUpload extends BasicWrapper implements ModelUpload { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 771584320947L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaUpload( ModelUpload wrapped ) { + super( wrapped ); + } + + public ModelUpload unwrap( MPSchemaUpload wrapper ) { + ModelUpload res = wrapper; + while ( res instanceof MPSchemaUpload ) { + res = ((MPSchemaUpload)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for entity attributes + */ + @Override + public void setId( java.math.BigDecimal value ) { + this.unwrapModel().setId( value ); + } + + @Override + public java.math.BigDecimal getId() { + return this.unwrapModel().getId(); + } + + @Override + public void setDateInsert( java.util.Date value ) { + this.unwrapModel().setDateInsert( value ); + } + + @Override + public java.util.Date getDateInsert() { + return this.unwrapModel().getDateInsert(); + } + + @Override + public void setDateUpdate( java.util.Date value ) { + this.unwrapModel().setDateUpdate( value ); + } + + @Override + public java.util.Date getDateUpdate() { + return this.unwrapModel().getDateUpdate(); + } + + @Override + public void setContent( org.fugerit.java.core.db.daogen.ByteArrayDataHandler value ) { + this.unwrapModel().setContent( value ); + } + + @Override + public org.fugerit.java.core.db.daogen.ByteArrayDataHandler getContent() { + return this.unwrapModel().getContent(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUser.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUser.java new file mode 100644 index 00000000..ef57511f --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUser.java @@ -0,0 +1,160 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; +import org.fugerit.java.daogen.sample.def.model.ModelUser; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaUser, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +@Schema( description = "Contains users data") +public class MPSchemaUser extends BasicWrapper implements ModelUser { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 755961802500L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaUser( ModelUser wrapped ) { + super( wrapped ); + } + + public ModelUser unwrap( MPSchemaUser wrapper ) { + ModelUser res = wrapper; + while ( res instanceof MPSchemaUser ) { + res = ((MPSchemaUser)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for relations + */ + + @Override + public void setUserAddresses( java.util.List value ) { + this.unwrapModel().setUserAddresses( value ); + } + + @Override + public java.util.List getUserAddresses() { + return this.unwrapModel().getUserAddresses(); + } + + /* + * fields generated for entity attributes + */ + @Override + public void setId( java.math.BigDecimal value ) { + this.unwrapModel().setId( value ); + } + + @Schema( description = "User system id" , example ="123") + @Override + public java.math.BigDecimal getId() { + return this.unwrapModel().getId(); + } + + @Override + public void setUsername( java.lang.String value ) { + this.unwrapModel().setUsername( value ); + } + + @Schema( description = "User chosen id" , example ="user1") + @Override + public java.lang.String getUsername() { + return this.unwrapModel().getUsername(); + } + + @Override + public void setPassword( java.lang.String value ) { + this.unwrapModel().setPassword( value ); + } + + @Schema( description = "Password hash" ) + @Override + public java.lang.String getPassword() { + return this.unwrapModel().getPassword(); + } + + @Override + public void setLastLogin( java.util.Date value ) { + this.unwrapModel().setLastLogin( value ); + } + + @Schema( description = "Time of last user login" ) + @Override + public java.util.Date getLastLogin() { + return this.unwrapModel().getLastLogin(); + } + + @Override + public void setDateInsert( java.util.Date value ) { + this.unwrapModel().setDateInsert( value ); + } + + @Override + public java.util.Date getDateInsert() { + return this.unwrapModel().getDateInsert(); + } + + @Override + public void setDateUpdate( java.util.Date value ) { + this.unwrapModel().setDateUpdate( value ); + } + + @Override + public java.util.Date getDateUpdate() { + return this.unwrapModel().getDateUpdate(); + } + + @Override + public void setState( java.math.BigDecimal value ) { + this.unwrapModel().setState( value ); + } + + @Schema( description = "1 active, 0 not active" ) + @Override + public java.math.BigDecimal getState() { + return this.unwrapModel().getState(); + } + + @Override + public void setStateVirtual( java.math.BigDecimal value ) { + this.unwrapModel().setStateVirtual( value ); + } + + @Schema( description = "1 active, 0 not active" ) + @Override + public java.math.BigDecimal getStateVirtual() { + return this.unwrapModel().getStateVirtual(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUserData.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUserData.java new file mode 100644 index 00000000..ca06e43d --- /dev/null +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/MPSchemaUserData.java @@ -0,0 +1,134 @@ +package org.fugerit.java.daogen.sample.impl.helper; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.fugerit.java.core.db.daogen.BasicWrapper; +import org.fugerit.java.daogen.sample.def.model.ModelUserData; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * MPSchemaUserData, version : 1.0.0 + * + * author: fugerit + * + * warning!: auto generated object, insert custom code only between comments : + * // custom code start ( code above here will be overwritten ) + * // custom code end ( code below here will be overwritten ) + */ +@Schema( description = "Contains users data") +public class MPSchemaUserData extends BasicWrapper implements ModelUserData { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 12158160465L; + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + out.defaultWriteObject(); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + // this class is conditionally serializable, depending on contained object + // special situation can be handled using this method in future + in.defaultReadObject(); + } + + public MPSchemaUserData( ModelUserData wrapped ) { + super( wrapped ); + } + + public ModelUserData unwrap( MPSchemaUserData wrapper ) { + ModelUserData res = wrapper; + while ( res instanceof MPSchemaUserData ) { + res = ((MPSchemaUserData)res).unwrapModel(); + } + return res; + } + + /* + * fields generated for entity attributes + */ + @Override + public void setId( java.math.BigDecimal value ) { + this.unwrapModel().setId( value ); + } + + @Schema( description = "User system id" ) + @Override + public java.math.BigDecimal getId() { + return this.unwrapModel().getId(); + } + + @Override + public void setUsername( java.lang.String value ) { + this.unwrapModel().setUsername( value ); + } + + @Schema( description = "User chosen id" ) + @Override + public java.lang.String getUsername() { + return this.unwrapModel().getUsername(); + } + + @Override + public void setPassword( java.lang.String value ) { + this.unwrapModel().setPassword( value ); + } + + @Schema( description = "Password hash" ) + @Override + public java.lang.String getPassword() { + return this.unwrapModel().getPassword(); + } + + @Override + public void setLastLogin( java.util.Date value ) { + this.unwrapModel().setLastLogin( value ); + } + + @Schema( description = "Time of last user login" ) + @Override + public java.util.Date getLastLogin() { + return this.unwrapModel().getLastLogin(); + } + + @Override + public void setDateInsert( java.util.Date value ) { + this.unwrapModel().setDateInsert( value ); + } + + @Override + public java.util.Date getDateInsert() { + return this.unwrapModel().getDateInsert(); + } + + @Override + public void setDateUpdate( java.util.Date value ) { + this.unwrapModel().setDateUpdate( value ); + } + + @Override + public java.util.Date getDateUpdate() { + return this.unwrapModel().getDateUpdate(); + } + + @Override + public void setState( java.math.BigDecimal value ) { + this.unwrapModel().setState( value ); + } + + @Schema( description = "1 active, 0 not active" ) + @Override + public java.math.BigDecimal getState() { + return this.unwrapModel().getState(); + } + + @Override + public boolean isEmpty() { + return this.unwrapModel().isEmpty(); + } + +} diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperAddress.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperAddress.java index 13bf5b51..4572d982 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperAddress.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperAddress.java @@ -21,7 +21,7 @@ public class WrapperAddress extends BasicWrapper implements ModelA // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 608697339771L; + private static final long serialVersionUID = 502806002084L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperLogData.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperLogData.java index e55f2d9f..c85402ba 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperLogData.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperLogData.java @@ -20,7 +20,7 @@ public class WrapperLogData extends BasicWrapper implements ModelL // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 827293319822L; + private static final long serialVersionUID = 576105439058L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperTestTwoFieldKey.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperTestTwoFieldKey.java index 46f32f51..38b29882 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperTestTwoFieldKey.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperTestTwoFieldKey.java @@ -20,7 +20,7 @@ public class WrapperTestTwoFieldKey extends BasicWrapper i // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 486564785574L; + private static final long serialVersionUID = 938209344374L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUpload.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUpload.java index 694483f6..ce32a956 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUpload.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUpload.java @@ -20,7 +20,7 @@ public class WrapperUpload extends BasicWrapper implements ModelUpl // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 714845245143L; + private static final long serialVersionUID = 146456998895L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUser.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUser.java index 0b0708ea..7bedffc6 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUser.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUser.java @@ -21,7 +21,7 @@ public class WrapperUser extends BasicWrapper implements ModelUser { // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 117929240875L; + private static final long serialVersionUID = 179401138402L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUserData.java b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUserData.java index 69a8296e..6bcfdf04 100644 --- a/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUserData.java +++ b/fj-daogen-sample/src/main/java/org/fugerit/java/daogen/sample/impl/helper/WrapperUserData.java @@ -20,7 +20,7 @@ public class WrapperUserData extends BasicWrapper implements Mode // custom code start ( code above here will be overwritten ) // custom code end ( code below here will be overwritten ) - private static final long serialVersionUID = 647032161858L; + private static final long serialVersionUID = 964012061980L; private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { // this class is conditionally serializable, depending on contained object diff --git a/src/docs/config/daogen-config-xsd-ref.html b/src/docs/config/daogen-config-xsd-ref.html index b34a5175..e757d75d 100644 --- a/src/docs/config/daogen-config-xsd-ref.html +++ b/src/docs/config/daogen-config-xsd-ref.html @@ -337,7 +337,7 @@

Reference daogen-config.xsd documentation for Ma package-model - The package to be used for model interfaces, for each entity. (e.g. 'org.fugerit.java.daogen.sample.def.model'). The relevant generators and decorators will only by run if this property is set. + The package to be used for model interfaces, for each entity. (e.g. 'org.fugerit.java.daogen.sample.def.model'). The relevant generators and decorators will only run if this property is set. string @@ -348,7 +348,7 @@

Reference daogen-config.xsd documentation for Ma package-helper - The package to be used for basic model implementation classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.helper'). The relevant generators and decorators will only by run if this property is set. + The package to be used for basic model implementation classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.helper'). The relevant generators and decorators will only run if this property is set. string @@ -356,21 +356,21 @@

Reference daogen-config.xsd documentation for Ma - disable-singleton + package-helper-microprofile - If set to 'enabled' the singleton generation. (i.e. RSE DEFAULT field). + The package to be used model helper on miprofile specification. (e.g. 'org.fugerit.java.daogen.sample.impl.helper' or 'org.fugerit.java.daogen.sample.impl.microprofile'). The relevant generators and decorators will only run if this property is set. - enabledDisabledType , base : string , enumeration : [ enabled , disabled ] + string - dao-helper-ng-mode + disable-singleton - If set to 'enabled' the 'dao.helper.ng' property set will be selected. NOTE: when enabled, Helper entities will not be made serializable. + If set to 'enabled' the singleton generation. (i.e. RSE DEFAULT field). enabledDisabledType , base : string , enumeration : [ enabled , disabled ] @@ -378,10 +378,10 @@

Reference daogen-config.xsd documentation for Ma - dao-wrapper-ng-mode + dao-helper-ng-mode - If set to 'enabled' the 'dao.wrapper.ng' property set will be selected. NOTE: when enabled, Wrapper entities will not be made serializable. + If set to 'enabled' the 'dao.helper.ng' property set will be selected. NOTE: when enabled, Helper entities will not be made serializable. enabledDisabledType , base : string , enumeration : [ enabled , disabled ] @@ -389,10 +389,10 @@

Reference daogen-config.xsd documentation for Ma - dao-finder-ng-mode + dao-wrapper-ng-mode - If set to 'enabled' the 'dao.finder.ng' property set will be selected. NOTE: when enabled, Finder entities will not be made serializable. + If set to 'enabled' the 'dao.wrapper.ng' property set will be selected. NOTE: when enabled, Wrapper entities will not be made serializable. enabledDisabledType , base : string , enumeration : [ enabled , disabled ] @@ -400,10 +400,10 @@

Reference daogen-config.xsd documentation for Ma - dao-rest-ng-mode + dao-finder-ng-mode - If set to 'enabled' the 'dao.rest.ng' property set will be selected. NOTE: when enabled, Rest entities will not be made serializable. + If set to 'enabled' the 'dao.finder.ng' property set will be selected. NOTE: when enabled, Finder entities will not be made serializable. enabledDisabledType , base : string , enumeration : [ enabled , disabled ] @@ -411,10 +411,10 @@

Reference daogen-config.xsd documentation for Ma - type-mapper-time-ng + dao-rest-ng-mode - If set to 'enabled' the model_ng property in type mapper is selected. NOTE: when enabled, By default java.time.LocalDate/LocalTime/LocalDateTime will be used for model. + If set to 'enabled' the 'dao.rest.ng' property set will be selected. NOTE: when enabled, Rest entities will not be made serializable. enabledDisabledType , base : string , enumeration : [ enabled , disabled ] @@ -422,21 +422,21 @@

Reference daogen-config.xsd documentation for Ma - package-struct + type-mapper-time-ng - The package to be used for database java.sql.String classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.struct'). The relevant generators and decorators will only by run if this property is set. + If set to 'enabled' the model_ng property in type mapper is selected. NOTE: when enabled, By default java.time.LocalDate/LocalTime/LocalDateTime will be used for model. - string + enabledDisabledType , base : string , enumeration : [ enabled , disabled ] - package-rse + package-struct - The package to be used for database org.fugerit.java.core.db.dao.RSExtractor classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.rse'). The relevant generators and decorators will only by run if this property is set. + The package to be used for database java.sql.String classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.struct'). The relevant generators and decorators will only by run if this property is set. string @@ -444,10 +444,10 @@

Reference daogen-config.xsd documentation for Ma - package-facade-def + package-rse - The package to be used for DAO facade interfaces, for each entity. (e.g. 'org.fugerit.java.daogen.sample.def.facade'). The relevant generators and decorators will only by run if this property is set. + The package to be used for database org.fugerit.java.core.db.dao.RSExtractor classes, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.rse'). The relevant generators and decorators will only by run if this property is set. string @@ -455,10 +455,10 @@

Reference daogen-config.xsd documentation for Ma - package-facade-data-impl + package-facade-def - The package to be used for DAO facade basic implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.facade.data'). The relevant generators and decorators will only by run if this property is set. + The package to be used for DAO facade interfaces, for each entity. (e.g. 'org.fugerit.java.daogen.sample.def.facade'). The relevant generators and decorators will only by run if this property is set. string @@ -466,10 +466,10 @@

Reference daogen-config.xsd documentation for Ma - factory-def + package-facade-data-impl - The fully qualified name to be used for DAO factory interface. (e.g. 'org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade'). The relevant generators and decorators will only by run if this property is set. + The package to be used for DAO facade basic implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.facade.data'). The relevant generators and decorators will only by run if this property is set. string @@ -477,10 +477,10 @@

Reference daogen-config.xsd documentation for Ma - factory-data-impl + factory-def - The fully qualified name to be used for DAO factory basic implementation. (e.g. 'org.fugerit.java.daogen.sample.impl.facade.data.FugeritDataLogicFacade'). The relevant generators and decorators will only by run if this property is set. + The fully qualified name to be used for DAO factory interface. (e.g. 'org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade'). The relevant generators and decorators will only by run if this property is set. string @@ -488,10 +488,10 @@

Reference daogen-config.xsd documentation for Ma - package-rest-load + factory-data-impl - The package to be used for a basic rest service implementation, for load methods, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.rest.load'). The relevant generators and decorators will only by run if this property is set. NOTE: REST services generation is not recommended, if not as a starting stub. + The fully qualified name to be used for DAO factory basic implementation. (e.g. 'org.fugerit.java.daogen.sample.impl.facade.data.FugeritDataLogicFacade'). The relevant generators and decorators will only by run if this property is set. string @@ -499,10 +499,10 @@

Reference daogen-config.xsd documentation for Ma - package-spring-rest-load + package-rest-load - The package to be used for a basic spring rest service implementation, for load methods, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.spring.rest.load'). The relevant generators and decorators will only by run if this property is set. NOTE: REST services generation is not recommended, if not as a starting stub. + The package to be used for a basic rest service implementation, for load methods, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.rest.load'). The relevant generators and decorators will only by run if this property is set. NOTE: REST services generation is not recommended, if not as a starting stub. string @@ -510,10 +510,10 @@

Reference daogen-config.xsd documentation for Ma - package-junit4-model + package-spring-rest-load - The package to be used for a basic junit 4 implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.junit4test.model'). The relevant generators and decorators will only by run if this property is set. NOTE: The junit generation is a very simple stub to start with. + The package to be used for a basic spring rest service implementation, for load methods, for each entity. (e.g. 'org.fugerit.java.daogen.sample.impl.spring.rest.load'). The relevant generators and decorators will only by run if this property is set. NOTE: REST services generation is not recommended, if not as a starting stub. string @@ -521,10 +521,10 @@

Reference daogen-config.xsd documentation for Ma - package-junit5-model + package-junit4-model - The package to be used for a basic junit 5 implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.junit5test.model'). The relevant generators and decorators will only by run if this property is set. NOTE: The junit generation is a very simple stub to start with. + The package to be used for a basic junit 4 implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.junit4test.model'). The relevant generators and decorators will only by run if this property is set. NOTE: The junit generation is a very simple stub to start with. string @@ -532,10 +532,10 @@

Reference daogen-config.xsd documentation for Ma - graalvm-reflect-config + package-junit5-model - Path to the reflect-config.json file to be created (e.g. 'daogen-reflect-config.json'). Initial folder is defined by 'src-main-resources' property. NOTE: Only one file for all the project will be created. + The package to be used for a basic junit 5 implementation, for each entity. (e.g. 'org.fugerit.java.daogen.sample.junit5test.model'). The relevant generators and decorators will only by run if this property is set. NOTE: The junit generation is a very simple stub to start with. string @@ -543,10 +543,10 @@

Reference daogen-config.xsd documentation for Ma - base-rest-service + graalvm-reflect-config - The base class for REST services. (e.g. 'org.fugerit.java.daogen.sample.helper.ServiceProviderHelper'). NOTE: REST services generation is not recommended, if not as a starting stub. + Path to the reflect-config.json file to be created (e.g. 'daogen-reflect-config.json'). Initial folder is defined by 'src-main-resources' property. NOTE: Only one file for all the project will be created. string @@ -554,32 +554,32 @@

Reference daogen-config.xsd documentation for Ma - openapi_host + base-rest-service - The host to be used for openapi specification and implementation specification. + The base class for REST services. (e.g. 'org.fugerit.java.daogen.sample.helper.ServiceProviderHelper'). NOTE: REST services generation is not recommended, if not as a starting stub. - anyURI + string - openapi_path + openapi_host - The path to be used for openapi specification and implementation specification. + The host to be used for openapi specification and implementation specification. - string + anyURI - default-sequence + openapi_path - The default sequence name to be used for the entities (it is possible to override it). + The path to be used for openapi specification and implementation specification. string @@ -587,10 +587,10 @@

Reference daogen-config.xsd documentation for Ma - check-empty-interface + default-sequence - If set to '1' will check if interfaces have no methods. NOTE: currently ignored. + The default sequence name to be used for the entities (it is possible to override it). string @@ -598,23 +598,34 @@

Reference daogen-config.xsd documentation for Ma - jdk-target-version + check-empty-interface - The jdk target version. + If set to '1' will check if interfaces have no methods. NOTE: currently ignored. - jdkTargetVersionType , base : string , enumeration : [ 8 , 11 , 17 , 21 ] + string - jee-target-mode + jdk-target-version - The enterprise edition target environment. + The jdk target version. + jdkTargetVersionType , base : string , enumeration : [ 8 , 11 , 17 , 21 ] + + + + + jee-target-mode + + + The enterprise edition target environment. + + jeeTargetModeType , base : string , enumeration : [ javax , jakarta ]