From 503a5e52ebb832376d6be15255a08b967594ff7c Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Wed, 13 Sep 2023 02:06:20 +0200 Subject: [PATCH 1/5] Simple compare tool #13 --- CHANGELOG.md | 6 + .../base/tool/handler/CompareHandler.java | 146 ++++++++++++ .../daogen/base/tool/TestCompareHandler.java | 70 ++++++ .../def/facade/EntityAddressFacadeHelper.java | 98 ++++++++ .../def/facade/EntityLogDataFacadeHelper.java | 50 ++++ .../EntityTestTwoFieldKeyFacadeHelper.java | 100 ++++++++ .../def/facade/EntityUploadFacadeHelper.java | 98 ++++++++ .../facade/EntityUserDataFacadeHelper.java | 98 ++++++++ .../def/facade/EntityUserFacadeHelper.java | 98 ++++++++ .../def/facade/FugeritLogicFacadeHelper.java | 72 ++++++ .../data/DataEntityAddressFacadeHelper.java | 145 ++++++++++++ .../data/DataEntityLogDataFacadeHelper.java | 73 ++++++ ...DataEntityTestTwoFieldKeyFacadeHelper.java | 134 +++++++++++ .../data/DataEntityUploadFacadeHelper.java | 141 ++++++++++++ .../data/DataEntityUserDataFacadeHelper.java | 153 +++++++++++++ .../data/DataEntityUserFacadeHelper.java | 153 +++++++++++++ .../data/FugeritDataLogicFacadeHelper.java | 106 +++++++++ .../impl/rest/load/LoadAddressHelper.java | 183 +++++++++++++++ .../impl/rest/load/LoadLogDataHelper.java | 136 +++++++++++ .../rest/load/LoadTestTwoFieldKeyHelper.java | 211 +++++++++++++++++ .../impl/rest/load/LoadUploadHelper.java | 118 ++++++++++ .../impl/rest/load/LoadUserDataHelper.java | 211 +++++++++++++++++ .../sample/impl/rest/load/LoadUserHelper.java | 214 ++++++++++++++++++ fj-daogen-tool/src/test/resources/log4j2.xml | 13 ++ pom.xml | 8 +- 25 files changed, 2831 insertions(+), 4 deletions(-) create mode 100644 fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java create mode 100644 fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java create mode 100644 fj-daogen-tool/src/test/resources/log4j2.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c2196b..ff8f52f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [workflow codeql on branch main](.github/workflows/codeql-analysis.yml) - badge link to the daogen-config xsd 1.0 +### Changed + +- fj-bom set to 1.3.6 +- fj-core set to 8.2.7 +- fj-doc set to 2.0.2 + ### Fixed - typos to the daogen-config-1-0.xsd diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java new file mode 100644 index 00000000..fc1d4fe9 --- /dev/null +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java @@ -0,0 +1,146 @@ +package org.fugerit.java.daogen.base.tool.handler; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; + +import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.FileIO; +import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.core.lang.helpers.StringUtils; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class CompareHandler { + + public static final String ARG_REPORT = "report"; + + public static final String ARG_TRY_DELETE_EQUAL = "try-delere-equal"; + + public static final String ARG_TRY_CORRECT_HELPER = "try-correct-helper"; + + public void handleCompare( File baseDir, File file1, File file2, Properties params ) { + SafeFunction.apply( () -> { + try ( StringWriter writer = new StringWriter(); + PrintWriter report = new PrintWriter( writer, true ) ) { + String removePath = baseDir == null ? "" : baseDir.getCanonicalPath(); + handleCompareWork(removePath, file1, file2, params, report); + String reportFile = params.getProperty( ARG_REPORT ); + if ( StringUtils.isNotEmpty( reportFile ) ) { + log.info( "write report file : {}", reportFile ); + FileIO.writeString( writer.toString() , new File(reportFile) ); + } else { + log.info( "print report : \n{}", writer.toString() ); + } + } + } ); + + } + + private String removePath( String path, String removePath ) { + String res = path; + if ( StringUtils.isNotEmpty( removePath ) ) { + if ( path.indexOf( removePath ) == 0 ) { + res = path.substring( removePath.length() ); + } + } + return res; + } + + private void tryCorrectHelperEqual( File file1, File file2, Properties params, PrintWriter report ) { + boolean tryCorrectHelper = BooleanUtils.isTrue( params.getProperty( ARG_TRY_CORRECT_HELPER ) ); + if ( tryCorrectHelper ) { + if ( file2.getName().endsWith( "Helper.java" ) ) { + String realFileName = file2.getName().replace( "Helper.java" , ".java" ); + File realFile = new File( file2.getParentFile(), realFileName ); + if ( realFile.exists() ) { + report.print( "real file exists, try to correct from helper : "+realFileName ); + } else { + report.print( "default real file not found : "+realFileName ); + } + } + } + } + + private void tryDeleteEqual( File file1, File file2, Properties params, PrintWriter report ) { + boolean tryDeleteEqual = BooleanUtils.isTrue( params.getProperty( ARG_TRY_DELETE_EQUAL ) ); + if ( tryDeleteEqual ) { + report.print( " - try delete equal result : "+file2.delete() ); + } + } + + private void compareFile( File file1, File file2, Properties params, PrintWriter report ) throws IOException { + List lines1 = new ArrayList<>(); + List lines2 = new ArrayList<>(); + try ( BufferedReader reader1 = new BufferedReader( new FileReader( file1 ) ); + BufferedReader reader2 = new BufferedReader( new FileReader( file2 ) ) ) { + lines1.addAll( reader1.lines().collect( Collectors.toList() ) ); + lines2.addAll( reader2.lines().collect( Collectors.toList() ) ); + } + // check + report.print( "file 1 size : "+lines1.size()+", " ); + if ( lines1.size() == lines2.size() ) { + report.print( "file 2 same size! " ); + boolean differentUid = false; + int diffSize = 0; + for ( int k=0; k 0 ) { + report.print( " - diffeent lines : "+diffSize ); + } else { + this.tryDeleteEqual(file1, file2, params, report); + } + if ( differentUid ) { + report.print( " - diffeent serialVersionUID" ); + } + } else { + report.print( "file 2 size : "+lines1.size()+" DIFFERENT! " ); + this.tryCorrectHelperEqual(file1, file2, params, report); + } + report.println(); + } + + private void handleCompareWork( String removePath, File file1, File file2, Properties params, PrintWriter report ) throws ConfigException, IOException { + String fileEntry1 = removePath( file1.getCanonicalPath(), removePath ); + String fileEntry2 = removePath( file2.getCanonicalPath(), removePath ); + log.info( "handleCompare {} - {}", fileEntry1, fileEntry2 ); + if ( file1.isDirectory() && file1.isDirectory() ) { + report.println( "# directory : "+fileEntry1 ); + for ( File file : file1.listFiles() ) { + if ( file.isDirectory() ) { + report.println(); + } + this.handleCompareWork( removePath, file, new File( file2, file.getName() ), params, report ); + } + } else if ( file1.isDirectory() || file1.isDirectory() ) { + throw new ConfigException( "Only one is directory : "+file1+"("+file1.isDirectory()+"), : "+file2+"("+file2.isDirectory()+")" ); + } else { + report.print( "- "+fileEntry1+" -> "+fileEntry2+" : " ); + if ( !file2.exists() ) { + report.println( "does not exist!" ); + } else { + report.println( "exists : " ); + this.compareFile(file1, file2, params, report); + } + } + } + +} diff --git a/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java new file mode 100644 index 00000000..dfc2203c --- /dev/null +++ b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java @@ -0,0 +1,70 @@ +package test.org.fugerit.java.daogen.base.tool; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.StreamIO; +import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.daogen.base.tool.handler.CompareHandler; +import org.junit.Assert; +import org.junit.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class TestCompareHandler { + + private static final String SOURCE_TEST = "src/test/resources/compare_handler_test/daogen"; + + private static void copyHelper( File baseSource, File baseDest, File currentSource ) throws IOException { + String relPath = currentSource.getCanonicalPath().substring( baseSource.getCanonicalPath().length() ); + File newFile = new File( baseDest, relPath ); + if ( currentSource.isDirectory() ) { + newFile.mkdirs(); + for ( File current : currentSource.listFiles() ) { + copyHelper(baseSource, baseDest, current); + } + } else { + try ( FileInputStream fis = new FileInputStream( currentSource ); + FileOutputStream fos = new FileOutputStream( newFile ) ) { + StreamIO.pipeStream(fis, fos, StreamIO.MODE_CLOSE_NONE); + } + } + } + + private static void copyHelper( File sourceFile, File testDir ) throws IOException { + if ( !testDir.exists() ) { + copyHelper(sourceFile, testDir, sourceFile ); + } else { + log.info( "testDir already exists! {}", testDir ); + } + } + + private static void prepare( File file1, File file2 ) { + SafeFunction.apply( () -> { + File sourceDir = new File( SOURCE_TEST ); + copyHelper( sourceDir, file1 ); + copyHelper( sourceDir, file2 ); + }); + } + + @Test + public void test() { + File baseDir = new File( "target" ); + File file1 = new File( baseDir, "daogen1" ); + File file2 = new File( baseDir, "daogen2" ); + prepare(file1, file2); + Assert.assertTrue( file1.exists() ); + Assert.assertTrue( file2.exists() ); + CompareHandler handler = new CompareHandler(); + Properties params = new Properties(); + params.setProperty( CompareHandler.ARG_TRY_CORRECT_HELPER , BooleanUtils.BOOLEAN_TRUE ); + params.setProperty( CompareHandler.ARG_TRY_DELETE_EQUAL , BooleanUtils.BOOLEAN_TRUE ); + handler.handleCompare( baseDir, file1, file2, params ); + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java new file mode 100644 index 00000000..e93e5ae5 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * EntityAddressFacadeHelper, 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 interface EntityAddressFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelAddress + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelAddress + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, AddressFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param id Address system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelAddress loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelAddress + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelAddress model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param id Address system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelAddress model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java new file mode 100644 index 00000000..9f91e28d --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java @@ -0,0 +1,50 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityLogDataFacadeHelper, 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 interface EntityLogDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelLogData + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelLogData + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, LogDataFinder finder ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java new file mode 100644 index 00000000..245b8bd3 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java @@ -0,0 +1,100 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityTestTwoFieldKeyFacadeHelper, 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 interface EntityTestTwoFieldKeyFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelTestTwoFieldKey + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelTestTwoFieldKey + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, TestTwoFieldKeyFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param idOne part of the key + * @param idTwo part of the key + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelTestTwoFieldKey loadById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException; + + /** + * Method to create an new entity of type : ModelTestTwoFieldKey + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param idOne part of the key + * @param idTwo part of the key + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java new file mode 100644 index 00000000..cda9afe5 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUploadFacadeHelper, 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 interface EntityUploadFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUpload + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUpload + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UploadFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param id part of the key + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUpload loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUpload + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUpload model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param id part of the key + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUpload model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java new file mode 100644 index 00000000..f5ac9e9a --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUserDataFacadeHelper, 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 interface EntityUserDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUserData + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUserData + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UserDataFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param id User system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUserData loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUserData + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUserData model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param id User system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUserData model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java new file mode 100644 index 00000000..e677c99c --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUserFacadeHelper, 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 interface EntityUserFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUser + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUser + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UserFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param id User system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUser loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUser + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUser model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param id User system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUser model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java new file mode 100644 index 00000000..c5da564d --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java @@ -0,0 +1,72 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * FugeritLogicFacadeHelper, 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 interface FugeritLogicFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + public static final String ATT_NAME = "FugeritLogicFacadeHelper"; + + /** + * Facade incapsulating persistance for entity : ADDRESS + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade getEntityAddressFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : LOG_DATA + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade getEntityLogDataFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : TEST_TWO_FIELD_KEY + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade getEntityTestTwoFieldKeyFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : UPLOAD + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade getEntityUploadFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : USER + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUserFacade getEntityUserFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : USER_DATA + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade getEntityUserDataFacade() throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java new file mode 100644 index 00000000..5014a483 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java @@ -0,0 +1,145 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.AddressFinder; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacadeHelper; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; +import org.fugerit.java.daogen.sample.impl.rse.AddressRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityAddressFacadeHelper, 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 DataEntityAddressFacadeHelper extends BasicDataFacade implements EntityAddressFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 217767376688L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.ADDRESS"; + + public DataEntityAddressFacadeHelper() { + super( TABLE_NAME, AddressRSE.DEFAULT, null ); + } + + public DataEntityAddressFacadeHelper( String tableName, String queryView ) { + super( tableName, AddressRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_ID_USER = "ID_USER"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, AddressFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelAddress model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_ID_USER, model.getIdUser() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelAddress model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_ID_USER, model.getIdUser() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_INFO, model.getInfo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelAddress loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelAddress result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelAddress model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_ID_USER, model.getIdUser() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_INFO, model.getInfo() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java new file mode 100644 index 00000000..f9da555f --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java @@ -0,0 +1,73 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.LogDataFinder; +import org.fugerit.java.daogen.sample.def.model.ModelLogData; +import org.fugerit.java.daogen.sample.impl.rse.LogDataRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityLogDataFacadeHelper, 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 DataEntityLogDataFacadeHelper extends BasicDataFacade implements EntityLogDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 913839672567L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.LOG_DATA"; + + public DataEntityLogDataFacadeHelper() { + super( TABLE_NAME, LogDataRSE.DEFAULT, null ); + } + + public DataEntityLogDataFacadeHelper( String tableName, String queryView ) { + super( tableName, LogDataRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_LOG_TIME = "LOG_TIME"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, LogDataFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelLogData model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_LOG_TIME, model.getLogTime() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java new file mode 100644 index 00000000..bf0a4af3 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java @@ -0,0 +1,134 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.TestTwoFieldKeyFinder; +import org.fugerit.java.daogen.sample.def.model.ModelTestTwoFieldKey; +import org.fugerit.java.daogen.sample.impl.rse.TestTwoFieldKeyRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityTestTwoFieldKeyFacadeHelper, 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 DataEntityTestTwoFieldKeyFacadeHelper extends BasicDataFacade implements EntityTestTwoFieldKeyFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 838819137461L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.TEST_TWO_FIELD_KEY"; + + public DataEntityTestTwoFieldKeyFacadeHelper() { + super( TABLE_NAME, TestTwoFieldKeyRSE.DEFAULT, null ); + } + + public DataEntityTestTwoFieldKeyFacadeHelper( String tableName, String queryView ) { + super( tableName, TestTwoFieldKeyRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID_ONE = "ID_ONE"; + public static final String COL_ID_TWO = "ID_TWO"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, TestTwoFieldKeyFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( finder.getModel() != null ) { + ModelTestTwoFieldKey model = finder.getModel(); + query.andEqualParam( COL_ID_ONE, model.getIdOne() ); + query.andEqualParam( COL_ID_TWO, model.getIdTwo() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getIdOne() == null ) { + model.setIdOne( this.generateId( context ) ); + } + if ( model.getIdTwo() == null ) { + model.setIdTwo( this.generateId( context ) ); + } + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID_ONE, model.getIdOne() ); + query.addParam( COL_ID_TWO, model.getIdTwo() ); + query.addParam( COL_INFO, model.getInfo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelTestTwoFieldKey loadById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + ModelTestTwoFieldKey result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( idOne == null || idTwo == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal idOne, java.math.BigDecimal idTwo" ); + } else { + query.andEqualParam( COL_ID_ONE, idOne ); + query.andEqualParam( COL_ID_TWO, idTwo ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID_ONE, idOne ); + query.andWhereParam( COL_ID_TWO, idTwo ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_INFO, model.getInfo() ); + query.andWhereParam( COL_ID_ONE, model.getIdOne() ); + query.andWhereParam( COL_ID_TWO, model.getIdTwo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java new file mode 100644 index 00000000..8e4bd7f8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java @@ -0,0 +1,141 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UploadFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUpload; +import org.fugerit.java.daogen.sample.impl.rse.UploadRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUploadFacadeHelper, 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 DataEntityUploadFacadeHelper extends BasicDataFacade implements EntityUploadFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 962863269897L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.UPLOAD"; + + public DataEntityUploadFacadeHelper() { + super( TABLE_NAME, UploadRSE.DEFAULT, null ); + } + + public DataEntityUploadFacadeHelper( String tableName, String queryView ) { + super( tableName, UploadRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_CONTENT = "CONTENT"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UploadFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUpload model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_CONTENT, model.getContent() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUpload model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_CONTENT, model.getContent() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUpload loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUpload result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUpload model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_CONTENT, model.getContent() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java new file mode 100644 index 00000000..ed6f79b8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java @@ -0,0 +1,153 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UserDataFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUserData; +import org.fugerit.java.daogen.sample.impl.rse.UserDataRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserDataFacadeHelper, 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 DataEntityUserDataFacadeHelper extends BasicDataFacade implements EntityUserDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 566958319786L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.USER"; + + public DataEntityUserDataFacadeHelper() { + super( TABLE_NAME, UserDataRSE.DEFAULT, null ); + } + + public DataEntityUserDataFacadeHelper( String tableName, String queryView ) { + super( tableName, UserDataRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_USERNAME = "USERNAME"; + public static final String COL_PASSWORD = "PASSWORD"; + public static final String COL_LAST_LOGIN = "LAST_LOGIN"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_STATE = "STATE"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UserDataFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUserData model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_USERNAME, model.getUsername() ); + query.andEqualParam( COL_PASSWORD, model.getPassword() ); + query.andEqualParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_STATE, model.getState() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUserData model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_USERNAME, model.getUsername() ); + query.addParam( COL_PASSWORD, model.getPassword() ); + query.addParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_STATE, model.getState() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUserData loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUserData result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUserData model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_USERNAME, model.getUsername() ); + query.addSetParam( COL_PASSWORD, model.getPassword() ); + query.addSetParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_STATE, model.getState() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java new file mode 100644 index 00000000..7a2e33e9 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java @@ -0,0 +1,153 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UserFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUser; +import org.fugerit.java.daogen.sample.impl.rse.UserRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserFacadeHelper, 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 DataEntityUserFacadeHelper extends BasicDataFacade implements EntityUserFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 522012954894L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.USER"; + + public DataEntityUserFacadeHelper() { + super( TABLE_NAME, UserRSE.DEFAULT, null ); + } + + public DataEntityUserFacadeHelper( String tableName, String queryView ) { + super( tableName, UserRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_USERNAME = "USERNAME"; + public static final String COL_PASSWORD = "PASSWORD"; + public static final String COL_LAST_LOGIN = "LAST_LOGIN"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_STATE = "STATE"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UserFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUser model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_USERNAME, model.getUsername() ); + query.andEqualParam( COL_PASSWORD, model.getPassword() ); + query.andEqualParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_STATE, model.getState() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUser model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_USERNAME, model.getUsername() ); + query.addParam( COL_PASSWORD, model.getPassword() ); + query.addParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_STATE, model.getState() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUser loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUser result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUser model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_USERNAME, model.getUsername() ); + query.addSetParam( COL_PASSWORD, model.getPassword() ); + query.addSetParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_STATE, model.getState() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java new file mode 100644 index 00000000..5ce3715f --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java @@ -0,0 +1,106 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * FugeritDataLogicFacadeHelper, 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 FugeritDataLogicFacadeHelper implements org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacadeHelper, java.io.Serializable { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 306189539652L; + + + public FugeritDataLogicFacadeHelper() { + this.entityaddressfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityAddressFacade(); + this.entitylogdatafacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityLogDataFacade(); + this.entitytesttwofieldkeyfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityTestTwoFieldKeyFacade(); + this.entityuploadfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUploadFacade(); + this.entityuserfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUserFacade(); + this.entityuserdatafacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUserDataFacade(); + } + + private EntityAddressFacade entityaddressfacade; + + @Override + public EntityAddressFacade getEntityAddressFacade() throws DAOException { + return this.entityaddressfacade; + } + + protected void setEntityAddressFacade( EntityAddressFacade facade ) throws DAOException { + this.entityaddressfacade = facade; + } + + private EntityLogDataFacade entitylogdatafacade; + + @Override + public EntityLogDataFacade getEntityLogDataFacade() throws DAOException { + return this.entitylogdatafacade; + } + + protected void setEntityLogDataFacade( EntityLogDataFacade facade ) throws DAOException { + this.entitylogdatafacade = facade; + } + + private EntityTestTwoFieldKeyFacade entitytesttwofieldkeyfacade; + + @Override + public EntityTestTwoFieldKeyFacade getEntityTestTwoFieldKeyFacade() throws DAOException { + return this.entitytesttwofieldkeyfacade; + } + + protected void setEntityTestTwoFieldKeyFacade( EntityTestTwoFieldKeyFacade facade ) throws DAOException { + this.entitytesttwofieldkeyfacade = facade; + } + + private EntityUploadFacade entityuploadfacade; + + @Override + public EntityUploadFacade getEntityUploadFacade() throws DAOException { + return this.entityuploadfacade; + } + + protected void setEntityUploadFacade( EntityUploadFacade facade ) throws DAOException { + this.entityuploadfacade = facade; + } + + private EntityUserFacade entityuserfacade; + + @Override + public EntityUserFacade getEntityUserFacade() throws DAOException { + return this.entityuserfacade; + } + + protected void setEntityUserFacade( EntityUserFacade facade ) throws DAOException { + this.entityuserfacade = facade; + } + + private EntityUserDataFacade entityuserdatafacade; + + @Override + public EntityUserDataFacade getEntityUserDataFacade() throws DAOException { + return this.entityuserdatafacade; + } + + protected void setEntityUserDataFacade( EntityUserDataFacade facade ) throws DAOException { + this.entityuserdatafacade = facade; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java new file mode 100644 index 00000000..7fa453c7 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java @@ -0,0 +1,183 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.AddressFinder; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * LoadAddressHelper, 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 LoadAddressHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 830554611736L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + ModelAddress model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + ModelAddress model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + if ( result.getContent() != null ) { + result.getContent().setUser(LoadUser.loadByIdWorker( context, result.getContent().getIdUser() ).getContent()); + } + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelAddress. + * Property ModelAddress is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelAddress to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelAddress model ) throws DAOException { + AddressFinder finder = AddressFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelAddress. + * Property idUser is being used as filter + * + * @param context DAO context + * @param current Tee value of property idUser to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdUser( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperAddress model = new org.fugerit.java.daogen.sample.impl.helper.HelperAddress(); + model.setIdUser( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_user/{id_user}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdUser(@PathParam( "id_user" ) String idUser) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idUser); + SimpleServiceResult> result = loadByIdUser( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAllIdUser - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelAddress. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperAddress model = new org.fugerit.java.daogen.sample.impl.helper.HelperAddress(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java new file mode 100644 index 00000000..48816ee8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java @@ -0,0 +1,136 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.LogDataFinder; +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 ) + +/** + * LoadLogDataHelper, 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 LoadLogDataHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 896855494315L; + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityLogDataFacade facade = factory.getEntityLogDataFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelLogData. + * Property ModelLogData is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelLogData to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelLogData model ) throws DAOException { + LogDataFinder finder = LogDataFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityLogDataFacade facade = factory.getEntityLogDataFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelLogData. + * Property id is being used as filter + * + * @param context DAO context + * @param current Tee value of property id to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadById( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperLogData model = new org.fugerit.java.daogen.sample.impl.helper.HelperLogData(); + model.setId( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllId(@PathParam( "id" ) String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(id); + SimpleServiceResult> result = loadById( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAllId - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelLogData. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperLogData model = new org.fugerit.java.daogen.sample.impl.helper.HelperLogData(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java new file mode 100644 index 00000000..a41036a7 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java @@ -0,0 +1,211 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.TestTwoFieldKeyFinder; +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 ) + +/** + * LoadTestTwoFieldKeyHelper, 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 LoadTestTwoFieldKeyHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 348976908673L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + ModelTestTwoFieldKey model = facade.loadById( context , idOne, idTwo ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/idOne/{idOne}/idTwo/{idTwo}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "idOne") String idOne, @PathParam( "idTwo") String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(idOne), new java.math.BigDecimal(idTwo) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + ModelTestTwoFieldKey model = facade.loadById( context , idOne, idTwo ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/idOne/{idOne}/idTwo/{idTwo}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "idOne") String idOne, @PathParam( "idTwo") String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(idOne), new java.math.BigDecimal(idTwo) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property ModelTestTwoFieldKey is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelTestTwoFieldKey to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + TestTwoFieldKeyFinder finder = TestTwoFieldKeyFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property idOne is being used as filter + * + * @param context DAO context + * @param current Tee value of property idOne to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdOne( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setIdOne( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_one/{id_one}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdOne(@PathParam( "id_one" ) String idOne) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idOne); + SimpleServiceResult> result = loadByIdOne( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllIdOne - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property idTwo is being used as filter + * + * @param context DAO context + * @param current Tee value of property idTwo to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdTwo( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setIdTwo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_two/{id_two}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdTwo(@PathParam( "id_two" ) String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idTwo); + SimpleServiceResult> result = loadByIdTwo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllIdTwo - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java new file mode 100644 index 00000000..6661488c --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java @@ -0,0 +1,118 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UploadFinder; +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 ) + +/** + * LoadUploadHelper, 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 LoadUploadHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 407430847282L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + ModelUpload model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + ModelUpload model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUpload. + * Property ModelUpload is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUpload to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUpload model ) throws DAOException { + UploadFinder finder = UploadFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java new file mode 100644 index 00000000..3d5c0f22 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java @@ -0,0 +1,211 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UserDataFinder; +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 ) + +/** + * LoadUserDataHelper, 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 LoadUserDataHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 363048926673L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + ModelUserData model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + ModelUserData model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property ModelUserData is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUserData to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUserData model ) throws DAOException { + UserDataFinder finder = UserDataFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelUserData. + * Property username is being used as filter + * + * @param context DAO context + * @param current Tee value of property username to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByUsername( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setUsername( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/username/{username}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllUsername(@PathParam( "username" ) String username) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = username; + SimpleServiceResult> result = loadByUsername( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllUsername - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property password is being used as filter + * + * @param context DAO context + * @param current Tee value of property password to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByPassword( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setPassword( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/password/{password}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllPassword(@PathParam( "password" ) String password) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = password; + SimpleServiceResult> result = loadByPassword( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllPassword - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property state is being used as filter + * + * @param context DAO context + * @param current Tee value of property state to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByState( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setState( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/state/{state}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllState(@PathParam( "state" ) String state) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(state); + SimpleServiceResult> result = loadByState( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllState - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java new file mode 100644 index 00000000..73189ecf --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java @@ -0,0 +1,214 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UserFinder; +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 ) + +/** + * LoadUserHelper, 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 LoadUserHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 315520622489L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + ModelUser model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + ModelUser model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + if ( result.getContent() != null ) { + result.getContent().setUserAddresses(LoadAddress.loadByIdUser( context, result.getContent().getId() ).getContent()); + } + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property ModelUser is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUser to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUser model ) throws DAOException { + UserFinder finder = UserFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelUser. + * Property username is being used as filter + * + * @param context DAO context + * @param current Tee value of property username to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByUsername( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setUsername( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/username/{username}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllUsername(@PathParam( "username" ) String username) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = username; + SimpleServiceResult> result = loadByUsername( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllUsername - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property password is being used as filter + * + * @param context DAO context + * @param current Tee value of property password to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByPassword( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setPassword( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/password/{password}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllPassword(@PathParam( "password" ) String password) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = password; + SimpleServiceResult> result = loadByPassword( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllPassword - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property state is being used as filter + * + * @param context DAO context + * @param current Tee value of property state to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByState( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setState( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/state/{state}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllState(@PathParam( "state" ) String state) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(state); + SimpleServiceResult> result = loadByState( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllState - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/log4j2.xml b/fj-daogen-tool/src/test/resources/log4j2.xml new file mode 100644 index 00000000..e6220f78 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 901a47b1..92b677f6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.fugerit.java fj-bom - 1.3.5 + 1.3.6 @@ -24,9 +24,9 @@ ${java-version-compliance} ${java-version-compliance} ${java-version-compliance} - 8.2.6 - 1.5.10 - 0.4.1 + 8.2.7 + 2.0.2 + 0.5.0 2.1.1 ${project.version} From 55f7fa0810d04d7f4c70c1f7764a3434df18c1ba Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Wed, 13 Sep 2023 02:29:04 +0200 Subject: [PATCH 2/5] Fix comparison bugs --- .../fugerit/java/daogen/base/tool/handler/CompareHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java index fc1d4fe9..aae9aa63 100644 --- a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java @@ -122,7 +122,7 @@ private void handleCompareWork( String removePath, File file1, File file2, Prope String fileEntry1 = removePath( file1.getCanonicalPath(), removePath ); String fileEntry2 = removePath( file2.getCanonicalPath(), removePath ); log.info( "handleCompare {} - {}", fileEntry1, fileEntry2 ); - if ( file1.isDirectory() && file1.isDirectory() ) { + if ( file1.isDirectory() && file2.isDirectory() ) { report.println( "# directory : "+fileEntry1 ); for ( File file : file1.listFiles() ) { if ( file.isDirectory() ) { @@ -130,7 +130,7 @@ private void handleCompareWork( String removePath, File file1, File file2, Prope } this.handleCompareWork( removePath, file, new File( file2, file.getName() ), params, report ); } - } else if ( file1.isDirectory() || file1.isDirectory() ) { + } else if ( file1.isDirectory() || file2.isDirectory() ) { throw new ConfigException( "Only one is directory : "+file1+"("+file1.isDirectory()+"), : "+file2+"("+file2.isDirectory()+")" ); } else { report.print( "- "+fileEntry1+" -> "+fileEntry2+" : " ); From 8b06feeb2121c32e938d6cb8a489f78355239b77 Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Wed, 13 Sep 2023 08:24:58 +0200 Subject: [PATCH 3/5] Better test coverage #13 --- .../base/gen/util/ExtractCustomCode.java | 62 +++++ .../daogen/util/TestExtractCustomCode.java | 39 ++++ .../base/tool/handler/CompareHandler.java | 108 ++++++--- .../daogen/base/tool/TestCompareHandler.java | 33 ++- .../def/facade/EntityAddressFacadeHelper.java | 0 .../def/facade/EntityLogDataFacadeHelper.java | 0 .../EntityTestTwoFieldKeyFacadeHelper.java | 0 .../def/facade/EntityUploadFacadeHelper.java | 0 .../facade/EntityUserDataFacadeHelper.java | 0 .../def/facade/EntityUserFacadeHelper.java | 0 .../def/facade/FugeritLogicFacadeHelper.java | 0 .../data/DataEntityAddressFacadeHelper.java | 0 .../data/DataEntityLogDataFacadeHelper.java | 0 ...DataEntityTestTwoFieldKeyFacadeHelper.java | 0 .../data/DataEntityUploadFacadeHelper.java | 0 .../data/DataEntityUserDataFacadeHelper.java | 0 .../data/DataEntityUserFacadeHelper.java | 0 .../data/FugeritDataLogicFacadeHelper.java | 0 .../impl/rest/load/LoadAddressHelper.java | 0 .../impl/rest/load/LoadLogDataHelper.java | 0 .../rest/load/LoadTestTwoFieldKeyHelper.java | 0 .../impl/rest/load/LoadUploadHelper.java | 0 .../impl/rest/load/LoadUserDataHelper.java | 0 .../sample/impl/rest/load/LoadUserHelper.java | 0 .../def/facade/EntityAddressFacadeHelper.java | 98 ++++++++ .../def/facade/EntityLogDataFacadeHelper.java | 50 ++++ .../EntityTestTwoFieldKeyFacadeHelper.java | 100 ++++++++ .../def/facade/EntityUploadFacadeHelper.java | 98 ++++++++ .../facade/EntityUserDataFacadeHelper.java | 98 ++++++++ .../def/facade/EntityUserFacadeHelper.java | 98 ++++++++ .../def/facade/FugeritLogicFacadeHelper.java | 72 ++++++ .../facade/data/DataEntityAddressFacade.java | 25 ++ .../data/DataEntityAddressFacadeHelper.java | 150 ++++++++++++ .../facade/data/DataEntityLogDataFacade.java | 25 ++ .../data/DataEntityLogDataFacadeHelper.java | 73 ++++++ .../data/DataEntityTestTwoFieldKeyFacade.java | 25 ++ ...DataEntityTestTwoFieldKeyFacadeHelper.java | 134 +++++++++++ .../facade/data/DataEntityUploadFacade.java | 25 ++ .../data/DataEntityUploadFacadeHelper.java | 141 ++++++++++++ .../facade/data/DataEntityUserDataFacade.java | 25 ++ .../data/DataEntityUserDataFacadeHelper.java | 153 +++++++++++++ .../facade/data/DataEntityUserFacade.java | 25 ++ .../data/DataEntityUserFacadeHelper.java | 153 +++++++++++++ .../facade/data/FugeritDataLogicFacade.java | 26 +++ .../data/FugeritDataLogicFacadeHelper.java | 106 +++++++++ .../impl/rest/load/LoadAddressHelper.java | 188 +++++++++++++++ .../impl/rest/load/LoadLogDataHelper.java | 136 +++++++++++ .../rest/load/LoadTestTwoFieldKeyHelper.java | 211 +++++++++++++++++ .../impl/rest/load/LoadUploadHelper.java | 118 ++++++++++ .../impl/rest/load/LoadUserDataHelper.java | 211 +++++++++++++++++ .../sample/impl/rest/load/LoadUserHelper.java | 214 ++++++++++++++++++ src/docs/config/daogen-config-xsd-ref.html | 176 ++++++++------ 52 files changed, 3085 insertions(+), 111 deletions(-) create mode 100644 fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java create mode 100644 fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java (100%) rename fj-daogen-tool/src/test/resources/compare_handler_test/{daogen => daogen_generated}/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java (100%) create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacade.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java create mode 100644 fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java new file mode 100644 index 00000000..15aa5ca8 --- /dev/null +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java @@ -0,0 +1,62 @@ +package org.fugerit.java.daogen.base.gen.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; + +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.function.SimpleValue; +import org.fugerit.java.core.io.FileIO; + +public class ExtractCustomCode { + + private ExtractCustomCode() {} + + public static String extractCustom( File file, String startTag, String endTag ) { + return SafeFunction.get( () -> extractCustom( FileIO.readString( file ) , startTag, endTag ) ); + } + + public static String extractCustom( CharSequence text, String startTag, String endTag ) { + return SafeFunction.get( () -> { + try ( BufferedReader reader = new BufferedReader( new StringReader( text.toString() ) ); + StringWriter buffer = new StringWriter(); + PrintWriter writer = new PrintWriter( buffer, true ) ) { + SimpleValue customCode = new SimpleValue<>( false ); + reader.lines().forEach( line -> { + if ( line.contains( startTag ) ) { + customCode.setValue( true ); + } else if ( line.contains( endTag ) ) { + customCode.setValue( false ); + } else if ( customCode.getValue().booleanValue() ) { + writer.println( line ); + } + } ); + return buffer.toString(); + } + } ); + } + + public static String addCustomContent( CharSequence text, String startTag, String endTag, String customContent ) { + return SafeFunction.get( () -> { + try ( BufferedReader reader = new BufferedReader( new StringReader( text.toString() ) ); + StringWriter buffer = new StringWriter(); + PrintWriter writer = new PrintWriter( buffer, true ) ) { + SimpleValue customCode = new SimpleValue<>( false ); + reader.lines().forEach( line -> { + if ( line.contains( startTag ) ) { + customCode.setValue( true ); + } else if ( line.contains( endTag ) ) { + writer.println( customContent ); // append custom content + customCode.setValue( false ); + } + // all lines myst be written anyway + writer.println( line ); + } ); + return buffer.toString(); + } + } ); + } + +} diff --git a/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java new file mode 100644 index 00000000..db4533c0 --- /dev/null +++ b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java @@ -0,0 +1,39 @@ +package test.org.fugerit.java.daogen.util; + +import java.io.File; + +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.FileIO; +import org.fugerit.java.core.javagen.SimpleJavaGenerator; +import org.fugerit.java.daogen.base.gen.util.ExtractCustomCode; +import org.junit.Assert; +import org.junit.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class TestExtractCustomCode { + + @Test + public void test001() { + SafeFunction.apply( () -> { + String path = "../fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java"; + String pathReal = "../fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java"; + File file = new File( path ); + File fileReal = new File( pathReal ); + log.info( "try source : {}", file.getCanonicalPath() ); + String content = FileIO.readString( file ); + String result = ExtractCustomCode.extractCustom( content , SimpleJavaGenerator.CUSTOM_CODE_START, SimpleJavaGenerator.CUSTOM_CODE_END ); + Assert.assertNotNull( result ); + log.info( "result : {}", result ); + log.info( "try correct : {}", fileReal.getCanonicalPath() ); + String realContent = FileIO.readString( fileReal ); + String resultReal = ExtractCustomCode.addCustomContent( realContent , SimpleJavaGenerator.CUSTOM_CODE_START, SimpleJavaGenerator.CUSTOM_CODE_END, result ); + Assert.assertNotNull( resultReal ); + } ); + + } + +} + + diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java index aae9aa63..902b79f7 100644 --- a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -14,19 +15,27 @@ import org.fugerit.java.core.cfg.ConfigException; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.io.FileIO; +import org.fugerit.java.core.javagen.SimpleJavaGenerator; import org.fugerit.java.core.lang.helpers.BooleanUtils; import org.fugerit.java.core.lang.helpers.StringUtils; +import org.fugerit.java.daogen.base.gen.util.ExtractCustomCode; import lombok.extern.slf4j.Slf4j; @Slf4j public class CompareHandler { + private static final String SERIAL_UID_STRING = "serialVersionUID"; + public static final String ARG_REPORT = "report"; public static final String ARG_TRY_DELETE_EQUAL = "try-delere-equal"; public static final String ARG_TRY_CORRECT_HELPER = "try-correct-helper"; + public static final String ARG_CUSTOM_CODE_START = "custom-code-start"; + public static final String ARG_CUSTOM_CODE_END = "custom-code-end"; + public static final String ARG_CUSTOM_IMPORT_START = "custom-import-start"; + public static final String ARG_CUSTOM_IMPORT_END = "custom-import-end"; public void handleCompare( File baseDir, File file1, File file2, Properties params ) { SafeFunction.apply( () -> { @@ -34,59 +43,79 @@ public void handleCompare( File baseDir, File file1, File file2, Properties para PrintWriter report = new PrintWriter( writer, true ) ) { String removePath = baseDir == null ? "" : baseDir.getCanonicalPath(); handleCompareWork(removePath, file1, file2, params, report); + log.info( "print report : \n{}", writer.toString() ); String reportFile = params.getProperty( ARG_REPORT ); if ( StringUtils.isNotEmpty( reportFile ) ) { log.info( "write report file : {}", reportFile ); FileIO.writeString( writer.toString() , new File(reportFile) ); - } else { - log.info( "print report : \n{}", writer.toString() ); } } } ); - } private String removePath( String path, String removePath ) { String res = path; - if ( StringUtils.isNotEmpty( removePath ) ) { - if ( path.indexOf( removePath ) == 0 ) { - res = path.substring( removePath.length() ); - } + if ( StringUtils.isNotEmpty( removePath ) && path.indexOf( removePath ) == 0) { + res = path.substring( removePath.length() ); } return res; } - private void tryCorrectHelperEqual( File file1, File file2, Properties params, PrintWriter report ) { + private void handleRealFileCorrect( File file2, Properties params, PrintWriter report, File realFile ) throws IOException { + report.print( "real file exists, try to correct from helper : "+realFile.getName() ); + String customCodeStart = params.getProperty( ARG_CUSTOM_CODE_START, SimpleJavaGenerator.CUSTOM_CODE_START ); + String customCodeEnd = params.getProperty( ARG_CUSTOM_CODE_END, SimpleJavaGenerator.CUSTOM_CODE_END ); + String customImportStart = params.getProperty( ARG_CUSTOM_IMPORT_START, SimpleJavaGenerator.CUSTOM_IMPORT_START ); + String customImportEnd = params.getProperty( ARG_CUSTOM_IMPORT_END, SimpleJavaGenerator.CUSTOM_IMPORT_END ); + String contentCode = ExtractCustomCode.extractCustom( file2 , customCodeStart, customCodeEnd); + String contentImport = ExtractCustomCode.extractCustom( file2 , customImportStart, customImportEnd); + log.info( "customCode : {}", contentCode ); + log.info( "contentImport : {}", contentImport ); + if ( StringUtils.isNotEmpty( contentCode ) || StringUtils.isNotEmpty( contentImport ) ) { + String realFileContent = FileIO.readString( realFile ); + if ( StringUtils.isNotEmpty( contentCode ) ) { + realFileContent = ExtractCustomCode.addCustomContent( realFileContent , customCodeStart, customCodeEnd, contentCode ); + } + if ( StringUtils.isNotEmpty( contentImport ) ) { + realFileContent = ExtractCustomCode.addCustomContent( realFileContent , customImportStart, customImportEnd, contentImport ); + } + FileIO.writeString( realFileContent , realFile ); + report.print( " real file customized! "+realFileContent ); + } + } + + private void tryCorrectHelperEqual( File file2, Properties params, PrintWriter report ) throws IOException { boolean tryCorrectHelper = BooleanUtils.isTrue( params.getProperty( ARG_TRY_CORRECT_HELPER ) ); - if ( tryCorrectHelper ) { - if ( file2.getName().endsWith( "Helper.java" ) ) { - String realFileName = file2.getName().replace( "Helper.java" , ".java" ); - File realFile = new File( file2.getParentFile(), realFileName ); - if ( realFile.exists() ) { - report.print( "real file exists, try to correct from helper : "+realFileName ); - } else { - report.print( "default real file not found : "+realFileName ); - } + if ( tryCorrectHelper && file2.getName().endsWith( "Helper.java" ) ) { + String realFileName = file2.getName().replace( "Helper.java" , ".java" ); + File realFile = new File( file2.getParentFile(), realFileName ); + if ( realFile.exists() ) { + handleRealFileCorrect(file2, params, report, realFile); + } else { + report.print( "default real file not found : "+realFileName ); } } } - private void tryDeleteEqual( File file1, File file2, Properties params, PrintWriter report ) { + private void tryDeleteEqual( File file2, Properties params, PrintWriter report ) throws IOException { boolean tryDeleteEqual = BooleanUtils.isTrue( params.getProperty( ARG_TRY_DELETE_EQUAL ) ); if ( tryDeleteEqual ) { - report.print( " - try delete equal result : "+file2.delete() ); + report.print( " - try delete equal result : "+ Files.deleteIfExists( file2.toPath() ) ); } } - private void compareFile( File file1, File file2, Properties params, PrintWriter report ) throws IOException { - List lines1 = new ArrayList<>(); - List lines2 = new ArrayList<>(); - try ( BufferedReader reader1 = new BufferedReader( new FileReader( file1 ) ); - BufferedReader reader2 = new BufferedReader( new FileReader( file2 ) ) ) { - lines1.addAll( reader1.lines().collect( Collectors.toList() ) ); - lines2.addAll( reader2.lines().collect( Collectors.toList() ) ); + private void checkDiffResult( File file2, Properties params, PrintWriter report, int diffSize, boolean differentUid ) throws IOException { + if ( diffSize > 0 ) { + report.print( " - diffeent lines : "+diffSize ); + } else { + this.tryDeleteEqual(file2, params, report); } - // check + if ( differentUid ) { + report.print( " - diffeent serialVersionUID" ); + } + } + + private void checkLines( File file2, Properties params, PrintWriter report, List lines1, List lines2 ) throws IOException { report.print( "file 1 size : "+lines1.size()+", " ); if ( lines1.size() == lines2.size() ) { report.print( "file 2 same size! " ); @@ -96,28 +125,33 @@ private void compareFile( File file1, File file2, Properties params, PrintWriter String current1 = lines1.get( k ); String current2 = lines2.get( k ); if ( !current1.equals( current2 ) ) { - if ( current1.contains( "serialVersionUID" ) && current2.contains( "serialVersionUID" ) ) { + if ( current1.contains( SERIAL_UID_STRING ) && current2.contains( SERIAL_UID_STRING ) ) { differentUid = true; } else { diffSize++; } } } - if ( diffSize > 0 ) { - report.print( " - diffeent lines : "+diffSize ); - } else { - this.tryDeleteEqual(file1, file2, params, report); - } - if ( differentUid ) { - report.print( " - diffeent serialVersionUID" ); - } + this.checkDiffResult( file2, params, report, diffSize, differentUid); } else { report.print( "file 2 size : "+lines1.size()+" DIFFERENT! " ); - this.tryCorrectHelperEqual(file1, file2, params, report); + this.tryCorrectHelperEqual(file2, params, report); } report.println(); } + private void compareFile( File file1, File file2, Properties params, PrintWriter report ) throws IOException { + List lines1 = new ArrayList<>(); + List lines2 = new ArrayList<>(); + try ( BufferedReader reader1 = new BufferedReader( new FileReader( file1 ) ); + BufferedReader reader2 = new BufferedReader( new FileReader( file2 ) ) ) { + lines1.addAll( reader1.lines().collect( Collectors.toList() ) ); + lines2.addAll( reader2.lines().collect( Collectors.toList() ) ); + } + // check + this.checkLines(file2, params, report, lines1, lines2); + } + private void handleCompareWork( String removePath, File file1, File file2, Properties params, PrintWriter report ) throws ConfigException, IOException { String fileEntry1 = removePath( file1.getCanonicalPath(), removePath ); String fileEntry2 = removePath( file2.getCanonicalPath(), removePath ); diff --git a/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java index dfc2203c..27198777 100644 --- a/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java +++ b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java @@ -18,7 +18,9 @@ @Slf4j public class TestCompareHandler { - private static final String SOURCE_TEST = "src/test/resources/compare_handler_test/daogen"; + private static final String SOURCE_GENERATED = "src/test/resources/compare_handler_test/daogen_generated"; + + private static final String SOURCE_ORIGINAL = "src/test/resources/compare_handler_test/daogen_original"; private static void copyHelper( File baseSource, File baseDest, File currentSource ) throws IOException { String relPath = currentSource.getCanonicalPath().substring( baseSource.getCanonicalPath().length() ); @@ -36,24 +38,38 @@ private static void copyHelper( File baseSource, File baseDest, File currentSour } } + private static int deleteRecurse( File dir ) { + int res = 0; + if ( dir.isDirectory() ) { + for ( File file : dir.listFiles() ) { + res+= deleteRecurse( file ); + } + } + if ( dir.delete() ) { + res++; + } + return res; + } + private static void copyHelper( File sourceFile, File testDir ) throws IOException { - if ( !testDir.exists() ) { - copyHelper(sourceFile, testDir, sourceFile ); - } else { - log.info( "testDir already exists! {}", testDir ); + if ( testDir.exists() ) { + int res = deleteRecurse( testDir ); + log.info( "delete result {} : {}", testDir, res ); } + copyHelper(sourceFile, testDir, sourceFile ); } private static void prepare( File file1, File file2 ) { SafeFunction.apply( () -> { - File sourceDir = new File( SOURCE_TEST ); + File sourceDir = new File( SOURCE_GENERATED ); + File sourceDirOriginal = new File( SOURCE_ORIGINAL ); copyHelper( sourceDir, file1 ); - copyHelper( sourceDir, file2 ); + copyHelper( sourceDirOriginal, file2 ); }); } @Test - public void test() { + public void test001() { File baseDir = new File( "target" ); File file1 = new File( baseDir, "daogen1" ); File file2 = new File( baseDir, "daogen2" ); @@ -62,6 +78,7 @@ public void test() { Assert.assertTrue( file2.exists() ); CompareHandler handler = new CompareHandler(); Properties params = new Properties(); + params.setProperty( CompareHandler.ARG_REPORT , "target/report_compare_handler_001.md" ); params.setProperty( CompareHandler.ARG_TRY_CORRECT_HELPER , BooleanUtils.BOOLEAN_TRUE ); params.setProperty( CompareHandler.ARG_TRY_DELETE_EQUAL , BooleanUtils.BOOLEAN_TRUE ); handler.handleCompare( baseDir, file1, file2, params ); diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java similarity index 100% rename from fj-daogen-tool/src/test/resources/compare_handler_test/daogen/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java rename to fj-daogen-tool/src/test/resources/compare_handler_test/daogen_generated/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java new file mode 100644 index 00000000..e93e5ae5 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityAddressFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * EntityAddressFacadeHelper, 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 interface EntityAddressFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelAddress + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelAddress + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, AddressFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param id Address system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelAddress loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelAddress + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelAddress model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param id Address system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelAddress + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelAddress model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java new file mode 100644 index 00000000..9f91e28d --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityLogDataFacadeHelper.java @@ -0,0 +1,50 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityLogDataFacadeHelper, 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 interface EntityLogDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelLogData + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelLogData + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, LogDataFinder finder ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java new file mode 100644 index 00000000..245b8bd3 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityTestTwoFieldKeyFacadeHelper.java @@ -0,0 +1,100 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityTestTwoFieldKeyFacadeHelper, 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 interface EntityTestTwoFieldKeyFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelTestTwoFieldKey + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelTestTwoFieldKey + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, TestTwoFieldKeyFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param idOne part of the key + * @param idTwo part of the key + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelTestTwoFieldKey loadById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException; + + /** + * Method to create an new entity of type : ModelTestTwoFieldKey + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param idOne part of the key + * @param idTwo part of the key + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelTestTwoFieldKey + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java new file mode 100644 index 00000000..cda9afe5 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUploadFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUploadFacadeHelper, 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 interface EntityUploadFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUpload + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUpload + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UploadFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param id part of the key + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUpload loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUpload + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUpload model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param id part of the key + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUpload + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUpload model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java new file mode 100644 index 00000000..f5ac9e9a --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserDataFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUserDataFacadeHelper, 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 interface EntityUserDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUserData + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUserData + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UserDataFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param id User system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUserData loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUserData + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUserData model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param id User system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUserData + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUserData model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java new file mode 100644 index 00000000..e677c99c --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/EntityUserFacadeHelper.java @@ -0,0 +1,98 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.DAOContext; +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 ) + +/** + * EntityUserFacadeHelper, 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 interface EntityUserFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + /* + * NOTE: It is advised to use a finder for incapsulating search params, except searches for primary key. + */ + + /** + * Method to load all the items for entity : ModelUser + * + * @param context DAOContext + * + * @return search result + * @throws DAOException in case of errors + */ + BasicDaoResult loadAll( DAOContext context ) throws DAOException; + + /** + * Method to load all the items for entity : ModelUser + * + * @param context DAOContext + * @param finder the finder incapsulating search params + * + * @return search result + * @throws DAOException in caso di errori + */ + BasicDaoResult loadAllByFinder( DAOContext context, UserFinder finder ) throws DAOException; + + /** + * Load method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param id User system id + + * + * @return The found object or null + * @throws DAOException in case of errors + */ + ModelUser loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Method to create an new entity of type : ModelUser + * + * A new ID should be assigned by this method. + * + * @param context DAO context + * @param model Entity to create + * + * @return The created entity + * @throws DAOException In case of any error. + */ + BasicDaoResult create( DAOContext context, ModelUser model ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param id User system id + + * + * @return Delete result (resultCode=0, delete ok) + * @throws DAOException in case of errors + */ + BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException; + + /** + * Delete method by primary key for entity : ModelUser + * + * @param context DAO Context + * @param model entity to update + * + * @return Update result (resultCode=0, update ok) + * @throws DAOException in case of errors + */ + BasicDaoResult updateById( DAOContext context, ModelUser model ) throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java new file mode 100644 index 00000000..c5da564d --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/def/facade/FugeritLogicFacadeHelper.java @@ -0,0 +1,72 @@ +package org.fugerit.java.daogen.sample.def.facade; + +import org.fugerit.java.core.db.dao.DAOException; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * FugeritLogicFacadeHelper, 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 interface FugeritLogicFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + public static final String ATT_NAME = "FugeritLogicFacadeHelper"; + + /** + * Facade incapsulating persistance for entity : ADDRESS + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade getEntityAddressFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : LOG_DATA + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade getEntityLogDataFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : TEST_TWO_FIELD_KEY + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade getEntityTestTwoFieldKeyFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : UPLOAD + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade getEntityUploadFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : USER + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUserFacade getEntityUserFacade() throws DAOException; + + /** + * Facade incapsulating persistance for entity : USER_DATA + * + * @return the facade + * @throws DAOException in case of problems + */ + org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade getEntityUserDataFacade() throws DAOException; + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java new file mode 100644 index 00000000..7ddcd3c9 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityAddressFacade, 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 DataEntityAddressFacade extends DataEntityAddressFacadeHelper implements EntityAddressFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 209491675380L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java new file mode 100644 index 00000000..0c3904ce --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java @@ -0,0 +1,150 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.AddressFinder; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacadeHelper; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; +import org.fugerit.java.daogen.sample.impl.rse.AddressRSE; + +// custom import start ( code above here will be overwritten ) +import java.sql.Timestamp; +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityAddressFacadeHelper, 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 DataEntityAddressFacadeHelper extends BasicDataFacade implements EntityAddressFacadeHelper { + + // custom code start ( code above here will be overwritten ) + public String testTimestamp() { + // Added only for test purpose + return String.valueOf( new Timestamp( System.currentTimeMillis() ) ); + } + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 12321213688L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.ADDRESS"; + + public DataEntityAddressFacadeHelper() { + super( TABLE_NAME, AddressRSE.DEFAULT, null ); + } + + public DataEntityAddressFacadeHelper( String tableName, String queryView ) { + super( tableName, AddressRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_ID_USER = "ID_USER"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, AddressFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelAddress model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_ID_USER, model.getIdUser() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelAddress model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_ID_USER, model.getIdUser() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_INFO, model.getInfo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelAddress loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelAddress result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelAddress model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_ID_USER, model.getIdUser() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_INFO, model.getInfo() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacade.java new file mode 100644 index 00000000..d1f05b7d --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityLogDataFacade, 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 DataEntityLogDataFacade extends DataEntityLogDataFacadeHelper implements EntityLogDataFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 84221996652L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java new file mode 100644 index 00000000..f9da555f --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityLogDataFacadeHelper.java @@ -0,0 +1,73 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.LogDataFinder; +import org.fugerit.java.daogen.sample.def.model.ModelLogData; +import org.fugerit.java.daogen.sample.impl.rse.LogDataRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityLogDataFacadeHelper, 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 DataEntityLogDataFacadeHelper extends BasicDataFacade implements EntityLogDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 913839672567L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.LOG_DATA"; + + public DataEntityLogDataFacadeHelper() { + super( TABLE_NAME, LogDataRSE.DEFAULT, null ); + } + + public DataEntityLogDataFacadeHelper( String tableName, String queryView ) { + super( tableName, LogDataRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_LOG_TIME = "LOG_TIME"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, LogDataFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelLogData model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_LOG_TIME, model.getLogTime() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacade.java new file mode 100644 index 00000000..d419126c --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityTestTwoFieldKeyFacade, 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 DataEntityTestTwoFieldKeyFacade extends DataEntityTestTwoFieldKeyFacadeHelper implements EntityTestTwoFieldKeyFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 885103477117L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java new file mode 100644 index 00000000..bf0a4af3 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityTestTwoFieldKeyFacadeHelper.java @@ -0,0 +1,134 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.TestTwoFieldKeyFinder; +import org.fugerit.java.daogen.sample.def.model.ModelTestTwoFieldKey; +import org.fugerit.java.daogen.sample.impl.rse.TestTwoFieldKeyRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityTestTwoFieldKeyFacadeHelper, 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 DataEntityTestTwoFieldKeyFacadeHelper extends BasicDataFacade implements EntityTestTwoFieldKeyFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 838819137461L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.TEST_TWO_FIELD_KEY"; + + public DataEntityTestTwoFieldKeyFacadeHelper() { + super( TABLE_NAME, TestTwoFieldKeyRSE.DEFAULT, null ); + } + + public DataEntityTestTwoFieldKeyFacadeHelper( String tableName, String queryView ) { + super( tableName, TestTwoFieldKeyRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID_ONE = "ID_ONE"; + public static final String COL_ID_TWO = "ID_TWO"; + public static final String COL_INFO = "INFO"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, TestTwoFieldKeyFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( finder.getModel() != null ) { + ModelTestTwoFieldKey model = finder.getModel(); + query.andEqualParam( COL_ID_ONE, model.getIdOne() ); + query.andEqualParam( COL_ID_TWO, model.getIdTwo() ); + query.andEqualParam( COL_INFO, model.getInfo() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getIdOne() == null ) { + model.setIdOne( this.generateId( context ) ); + } + if ( model.getIdTwo() == null ) { + model.setIdTwo( this.generateId( context ) ); + } + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID_ONE, model.getIdOne() ); + query.addParam( COL_ID_TWO, model.getIdTwo() ); + query.addParam( COL_INFO, model.getInfo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelTestTwoFieldKey loadById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + ModelTestTwoFieldKey result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( idOne == null || idTwo == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal idOne, java.math.BigDecimal idTwo" ); + } else { + query.andEqualParam( COL_ID_ONE, idOne ); + query.andEqualParam( COL_ID_TWO, idTwo ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID_ONE, idOne ); + query.andWhereParam( COL_ID_TWO, idTwo ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_INFO, model.getInfo() ); + query.andWhereParam( COL_ID_ONE, model.getIdOne() ); + query.andWhereParam( COL_ID_TWO, model.getIdTwo() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacade.java new file mode 100644 index 00000000..1845981e --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUploadFacade, 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 DataEntityUploadFacade extends DataEntityUploadFacadeHelper implements EntityUploadFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 484214149679L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java new file mode 100644 index 00000000..8e4bd7f8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUploadFacadeHelper.java @@ -0,0 +1,141 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UploadFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUpload; +import org.fugerit.java.daogen.sample.impl.rse.UploadRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUploadFacadeHelper, 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 DataEntityUploadFacadeHelper extends BasicDataFacade implements EntityUploadFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 962863269897L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.UPLOAD"; + + public DataEntityUploadFacadeHelper() { + super( TABLE_NAME, UploadRSE.DEFAULT, null ); + } + + public DataEntityUploadFacadeHelper( String tableName, String queryView ) { + super( tableName, UploadRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_CONTENT = "CONTENT"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UploadFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUpload model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_CONTENT, model.getContent() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUpload model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_CONTENT, model.getContent() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUpload loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUpload result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUpload model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_CONTENT, model.getContent() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacade.java new file mode 100644 index 00000000..3c6720a2 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserDataFacade, 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 DataEntityUserDataFacade extends DataEntityUserDataFacadeHelper implements EntityUserDataFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 414347890163L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java new file mode 100644 index 00000000..ed6f79b8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserDataFacadeHelper.java @@ -0,0 +1,153 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UserDataFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUserData; +import org.fugerit.java.daogen.sample.impl.rse.UserDataRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserDataFacadeHelper, 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 DataEntityUserDataFacadeHelper extends BasicDataFacade implements EntityUserDataFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 566958319786L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.USER"; + + public DataEntityUserDataFacadeHelper() { + super( TABLE_NAME, UserDataRSE.DEFAULT, null ); + } + + public DataEntityUserDataFacadeHelper( String tableName, String queryView ) { + super( tableName, UserDataRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_USERNAME = "USERNAME"; + public static final String COL_PASSWORD = "PASSWORD"; + public static final String COL_LAST_LOGIN = "LAST_LOGIN"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_STATE = "STATE"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UserDataFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUserData model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_USERNAME, model.getUsername() ); + query.andEqualParam( COL_PASSWORD, model.getPassword() ); + query.andEqualParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_STATE, model.getState() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUserData model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_USERNAME, model.getUsername() ); + query.addParam( COL_PASSWORD, model.getPassword() ); + query.addParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_STATE, model.getState() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUserData loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUserData result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUserData model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_USERNAME, model.getUsername() ); + query.addSetParam( COL_PASSWORD, model.getPassword() ); + query.addSetParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_STATE, model.getState() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacade.java new file mode 100644 index 00000000..68cca7ae --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacade.java @@ -0,0 +1,25 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserFacade, 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 DataEntityUserFacade extends DataEntityUserFacadeHelper implements EntityUserFacade { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 576230448583L; + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java new file mode 100644 index 00000000..85722231 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityUserFacadeHelper.java @@ -0,0 +1,153 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDAOHelper; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.BasicDataFacade; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.DeleteHelper; +import org.fugerit.java.core.db.daogen.InsertHelper; +import org.fugerit.java.core.db.daogen.SelectHelper; +import org.fugerit.java.core.db.daogen.UpdateHelper; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacadeHelper; +import org.fugerit.java.daogen.sample.def.facade.UserFinder; +import org.fugerit.java.daogen.sample.def.model.ModelUser; +import org.fugerit.java.daogen.sample.impl.rse.UserRSE; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * DataEntityUserFacadeHelper, 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 DataEntityUserFacadeHelper extends BasicDataFacade implements EntityUserFacadeHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 985222954894L; + + private static final String TABLE_NAME = "PUBLIC.FUGERIT.USER"; + + public DataEntityUserFacadeHelper() { + super( TABLE_NAME, UserRSE.DEFAULT, null ); + } + + public DataEntityUserFacadeHelper( String tableName, String queryView ) { + super( tableName, UserRSE.DEFAULT, queryView ); + } + + public static final String SEQUENCE_NAME = "seq_id_fugerit"; + + @Override + public String getSequenceName() { + return SEQUENCE_NAME; + } + + public static final String COL_ID = "ID"; + public static final String COL_USERNAME = "USERNAME"; + public static final String COL_PASSWORD = "PASSWORD"; + public static final String COL_LAST_LOGIN = "LAST_LOGIN"; + public static final String COL_DATE_INSERT = "DATE_INSERT"; + public static final String COL_DATE_UPDATE = "DATE_UPDATE"; + public static final String COL_STATE = "STATE"; + + /* loadAll( context ) is inherited from BasicDataFacade */ + + @Override + public BasicDaoResult loadAllByFinder( DAOContext context, UserFinder finder ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + query.andEqualParam( COL_ID, finder.getId() ); + if ( finder.getModel() != null ) { + ModelUser model = finder.getModel(); + query.andEqualParam( COL_ID, model.getId() ); + query.andEqualParam( COL_USERNAME, model.getUsername() ); + query.andEqualParam( COL_PASSWORD, model.getPassword() ); + query.andEqualParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.andEqualParam( COL_DATE_INSERT, model.getDateInsert() ); + query.andEqualParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.andEqualParam( COL_STATE, model.getState() ); + } + daoHelper.loadAllHelper( result.getList(), query, this.getRse() ); + result.evaluateResultFromList(); + return result; + } + + @Override + public BasicDaoResult create( DAOContext context, ModelUser model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + if ( model.getId() == null ) { + model.setId( this.generateId( context ) ); + } + java.sql.Timestamp currentTime = new java.sql.Timestamp( System.currentTimeMillis() ); + // default-column-time-insert : true - i will set insert time + model.setDateInsert( currentTime ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( currentTime ); + InsertHelper query = daoHelper.newInsertHelper( this.getTableName() ); + query.addParam( COL_ID, model.getId() ); + query.addParam( COL_USERNAME, model.getUsername() ); + query.addParam( COL_PASSWORD, model.getPassword() ); + query.addParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addParam( COL_STATE, model.getState() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + + @Override + public ModelUser loadById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + ModelUser result = null; + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + SelectHelper query = daoHelper.newSelectHelper( this.getQueryView(), this.getTableName() ); + if ( id == null ) { + throw new DAOException( "Null parameter in key java.math.BigDecimal id" ); + } else { + query.andEqualParam( COL_ID, id ); + } + result = daoHelper.loadOneHelper( query, this.getRse() ); + return result; + } + + @Override + public BasicDaoResult deleteById( DAOContext context, java.math.BigDecimal id ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + DeleteHelper query = daoHelper.newDeleteHelper( this.getTableName() ); + query.andWhereParam( COL_ID, id ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, null, result); + return result; + } + + @Override + public BasicDaoResult updateById( DAOContext context, ModelUser model ) throws DAOException { + BasicDaoResult result = new BasicDaoResult<>(); + BasicDAOHelper daoHelper = new BasicDAOHelper<>( context ); + // default-column-time-update : true - i will set update time + model.setDateUpdate( new java.sql.Timestamp( System.currentTimeMillis() ) ); + UpdateHelper query = daoHelper.newUpdateHelper( this.getTableName() ); + query.addSetParam( COL_USERNAME, model.getUsername() ); + query.addSetParam( COL_PASSWORD, model.getPassword() ); + query.addSetParam( COL_LAST_LOGIN, model.getLastLogin() ); + query.addSetParam( COL_DATE_INSERT, model.getDateInsert() ); + query.addSetParam( COL_DATE_UPDATE, model.getDateUpdate() ); + query.addSetParam( COL_STATE, model.getState() ); + query.andWhereParam( COL_ID, model.getId() ); + int res = daoHelper.update( query ); + this.evaluteSqlUpdateResult(res, model, result); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacade.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacade.java new file mode 100644 index 00000000..60a423d0 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacade.java @@ -0,0 +1,26 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * FugeritDataLogicFacade, 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 FugeritDataLogicFacade extends FugeritDataLogicFacadeHelper { + + /** + * + */ + private static final long serialVersionUID = -3428899643186915522L; + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + // [HELPER/IMPL MODEL] this class is a stub and can be modified as you see fit (it will not been overwritten) +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java new file mode 100644 index 00000000..5ce3715f --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/FugeritDataLogicFacadeHelper.java @@ -0,0 +1,106 @@ +package org.fugerit.java.daogen.sample.impl.facade.data; + +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacade; + +// custom import start ( code above here will be overwritten ) +// custom import end ( code below here will be overwritten ) + +/** + * FugeritDataLogicFacadeHelper, 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 FugeritDataLogicFacadeHelper implements org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacadeHelper, java.io.Serializable { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 306189539652L; + + + public FugeritDataLogicFacadeHelper() { + this.entityaddressfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityAddressFacade(); + this.entitylogdatafacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityLogDataFacade(); + this.entitytesttwofieldkeyfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityTestTwoFieldKeyFacade(); + this.entityuploadfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUploadFacade(); + this.entityuserfacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUserFacade(); + this.entityuserdatafacade = new org.fugerit.java.daogen.sample.impl.facade.data.DataEntityUserDataFacade(); + } + + private EntityAddressFacade entityaddressfacade; + + @Override + public EntityAddressFacade getEntityAddressFacade() throws DAOException { + return this.entityaddressfacade; + } + + protected void setEntityAddressFacade( EntityAddressFacade facade ) throws DAOException { + this.entityaddressfacade = facade; + } + + private EntityLogDataFacade entitylogdatafacade; + + @Override + public EntityLogDataFacade getEntityLogDataFacade() throws DAOException { + return this.entitylogdatafacade; + } + + protected void setEntityLogDataFacade( EntityLogDataFacade facade ) throws DAOException { + this.entitylogdatafacade = facade; + } + + private EntityTestTwoFieldKeyFacade entitytesttwofieldkeyfacade; + + @Override + public EntityTestTwoFieldKeyFacade getEntityTestTwoFieldKeyFacade() throws DAOException { + return this.entitytesttwofieldkeyfacade; + } + + protected void setEntityTestTwoFieldKeyFacade( EntityTestTwoFieldKeyFacade facade ) throws DAOException { + this.entitytesttwofieldkeyfacade = facade; + } + + private EntityUploadFacade entityuploadfacade; + + @Override + public EntityUploadFacade getEntityUploadFacade() throws DAOException { + return this.entityuploadfacade; + } + + protected void setEntityUploadFacade( EntityUploadFacade facade ) throws DAOException { + this.entityuploadfacade = facade; + } + + private EntityUserFacade entityuserfacade; + + @Override + public EntityUserFacade getEntityUserFacade() throws DAOException { + return this.entityuserfacade; + } + + protected void setEntityUserFacade( EntityUserFacade facade ) throws DAOException { + this.entityuserfacade = facade; + } + + private EntityUserDataFacade entityuserdatafacade; + + @Override + public EntityUserDataFacade getEntityUserDataFacade() throws DAOException { + return this.entityuserdatafacade; + } + + protected void setEntityUserDataFacade( EntityUserDataFacade facade ) throws DAOException { + this.entityuserdatafacade = facade; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java new file mode 100644 index 00000000..52d70c36 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadAddressHelper.java @@ -0,0 +1,188 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.AddressFinder; +import org.fugerit.java.daogen.sample.def.facade.EntityAddressFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.model.ModelAddress; + +// custom import start ( code above here will be overwritten ) +import java.sql.Timestamp; +// custom import end ( code below here will be overwritten ) + +/** + * LoadAddressHelper, 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 LoadAddressHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + public String testTimestamp() { + // Added only for test purpose + return String.valueOf( new Timestamp( System.currentTimeMillis() ) ); + } + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 830554611736L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + ModelAddress model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + ModelAddress model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + if ( result.getContent() != null ) { + result.getContent().setUser(LoadUser.loadByIdWorker( context, result.getContent().getIdUser() ).getContent()); + } + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelAddress. + * Property ModelAddress is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelAddress to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelAddress model ) throws DAOException { + AddressFinder finder = AddressFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityAddressFacade facade = factory.getEntityAddressFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelAddress. + * Property idUser is being used as filter + * + * @param context DAO context + * @param current Tee value of property idUser to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdUser( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperAddress model = new org.fugerit.java.daogen.sample.impl.helper.HelperAddress(); + model.setIdUser( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_user/{id_user}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdUser(@PathParam( "id_user" ) String idUser) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idUser); + SimpleServiceResult> result = loadByIdUser( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAllIdUser - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelAddress. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperAddress model = new org.fugerit.java.daogen.sample.impl.helper.HelperAddress(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadAddress - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java new file mode 100644 index 00000000..48816ee8 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadLogDataHelper.java @@ -0,0 +1,136 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityLogDataFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.LogDataFinder; +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 ) + +/** + * LoadLogDataHelper, 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 LoadLogDataHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 896855494315L; + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityLogDataFacade facade = factory.getEntityLogDataFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelLogData. + * Property ModelLogData is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelLogData to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelLogData model ) throws DAOException { + LogDataFinder finder = LogDataFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityLogDataFacade facade = factory.getEntityLogDataFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelLogData. + * Property id is being used as filter + * + * @param context DAO context + * @param current Tee value of property id to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadById( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperLogData model = new org.fugerit.java.daogen.sample.impl.helper.HelperLogData(); + model.setId( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllId(@PathParam( "id" ) String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(id); + SimpleServiceResult> result = loadById( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAllId - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelLogData. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperLogData model = new org.fugerit.java.daogen.sample.impl.helper.HelperLogData(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadLogData - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java new file mode 100644 index 00000000..a41036a7 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadTestTwoFieldKeyHelper.java @@ -0,0 +1,211 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityTestTwoFieldKeyFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.TestTwoFieldKeyFinder; +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 ) + +/** + * LoadTestTwoFieldKeyHelper, 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 LoadTestTwoFieldKeyHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 348976908673L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + ModelTestTwoFieldKey model = facade.loadById( context , idOne, idTwo ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/idOne/{idOne}/idTwo/{idTwo}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "idOne") String idOne, @PathParam( "idTwo") String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(idOne), new java.math.BigDecimal(idTwo) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal idOne, java.math.BigDecimal idTwo ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + ModelTestTwoFieldKey model = facade.loadById( context , idOne, idTwo ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/idOne/{idOne}/idTwo/{idTwo}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "idOne") String idOne, @PathParam( "idTwo") String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(idOne), new java.math.BigDecimal(idTwo) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property ModelTestTwoFieldKey is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelTestTwoFieldKey to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelTestTwoFieldKey model ) throws DAOException { + TestTwoFieldKeyFinder finder = TestTwoFieldKeyFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityTestTwoFieldKeyFacade facade = factory.getEntityTestTwoFieldKeyFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property idOne is being used as filter + * + * @param context DAO context + * @param current Tee value of property idOne to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdOne( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setIdOne( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_one/{id_one}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdOne(@PathParam( "id_one" ) String idOne) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idOne); + SimpleServiceResult> result = loadByIdOne( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllIdOne - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property idTwo is being used as filter + * + * @param context DAO context + * @param current Tee value of property idTwo to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByIdTwo( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setIdTwo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/id_two/{id_two}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllIdTwo(@PathParam( "id_two" ) String idTwo) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(idTwo); + SimpleServiceResult> result = loadByIdTwo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllIdTwo - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelTestTwoFieldKey. + * Property info is being used as filter + * + * @param context DAO context + * @param current Tee value of property info to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByInfo( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey model = new org.fugerit.java.daogen.sample.impl.helper.HelperTestTwoFieldKey(); + model.setInfo( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/info/{info}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllInfo(@PathParam( "info" ) String info) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = info; + SimpleServiceResult> result = loadByInfo( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadTestTwoFieldKey - getAllInfo - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java new file mode 100644 index 00000000..6661488c --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUploadHelper.java @@ -0,0 +1,118 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUploadFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UploadFinder; +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 ) + +/** + * LoadUploadHelper, 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 LoadUploadHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 407430847282L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + ModelUpload model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + ModelUpload model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUpload - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUpload. + * Property ModelUpload is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUpload to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUpload model ) throws DAOException { + UploadFinder finder = UploadFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUploadFacade facade = factory.getEntityUploadFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java new file mode 100644 index 00000000..3d5c0f22 --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserDataHelper.java @@ -0,0 +1,211 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUserDataFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UserDataFinder; +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 ) + +/** + * LoadUserDataHelper, 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 LoadUserDataHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 363048926673L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + ModelUserData model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + ModelUserData model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property ModelUserData is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUserData to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUserData model ) throws DAOException { + UserDataFinder finder = UserDataFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserDataFacade facade = factory.getEntityUserDataFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelUserData. + * Property username is being used as filter + * + * @param context DAO context + * @param current Tee value of property username to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByUsername( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setUsername( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/username/{username}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllUsername(@PathParam( "username" ) String username) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = username; + SimpleServiceResult> result = loadByUsername( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllUsername - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property password is being used as filter + * + * @param context DAO context + * @param current Tee value of property password to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByPassword( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setPassword( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/password/{password}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllPassword(@PathParam( "password" ) String password) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = password; + SimpleServiceResult> result = loadByPassword( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllPassword - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUserData. + * Property state is being used as filter + * + * @param context DAO context + * @param current Tee value of property state to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByState( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUserData model = new org.fugerit.java.daogen.sample.impl.helper.HelperUserData(); + model.setState( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/state/{state}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllState(@PathParam( "state" ) String state) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(state); + SimpleServiceResult> result = loadByState( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUserData - getAllState - "+e, e ); + } + return res; + } + +} diff --git a/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java new file mode 100644 index 00000000..73189ecf --- /dev/null +++ b/fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/rest/load/LoadUserHelper.java @@ -0,0 +1,214 @@ +package org.fugerit.java.daogen.sample.impl.rest.load; + +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.fugerit.java.core.db.dao.DAOException; +import org.fugerit.java.core.db.daogen.BasicDaoResult; +import org.fugerit.java.core.db.daogen.CloseableDAOContext; +import org.fugerit.java.core.db.daogen.DAOContext; +import org.fugerit.java.core.db.daogen.SimpleServiceResult; +import org.fugerit.java.daogen.sample.def.facade.EntityUserFacade; +import org.fugerit.java.daogen.sample.def.facade.FugeritLogicFacade; +import org.fugerit.java.daogen.sample.def.facade.UserFinder; +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 ) + +/** + * LoadUserHelper, 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 LoadUserHelper extends org.fugerit.java.daogen.sample.helper.ServiceProviderHelper { + + // custom code start ( code above here will be overwritten ) + // custom code end ( code below here will be overwritten ) + + private static final long serialVersionUID = 315520622489L; + + public static SimpleServiceResult loadByIdWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + ModelUser model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + return result; + } + + @GET + @Path("/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByID(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getByID - "+e, e ); + } + return res; + } + + public static SimpleServiceResult loadByIdDeepWorker( DAOContext context, java.math.BigDecimal id ) throws DAOException { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + ModelUser model = facade.loadById( context , id ); + SimpleServiceResult result = SimpleServiceResult.newDefaultResult( model ); + if ( result.getContent() != null ) { + result.getContent().setUserAddresses(LoadAddress.loadByIdUser( context, result.getContent().getId() ).getContent()); + } + return result; + } + + @GET + @Path("/deep/id/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getByIDdeep(@PathParam( "id") String id) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + SimpleServiceResult result = loadByIdDeepWorker( context, new java.math.BigDecimal(id) ); + res = this.createResponseFromObject( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getByID - "+e, e ); + } + return res; + } + + @GET + @Path("/all") + @Produces(MediaType.APPLICATION_JSON) + public Response getAll() throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + BasicDaoResult resultFacade = facade.loadAll( context ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAll - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property ModelUser is being used as filter + * + * @param context DAO context + * @param model Tee value of property ModelUser to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByModelWorker( DAOContext context, ModelUser model ) throws DAOException { + UserFinder finder = UserFinder.newInstance( model ); + FugeritLogicFacade factory = (FugeritLogicFacade) context.getAttribute(FugeritLogicFacade.ATT_NAME ); + EntityUserFacade facade = factory.getEntityUserFacade(); + BasicDaoResult resultFacade = facade.loadAllByFinder( context , finder ); + SimpleServiceResult> result = SimpleServiceResult.newDefaultResult( resultFacade.getList() ); + return result; + } + + /** + * Service method to load entity of type ModelUser. + * Property username is being used as filter + * + * @param context DAO context + * @param current Tee value of property username to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByUsername( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setUsername( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/username/{username}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllUsername(@PathParam( "username" ) String username) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = username; + SimpleServiceResult> result = loadByUsername( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllUsername - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property password is being used as filter + * + * @param context DAO context + * @param current Tee value of property password to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByPassword( DAOContext context, java.lang.String current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setPassword( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/password/{password}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllPassword(@PathParam( "password" ) String password) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + String value = password; + SimpleServiceResult> result = loadByPassword( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllPassword - "+e, e ); + } + return res; + } + + /** + * Service method to load entity of type ModelUser. + * Property state is being used as filter + * + * @param context DAO context + * @param current Tee value of property state to use as a filter + * @return the result found + * @throws DAOException in case of any issue + */ + public static SimpleServiceResult> loadByState( DAOContext context, java.math.BigDecimal current ) throws DAOException { + org.fugerit.java.daogen.sample.impl.helper.HelperUser model = new org.fugerit.java.daogen.sample.impl.helper.HelperUser(); + model.setState( current ); + SimpleServiceResult> result = loadByModelWorker( context , model ); + return result; + } + + @GET + @Path("/state/{state}") + @Produces(MediaType.APPLICATION_JSON) + public Response getAllState(@PathParam( "state" ) String state) throws Exception { + Response res = null; + try (CloseableDAOContext context = this.newDefaultContext() ) { + java.math.BigDecimal value = new java.math.BigDecimal(state); + SimpleServiceResult> result = loadByState( context, value ); + res = this.createResponseFromList( result ); + } catch(Exception e) { + logger.error("ERRORE - REST- LoadUser - getAllState - "+e, e ); + } + return res; + } + +} diff --git a/src/docs/config/daogen-config-xsd-ref.html b/src/docs/config/daogen-config-xsd-ref.html index eadaa2c0..415ff0b6 100644 --- a/src/docs/config/daogen-config-xsd-ref.html +++ b/src/docs/config/daogen-config-xsd-ref.html @@ -212,10 +212,10 @@

Reference daogen-config.xsd documentation for Ma - src-helpers + relations-last - Relative path to 'base-src-folder' attribute. The directory helper java files. (default to 'src-main-java'). It will be used by the relevant generators as output folder . + 'true' if the entities should be generated at the end. string @@ -223,10 +223,10 @@

Reference daogen-config.xsd documentation for Ma - src-mvn-generated-sources + src-helpers - Relative path to 'base-src-folder' attribute. The directory for maven plugin generated file. mainly to be used by fj-daogen-maven-plugin. It will be used by the relevant generators as output folder . + Relative path to 'base-src-folder' attribute. The directory helper java files. (default to 'src-main-java'). It will be used by the relevant generators as output folder . string @@ -234,10 +234,10 @@

Reference daogen-config.xsd documentation for Ma - class-config + src-mvn-generated-sources - The class mapping for DaoGen classes. It will be default to 'cl://config/daogen_default_class_config.xml'. It is usually safe to keep the default. + Relative path to 'base-src-folder' attribute. The directory for maven plugin generated file. mainly to be used by fj-daogen-maven-plugin. It will be used by the relevant generators as output folder . string @@ -245,10 +245,10 @@

Reference daogen-config.xsd documentation for Ma - type-mapper + class-config - The type mapper. It will be default to 'org.fugerit.java.daogen.base.config.DaogenTypeMapper'. It is usually safe to keep the default. + The class mapping for DaoGen classes. It will be default to 'cl://config/daogen_default_class_config.xml'. It is usually safe to keep the default. string @@ -256,10 +256,10 @@

Reference daogen-config.xsd documentation for Ma - type-map-config + type-mapper - The type mapper config. It will be default to 'cl://config/daogen_default_type_mapping.xml'. It is usually safe to keep the default. + The type mapper. It will be default to 'org.fugerit.java.daogen.base.config.DaogenTypeMapper'. It is usually safe to keep the default. string @@ -267,10 +267,10 @@

Reference daogen-config.xsd documentation for Ma - generator-catalog + type-map-config - The generator catalog. It will be default to 'cl://config/default-generator-catalog.xml'. It is usually safe to keep the default. + The type mapper config. It will be default to 'cl://config/daogen_default_type_mapping.xml'. It is usually safe to keep the default. string @@ -278,10 +278,10 @@

Reference daogen-config.xsd documentation for Ma - decorator-catalog + generator-catalog - The decorator catalog. It will be default to 'cl://config/default-decorator-catalog.xml'. It is usually safe to keep the default. + The generator catalog. It will be default to 'cl://config/default-generator-catalog.xml'. It is usually safe to keep the default. string @@ -289,10 +289,10 @@

Reference daogen-config.xsd documentation for Ma - default-column-time-insert + decorator-catalog - The default column to be used for 'insert' time. (e.g. 'DATE_INSERT'). Set this property only if you want a special handling of this column. + The decorator catalog. It will be default to 'cl://config/default-decorator-catalog.xml'. It is usually safe to keep the default. string @@ -300,10 +300,10 @@

Reference daogen-config.xsd documentation for Ma - default-column-time-update + default-column-time-insert - The default column to be used for 'last update' time. (e.g. 'DATE_INSERT'). Set this property only if you want a special handling of this column. + The default column to be used for 'insert' time. (e.g. 'DATE_INSERT'). Set this property only if you want a special handling of this column. string @@ -311,10 +311,10 @@

Reference daogen-config.xsd documentation for Ma - struct-prefix + default-column-time-update - The prefix for java.sql.Struct classes, it will default to 'OBJ_'. Common alternative may be 'UT_' (for user type). It is usually safe to keep the default. + The default column to be used for 'last update' time. (e.g. 'DATE_INSERT'). Set this property only if you want a special handling of this column. string @@ -322,10 +322,10 @@

Reference daogen-config.xsd documentation for Ma - package-model + struct-prefix - 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 prefix for java.sql.Struct classes, it will default to 'OBJ_'. Common alternative may be 'UT_' (for user type). It is usually safe to keep the default. string @@ -333,10 +333,10 @@

Reference daogen-config.xsd documentation for Ma - package-helper + package-model - 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 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. string @@ -344,10 +344,10 @@

Reference daogen-config.xsd documentation for Ma - package-struct + package-helper - 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. + 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. string @@ -355,10 +355,10 @@

Reference daogen-config.xsd documentation for Ma - 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 @@ -366,10 +366,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 @@ -377,10 +377,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 @@ -388,10 +388,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 @@ -399,10 +399,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 @@ -410,10 +410,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 @@ -421,10 +421,10 @@

Reference daogen-config.xsd documentation for Ma - base-rest-service + package-rest-load - 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. + 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 @@ -432,21 +432,21 @@

Reference daogen-config.xsd documentation for Ma - openapi_host + package-spring-rest-load - The host to be used for openapi specification and implementation specification. + 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. - anyURI + string - openapi_path + base-rest-service - The path 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. string @@ -454,25 +454,47 @@

Reference daogen-config.xsd documentation for Ma - default-sequence + openapi_host - The default sequence name to be used for the entities (it is possible to override it). + The host to be used for openapi specification and implementation specification. - string + anyURI - check-empty-interface + openapi_path - If set to '1' will check if interfaces have no methods. NOTE: currently ignored. + The path to be used for openapi specification and implementation specification. string + + + + default-sequence + + + The default sequence name to be used for the entities (it is possible to override it). + + + string + + + + + check-empty-interface + + + If set to '1' will check if interfaces have no methods. NOTE: currently ignored. + + + string + @@ -516,10 +538,10 @@

Reference daogen-config.xsd documentation for Ma - name + comment - The name of the relation. (e.g. 'USER_ADDRESSES') It will be used by all relevant generators as base name. (eventually converted with the proper case). + Comment for the relation. string @@ -527,10 +549,10 @@

Reference daogen-config.xsd documentation for Ma - from + name - The name of the entity from which the relation originate. (the model will contain the set method). (e.g. 'PUBLIC.FUGERIT.USER') + The name of the relation. (e.g. 'USER_ADDRESSES') It will be used by all relevant generators as base name. (eventually converted with the proper case). string @@ -538,10 +560,10 @@

Reference daogen-config.xsd documentation for Ma - to + from - The name of the entity to which the relation goes. (e.g. 'PUBLIC.FUGERIT.ADDRESS') + The name of the entity from which the relation originate. (the model will contain the set method). (e.g. 'PUBLIC.FUGERIT.USER') string @@ -549,10 +571,10 @@

Reference daogen-config.xsd documentation for Ma - mode + to - The mode of the relation, 'one' or 'many'. (e.g. 'many') + The name of the entity to which the relation goes. (e.g. 'PUBLIC.FUGERIT.ADDRESS') string @@ -560,14 +582,25 @@

Reference daogen-config.xsd documentation for Ma - key + mode - The list of comma separated field ids to be used for mapping the relation. (e.g. 'ID_USER') + The mode of the relation, 'one' or 'many'. (e.g. 'many') relationModeType , base : string , enumeration : [ one , many ] + + + + key + + + The list of comma separated field ids to be used for mapping the relation. (e.g. 'ID_USER') + + + string + @@ -655,10 +688,10 @@

Reference daogen-config.xsd documentation for Ma - sequenceName + catalog - The sequence name for this entity. (it not present will default to global 'default-sequence') (e.g. 'SEQ_USER') + The catalog name for the entity. If present it will be prefixed to table name for query. (e.g. 'PUBLIC') string @@ -666,10 +699,10 @@

Reference daogen-config.xsd documentation for Ma - foreignKeys + sequenceName - Comma separated list of entity ids. (e.g. 'PUBLIC.FUGERIT.USER') + The sequence name for this entity. (it not present will default to global 'default-sequence') (e.g. 'SEQ_USER') string @@ -677,14 +710,25 @@

Reference daogen-config.xsd documentation for Ma - facadeMode + foreignKeys - Facade mode, comma separated list of accepted values 'complete' (default), 'select', 'insert', 'delete', 'update', 'none'. (e.g. 'complete') It is usually safe to keep the default. + Comma separated list of entity ids. (e.g. 'PUBLIC.FUGERIT.USER') string + + + + facadeMode + + + Facade mode, comma separated list of accepted values 'complete' (default), 'select', 'insert', 'delete', 'update', 'none'. (e.g. 'complete') It is usually safe to keep the default. + + + string + From d78652bda7ce92a3db05311c4460ecdaf17b40c2 Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Wed, 13 Sep 2023 11:28:54 +0200 Subject: [PATCH 4/5] fix to custom code substitution #13 --- .../base/gen/util/ExtractCustomCode.java | 58 +++++++++++++++++++ .../daogen/util/TestExtractCustomCode.java | 33 ++++++++++- .../base/tool/handler/CompareHandler.java | 4 +- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java index 15aa5ca8..0c57be2e 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java @@ -5,10 +5,14 @@ import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.function.SimpleValue; import org.fugerit.java.core.io.FileIO; +import org.fugerit.java.core.lang.helpers.StringUtils; public class ExtractCustomCode { @@ -59,4 +63,58 @@ public static String addCustomContent( CharSequence text, String startTag, Strin } ); } + private static String addWithCondition( CharSequence text, String customContent, Function condition ) { + return SafeFunction.get( () -> { + try ( BufferedReader reader = new BufferedReader( new StringReader( text.toString() ) ); + StringWriter buffer = new StringWriter(); + PrintWriter writer = new PrintWriter( buffer, true ) ) { + List lines = reader.lines().collect( Collectors.toList() ); + LineCursor cursor = new LineCursor(); + cursor.lines = lines; + for ( cursor.index = 0; cursor.index { + boolean ok = false; + String previousLine = c.getPreviousLine(); + if ( StringUtils.isNotEmpty( previousLine ) ) { + ok = previousLine.trim().startsWith( "package" ); + } + return ok; + } ); + } + + public static String addBeforeClassEnd( CharSequence text, String customContent ) { + return addWithCondition(text, customContent, c -> c.isLast() && c.getCurrentLine().trim().equals( "}" ) ); + } + +} + +class LineCursor { + + public List lines; + + public int index; + + public boolean isLast() { + return this.lines.size()-1 == this.index; + } + + public String getPreviousLine() { + return this.index==0 ? null : this.lines.get( this.index-1 ); + } + + public String getCurrentLine() { + return this.lines.get( this.index ); + } } diff --git a/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java index db4533c0..8625336c 100644 --- a/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java +++ b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/util/TestExtractCustomCode.java @@ -26,12 +26,43 @@ public void test001() { String result = ExtractCustomCode.extractCustom( content , SimpleJavaGenerator.CUSTOM_CODE_START, SimpleJavaGenerator.CUSTOM_CODE_END ); Assert.assertNotNull( result ); log.info( "result : {}", result ); + // try to correct log.info( "try correct : {}", fileReal.getCanonicalPath() ); String realContent = FileIO.readString( fileReal ); + // test real mode 1 String resultReal = ExtractCustomCode.addCustomContent( realContent , SimpleJavaGenerator.CUSTOM_CODE_START, SimpleJavaGenerator.CUSTOM_CODE_END, result ); Assert.assertNotNull( resultReal ); + // test real mode 2 + log.info( "try correct alt : {}", fileReal.getCanonicalPath() ); + String resultRealAlt = ExtractCustomCode.addBeforeClassEnd( realContent , result ); + log.info( "real result alt {}", resultRealAlt ); + Assert.assertNotNull( resultRealAlt ); + } ); + } + + @Test + public void test002() { + SafeFunction.apply( () -> { + String path = "../fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacadeHelper.java"; + String pathReal = "../fj-daogen-tool/src/test/resources/compare_handler_test/daogen_original/org/fugerit/java/daogen/sample/impl/facade/data/DataEntityAddressFacade.java"; + File file = new File( path ); + File fileReal = new File( pathReal ); + log.info( "try source : {}", file.getCanonicalPath() ); + String result = ExtractCustomCode.extractCustom( file , SimpleJavaGenerator.CUSTOM_IMPORT_START, SimpleJavaGenerator.CUSTOM_IMPORT_END ); + Assert.assertNotNull( result ); + log.info( "result : {}", result ); + // try to correct + log.info( "try correct : {}", fileReal.getCanonicalPath() ); + String realContent = FileIO.readString( fileReal ); + // test real mode 1 + String resultReal = ExtractCustomCode.addCustomContent( realContent , SimpleJavaGenerator.CUSTOM_IMPORT_START, SimpleJavaGenerator.CUSTOM_IMPORT_END, result ); + Assert.assertNotNull( resultReal ); + // test real mode 2 + log.info( "try correct alt : {}", fileReal.getCanonicalPath() ); + String resultRealAlt = ExtractCustomCode.addAfterPackageClassEnd( realContent , result ); + log.info( "real result alt {}", resultRealAlt ); + Assert.assertNotNull( resultRealAlt ); } ); - } } diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java index 902b79f7..9c1ba651 100644 --- a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java @@ -74,10 +74,10 @@ private void handleRealFileCorrect( File file2, Properties params, PrintWriter r if ( StringUtils.isNotEmpty( contentCode ) || StringUtils.isNotEmpty( contentImport ) ) { String realFileContent = FileIO.readString( realFile ); if ( StringUtils.isNotEmpty( contentCode ) ) { - realFileContent = ExtractCustomCode.addCustomContent( realFileContent , customCodeStart, customCodeEnd, contentCode ); + realFileContent = ExtractCustomCode.addBeforeClassEnd( realFileContent, contentCode ); } if ( StringUtils.isNotEmpty( contentImport ) ) { - realFileContent = ExtractCustomCode.addCustomContent( realFileContent , customImportStart, customImportEnd, contentImport ); + realFileContent = ExtractCustomCode.addAfterPackageClassEnd( realFileContent, contentImport ); } FileIO.writeString( realFileContent , realFile ); report.print( " real file customized! "+realFileContent ); From 73f5a9c0f62fd07f78a6cb6750cc6b575dcde2b1 Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Wed, 13 Sep 2023 12:16:37 +0200 Subject: [PATCH 5/5] Test coverage for tool compare #13 --- .../base/gen/util/ExtractCustomCode.java | 21 ++++++----- .../daogen/base/tool/DaoGenToolHandler.java | 5 +++ .../base/tool/handler/CompareHandler.java | 28 +++++++++++++++ fj-daogen-tool/src/main/java/tool/DaoGen.java | 14 ++------ .../daogen/base/tool/TestCompareHandler.java | 35 ++++++++++++++++++- 5 files changed, 83 insertions(+), 20 deletions(-) diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java index 0c57be2e..e403e16a 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/ExtractCustomCode.java @@ -6,7 +6,7 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.List; -import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.fugerit.java.core.function.SafeFunction; @@ -14,6 +14,9 @@ import org.fugerit.java.core.io.FileIO; import org.fugerit.java.core.lang.helpers.StringUtils; +import lombok.Getter; +import lombok.Setter; + public class ExtractCustomCode { private ExtractCustomCode() {} @@ -63,20 +66,22 @@ public static String addCustomContent( CharSequence text, String startTag, Strin } ); } - private static String addWithCondition( CharSequence text, String customContent, Function condition ) { + private static String addWithCondition( CharSequence text, String customContent, Predicate condition ) { return SafeFunction.get( () -> { try ( BufferedReader reader = new BufferedReader( new StringReader( text.toString() ) ); StringWriter buffer = new StringWriter(); PrintWriter writer = new PrintWriter( buffer, true ) ) { List lines = reader.lines().collect( Collectors.toList() ); LineCursor cursor = new LineCursor(); - cursor.lines = lines; - for ( cursor.index = 0; cursor.index lines; + @Getter @Setter private List lines; - public int index; + @Getter @Setter private int index; public boolean isLast() { return this.lines.size()-1 == this.index; diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/DaoGenToolHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/DaoGenToolHandler.java index a7398632..26282e58 100644 --- a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/DaoGenToolHandler.java +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/DaoGenToolHandler.java @@ -14,6 +14,7 @@ import org.fugerit.java.core.lang.helpers.StringUtils; import org.fugerit.java.core.util.PropsIO; import org.fugerit.java.daogen.base.config.DaogenFacade; +import org.fugerit.java.daogen.base.tool.handler.CompareHandler; import org.fugerit.java.daogen.base.config.DaogenConfigDump; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,7 @@ private DaoGenToolHandler() {} public static final String ARG_ACTION = "action"; public static final String ARG_ACTION_DAOGEN = "daogen"; public static final String ARG_ACTION_DUMP = "dump"; + public static final String ARG_ACTION_COMPARE = "compare"; public static void handle( Properties params ) { String action = params.getProperty( ARG_ACTION ); @@ -41,6 +43,9 @@ public static void handle( Properties params ) { handleDaogen(params); } else if ( ARG_ACTION_DUMP.equalsIgnoreCase( action ) ) { handleDump(params); + } else if ( ARG_ACTION_COMPARE.equalsIgnoreCase( action ) ) { + CompareHandler handler = new CompareHandler(); + handler.handleCompare(params); } else { throw new ConfigRuntimeException( "Reuired parameter : "+ARG_ACTION+" ("+ARG_ACTION_DAOGEN+"|"+ARG_ACTION_DUMP+")" ); } diff --git a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java index 9c1ba651..b31aff4e 100644 --- a/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java +++ b/fj-daogen-tool/src/main/java/org/fugerit/java/daogen/base/tool/handler/CompareHandler.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.io.FileIO; import org.fugerit.java.core.javagen.SimpleJavaGenerator; @@ -27,6 +28,10 @@ public class CompareHandler { private static final String SERIAL_UID_STRING = "serialVersionUID"; + public static final String ARG_BASE_FOLDER = "base-folder"; + public static final String ARG_FOLDER1 = "folder1"; + public static final String ARG_FOLDER2 = "folder1"; + public static final String ARG_REPORT = "report"; public static final String ARG_TRY_DELETE_EQUAL = "try-delere-equal"; @@ -37,6 +42,29 @@ public class CompareHandler { public static final String ARG_CUSTOM_IMPORT_START = "custom-import-start"; public static final String ARG_CUSTOM_IMPORT_END = "custom-import-end"; + private File getFolder( Properties params, String param, boolean required ) { + File file = null; + String path = params.getProperty( param ); + if ( required && StringUtils.isEmpty( path ) ) { + throw new ConfigRuntimeException( "Required arg missing : "+param ); + } else { + if ( StringUtils.isNotEmpty( path ) ) { + file = new File( path ); + if ( !file.exists() ) { + throw new ConfigRuntimeException( "Directory not exists : "+param+", path : "+path ); + } + } + } + return file; + } + + public void handleCompare( Properties params ) { + File baseDir = getFolder( params, ARG_BASE_FOLDER, false ); + File file1 = getFolder( params, ARG_FOLDER1, true ); + File file2 = getFolder( params, ARG_FOLDER2, true ); + handleCompare(baseDir, file1, file2, params); + } + public void handleCompare( File baseDir, File file1, File file2, Properties params ) { SafeFunction.apply( () -> { try ( StringWriter writer = new StringWriter(); diff --git a/fj-daogen-tool/src/main/java/tool/DaoGen.java b/fj-daogen-tool/src/main/java/tool/DaoGen.java index 670172a2..3aa4b724 100644 --- a/fj-daogen-tool/src/main/java/tool/DaoGen.java +++ b/fj-daogen-tool/src/main/java/tool/DaoGen.java @@ -2,9 +2,8 @@ import java.util.Properties; import org.fugerit.java.core.cli.ArgUtils; +import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.daogen.base.tool.DaoGenToolHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @@ -14,18 +13,11 @@ */ public class DaoGen { - private static final Logger logger = LoggerFactory.getLogger( DaoGen.class ); - public static void main( String[] args ) { - int exit = 0; - try { + SafeFunction.apply( () -> { Properties params = ArgUtils.getArgs( args, true ); DaoGenToolHandler.handle( params ); - } catch (Exception e) { - logger.error( "Error "+e, e ); - exit = 1; - } - System.exit( exit ); + } ); } } diff --git a/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java index 27198777..05d27173 100644 --- a/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java +++ b/fj-daogen-tool/src/test/java/test/org/fugerit/java/daogen/base/tool/TestCompareHandler.java @@ -6,14 +6,18 @@ import java.io.IOException; import java.util.Properties; +import org.fugerit.java.core.cfg.ConfigRuntimeException; +import org.fugerit.java.core.cli.ArgUtils; import org.fugerit.java.core.function.SafeFunction; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.daogen.base.tool.DaoGenToolHandler; import org.fugerit.java.daogen.base.tool.handler.CompareHandler; import org.junit.Assert; import org.junit.Test; import lombok.extern.slf4j.Slf4j; +import tool.DaoGen; @Slf4j public class TestCompareHandler { @@ -22,6 +26,8 @@ public class TestCompareHandler { private static final String SOURCE_ORIGINAL = "src/test/resources/compare_handler_test/daogen_original"; + private static final File OUTPUT_BASE = new File( "target" ); + private static void copyHelper( File baseSource, File baseDest, File currentSource ) throws IOException { String relPath = currentSource.getCanonicalPath().substring( baseSource.getCanonicalPath().length() ); File newFile = new File( baseDest, relPath ); @@ -70,7 +76,7 @@ private static void prepare( File file1, File file2 ) { @Test public void test001() { - File baseDir = new File( "target" ); + File baseDir = OUTPUT_BASE; File file1 = new File( baseDir, "daogen1" ); File file2 = new File( baseDir, "daogen2" ); prepare(file1, file2); @@ -84,4 +90,31 @@ public void test001() { handler.handleCompare( baseDir, file1, file2, params ); } + @Test + public void test002() { + File baseDir = OUTPUT_BASE; + File file1 = new File( baseDir, "daogen1alt" ); + File file2 = new File( baseDir, "daogen2alt" ); + prepare(file1, file2); + Assert.assertTrue( file1.exists() ); + Assert.assertTrue( file2.exists() ); + SafeFunction.apply( () -> { + String[] args = { + ArgUtils.getArgString( DaoGenToolHandler.ARG_ACTION ), DaoGenToolHandler.ARG_ACTION_COMPARE, + ArgUtils.getArgString( CompareHandler.ARG_FOLDER1 ), file1.getCanonicalPath(), + ArgUtils.getArgString( CompareHandler.ARG_FOLDER2 ), file2.getCanonicalPath(), + }; + DaoGen.main(args); + } ); + } + + @Test + public void test003Fail() { + CompareHandler handler = new CompareHandler(); + Properties params = new Properties(); + Assert.assertThrows( ConfigRuntimeException.class , () -> handler.handleCompare(params) ); + params.setProperty( CompareHandler.ARG_FOLDER1 , "not-exists" ); + Assert.assertThrows( ConfigRuntimeException.class , () -> handler.handleCompare(params) ); + } + }