Skip to content

Commit a7773dc

Browse files
committed
1.1.5 (2023-08-29)
+ [fix] [fj-daogen-base] Fox to SpringBoot rest load generators + [documentation] [fj-daogen] Added documentation for daogen-config-1.0.xsd + [enhancement] [fj-daogen] Removed maven 'full' profile as not needed (inherited from fj-bom)
1 parent ad4eb1c commit a7773dc

File tree

15 files changed

+80
-25
lines changed

15 files changed

+80
-25
lines changed

docgen/parameters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title" : "Mars (Fugerit DAOGEN A.P.I.)",
33
"name": "Mars",
4-
"version" : "1.1.4",
5-
"date" : "27/08/2023",
4+
"version" : "1.1.5",
5+
"date" : "29/08/2023",
66
"organization" : {
77
"name" : "Fugerit Org",
88
"url" : "https://www.fugerit.org"

docgen/release-notes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
1.2.0 (next)
1+
1.1.5 (2023-08-29)
22
------------------
3+
+ [fix] [fj-daogen-base] Fox to SpringBoot rest load generators
34
+ [documentation] [fj-daogen] Added documentation for daogen-config-1.0.xsd
45
+ [enhancement] [fj-daogen] Removed maven 'full' profile as not needed (inherited from fj-bom)
56

fj-daogen-base/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-daogen</artifactId>
10-
<version>1.1.4</version>
10+
<version>1.1.5</version>
1111
</parent>
1212

1313
<name>fj-daogen-base</name>

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/config/DaogenFacade.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ public class DaogenFacade {
2323
private DaogenFacade() {}
2424

2525
private static void generageFile( JavaGenerator gen ) throws IOException {
26-
log.info( "Generating : {}", gen );
26+
log.debug( "Generating : {} START", gen );
2727
gen.generate();
2828
gen.write();
29+
log.debug( "Generating : {} END", gen );
2930
}
3031

3132
private static void handleCurrentGenerator( DaogenBasicGenerator generator, DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity, FactoryType dataType ) throws ConfigException, IOException {
@@ -48,6 +49,7 @@ private static void handleGenerators( DaogenCatalogConfig daogenConfig, DaogenGe
4849
if ( generatorCatalog.getEntityGenerators( daogenConfig ) != null ) {
4950
// iterating over generators
5051
for ( FactoryType dataType : generatorCatalog.getEntityGenerators( daogenConfig ) ) {
52+
log.info( "generator : {} -> {}", dataType.getInfo(), dataType.getType() );
5153
if ( daogenConfig.getGeneralProps().containsKey( dataType.getInfo() ) ) {
5254
handleCurrentGenerator((DaogenBasicGenerator)(ClassHelper.newInstance( dataType.getType())), daogenConfig, entity, dataType);
5355
}

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ public void setSkipWrite(boolean skipWrite) {
161161
}
162162

163163
public static String fullObjectName( String packageName, String simpleClassName ) {
164+
if ( packageName == null ) {
165+
throw new ConfigRuntimeException( "fullObjectName() packageName is null" );
166+
}
167+
if ( simpleClassName == null ) {
168+
throw new ConfigRuntimeException( "fullObjectName() simpleClassName is null" );
169+
}
164170
return packageName+"."+simpleClassName;
165171
}
166172

@@ -173,6 +179,9 @@ public void init( String sourceFolder, String fullObjectBName, String javaStyle,
173179
} else if ( DaogenCatalogConstants.GEN_PROP_SRC_HELPERS_GEN.equalsIgnoreCase( sourceFolder ) ) {
174180
sourceFolder = "target/generated-sources/daogen/";
175181
}
182+
if ( sourceFolder == null || sourceFolder.equalsIgnoreCase( "null" ) ) {
183+
throw new ConfigException( "null source folder for : "+fullObjectBName );
184+
}
176185
super.init( new File( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_BASE_SRC_FOLDER ), sourceFolder ), fullObjectBName, javaStyle, daogenConfig.getGeneralProps(), daogenConfig.getLineSeparator() );
177186
this.daogenConfig = daogenConfig;
178187
this.currentEntity = entity;

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/helper/BaseRestLoadHelperGenerator.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import org.fugerit.java.daogen.base.gen.GeneratorKeyHelper;
2222
import org.fugerit.java.daogen.base.gen.util.FacadeGeneratorUtils;
2323

24+
import lombok.extern.slf4j.Slf4j;
25+
26+
@Slf4j
2427
public abstract class BaseRestLoadHelperGenerator extends DaogenBasicGenerator {
2528

2629
protected static final String NEW_CONTEXT_LIT = "try (CloseableDAOContext context = this.newDefaultContext() ) {";
@@ -43,16 +46,17 @@ public abstract class BaseRestLoadHelperGenerator extends DaogenBasicGenerator {
4346

4447
protected static final String FACADE_FACTORY_GET_LIT = " facade = factory.get";
4548

46-
49+
private String propertyPackage;
4750

4851
private String key;
4952

5053
private BaseRestLoadHelperGeneratorConfig config;
5154

52-
protected BaseRestLoadHelperGenerator(String key, BaseRestLoadHelperGeneratorConfig config) {
55+
protected BaseRestLoadHelperGenerator(String key, BaseRestLoadHelperGeneratorConfig config, String propertyPackage ) {
5356
super();
5457
this.key = key;
5558
this.config = config;
59+
this.propertyPackage = propertyPackage;
5660
}
5761

5862
@Override
@@ -68,8 +72,10 @@ public boolean isGenerate( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity
6872
protected String helperClass = null;
6973

7074
public void init( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity ) throws ConfigException {
75+
String fullObjectBName = fullObjectName( daogenConfig.getGeneralProp( this.propertyPackage ), DaogenCatalogConstants.restLoadName( entity ) );
76+
log.info( "propertyPackage:{}, fullObjectBName:{}", this.propertyPackage, fullObjectBName );
7177
super.init( DaogenHelperGenerator.toHelperSourceFolder( daogenConfig ),
72-
DaogenHelperGenerator.toHelperClassName( fullObjectName( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_REST_LOAD ), DaogenCatalogConstants.restLoadName( entity ) ) ),
78+
DaogenHelperGenerator.toHelperClassName( fullObjectBName ),
7379
STYLE_CLASS, daogenConfig, entity );
7480
this.getImportList().addAll( this.config.getImportList() );
7581
this.setClassDaogenContext( DaogenClassConfigHelper.addImport( daogenConfig , DaogenClassConfigHelper.DAO_CONTEXT_BASE, this.getImportList() ) );

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/helper/BaseRestLoadRealGenerator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public BaseRestLoadRealGenerator(String key, List<String> importList, String pro
2222
super();
2323
this.key = key;
2424
this.importList = importList;
25-
this.propertyParage = propertyParage;
25+
this.propertyPackage = propertyParage;
26+
log.debug( "patternBaseAnnotation:{}, patternBaseAnnotation:{}", patternBaseAnnotation, patternBaseAnnotation );
2627
this.patternBaseAnnotation = patternBaseAnnotation;
2728
this.patternPathAnnotation = patternPathAnnotation;
2829
}
@@ -31,7 +32,7 @@ public BaseRestLoadRealGenerator(String key, List<String> importList, String pro
3132

3233
private List<String> importList;
3334

34-
private String propertyParage;
35+
private String propertyPackage;
3536

3637
private String patternBaseAnnotation;
3738

@@ -49,8 +50,10 @@ public boolean isGenerate( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity
4950
}
5051

5152
public void init( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity ) throws ConfigException {
53+
String fullObjectBName = fullObjectName( daogenConfig.getGeneralProp( this.propertyPackage ), DaogenCatalogConstants.restLoadName( entity ) );
54+
log.debug( "propertyPackage:{}, fullObjectBName:{}", this.propertyPackage, fullObjectBName );
5255
super.init( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_SRC_MAIN_JAVA ),
53-
fullObjectName( daogenConfig.getGeneralProp( this.propertyParage ), DaogenCatalogConstants.restLoadName( entity ) ),
56+
fullObjectBName,
5457
STYLE_CLASS, daogenConfig, entity );
5558
for ( String currentImport : this.importList ) {
5659
this.getImportList().add( currentImport );
@@ -68,8 +71,9 @@ protected void beforeClass() {
6871
super.beforeClass();
6972
String urlBase = this.getCurrentEntity().getName().replace( "_" , "" ).toLowerCase();
7073
this.getWriter().println( patternBaseAnnotation );
74+
log.debug( "patternPathAnnotation : {}, urlBase : {}", patternPathAnnotation, urlBase );
7175
String pathAnnotation = MessageFormat.format( this.patternPathAnnotation , urlBase);
72-
log.info( "pathAnnotation : {}", pathAnnotation );
76+
log.debug( "pathAnnotation : {}", pathAnnotation );
7377
this.getWriter().println( pathAnnotation );
7478
}
7579

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/helper/RestLoadHelperGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.fugerit.java.daogen.base.config.DaogenCatalogConstants;
67
import org.fugerit.java.daogen.base.config.DaogenCatalogField;
78
import org.fugerit.java.daogen.base.gen.FacadeDefGenerator;
89
import org.fugerit.java.daogen.base.gen.GeneratorKeyHelper;
@@ -25,7 +26,7 @@ public class RestLoadHelperGenerator extends BaseRestLoadHelperGenerator {
2526
}
2627

2728
public RestLoadHelperGenerator() {
28-
super(KEY, CONFIG);
29+
super(KEY, CONFIG, DaogenCatalogConstants.GEN_PROP_PACKAGE_REST_LOAD);
2930
}
3031

3132
protected void printPrimaryKeyLoader( GeneratorKeyHelper primaryKeyHelper, String deepUrl, String deepMethod, String deepWorker ) {

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/helper/SpringBootLoadHelperGenerator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.fugerit.java.daogen.base.config.DaogenCatalogConstants;
67
import org.fugerit.java.daogen.base.config.DaogenCatalogField;
78
import org.fugerit.java.daogen.base.gen.FacadeDefGenerator;
89
import org.fugerit.java.daogen.base.gen.GeneratorKeyHelper;
@@ -22,19 +23,17 @@ public class SpringBootLoadHelperGenerator extends BaseRestLoadHelperGenerator {
2223
importList.add( "javax.servlet.http.HttpServletResponse" );
2324
importList.add( "org.springframework.http.ResponseEntity" );
2425
importList.add( "org.springframework.web.bind.annotation.PathVariable" );
25-
importList.add( "org.springframework.web.bind.annotation.RequestMapping" );
26-
importList.add( "org.springframework.web.bind.annotation.RequestMethod" );
27-
importList.add( "org.springframework.web.bind.annotation.RequestMethod" );
26+
importList.add( "org.springframework.web.bind.annotation.GetMapping" );
2827
importList.add( "org.springframework.http.MediaType" );
2928
CONFIG.setImportList( importList );
3029
}
3130

3231
public SpringBootLoadHelperGenerator() {
33-
super(KEY, CONFIG);
32+
super(KEY, CONFIG, DaogenCatalogConstants.GEN_PROP_PACKAGE_SPRING_REST_LOAD);
3433
}
3534

3635
protected void printPrimaryKeyLoader( GeneratorKeyHelper primaryKeyHelper, String deepUrl, String deepMethod, String deepWorker ) {
37-
this.getWriter().println( TAB+"@RequestMapping(value = \""+deepUrl+primaryKeyHelper.getUrlParams()+"\", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )" );
36+
this.getWriter().println( TAB+"@GetMapping(value = \""+deepUrl+primaryKeyHelper.getUrlParams()+"\", produces = MediaType.APPLICATION_JSON_VALUE )" );
3837
this.getWriter().println( TAB+"public ResponseEntity<Object> getByID"+deepMethod+"("+primaryKeyHelper.getPathVarables()+") throws Exception {" );
3938
this.getWriter().println( TAB_2+RESPONSE_ENTITY_LIT );
4039
this.getWriter().println( TAB_2+NEW_CONTEXT_LIT );
@@ -45,10 +44,11 @@ protected void printPrimaryKeyLoader( GeneratorKeyHelper primaryKeyHelper, Strin
4544
this.getWriter().println( TAB_3+RES_BUILD_LIT );
4645
this.getWriter().println( TAB_2+"}" );
4746
this.getWriter().println( TAB_2+RETURN_RES_LIT );
47+
this.getWriter().println( TAB+"}" );
4848
}
4949

5050
protected void printLoadAll( String factoryClassName ) {
51-
this.getWriter().println( TAB+"@RequestMapping(value = \"/all\", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )" );
51+
this.getWriter().println( TAB+"@GetMapping(value = \"/all\", produces = MediaType.APPLICATION_JSON_VALUE )" );
5252
this.getWriter().println( TAB+"public ResponseEntity<Object> getAll() throws Exception {" );
5353
this.getWriter().println( TAB_2+RESPONSE_ENTITY_LIT );
5454
this.getWriter().println( TAB_2+NEW_CONTEXT_LIT );
@@ -66,7 +66,7 @@ protected void printLoadAll( String factoryClassName ) {
6666
}
6767

6868
protected void printLoadCurrent( String urlName, String propertyName, String javaName, DaogenCatalogField field ) {
69-
this.getWriter().println( TAB+"@RequestMapping(value = \"/"+urlName+"/{"+urlName+"}\", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )" );
69+
this.getWriter().println( TAB+"@GetMapping(value = \"/"+urlName+"/{"+urlName+"}\", produces = MediaType.APPLICATION_JSON_VALUE )" );
7070
this.getWriter().println( TAB+"public ResponseEntity<Object> getAll"+javaName+"(@PathVariable( \""+urlName+"\" ) String "+propertyName+") throws Exception {" );
7171
this.getWriter().println( TAB_2+RESPONSE_ENTITY_LIT );
7272
this.getWriter().println( TAB_2+NEW_CONTEXT_LIT );

fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/helper/SpringBootLoadRealGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SpringBootLoadRealGenerator extends BaseRestLoadRealGenerator {
1111
private static final String[] IMPORTS = { "org.springframework.web.bind.annotation.RequestMapping", "org.springframework.web.bind.annotation.RestController" };
1212

1313
public SpringBootLoadRealGenerator() {
14-
super( KEY, Arrays.asList( IMPORTS ), DaogenCatalogConstants.GEN_PROP_PACKAGE_REST_LOAD, "@RestController", "@RequestMapping(\"/{}/load\")" );
14+
super( KEY, Arrays.asList( IMPORTS ), DaogenCatalogConstants.GEN_PROP_PACKAGE_SPRING_REST_LOAD, "@RestController", "@RequestMapping(\"/{0}/load\")" );
1515
}
1616

1717
}

0 commit comments

Comments
 (0)