diff --git a/docgen/parameters.json b/docgen/parameters.json index 93e217b57..11b4ffa15 100644 --- a/docgen/parameters.json +++ b/docgen/parameters.json @@ -1,8 +1,8 @@ { "title" : "Venus (Fugerit Document Generation Framework)", "name": "Venus", - "version" : "1.1.1-rc.001", - "date" : "02/07/2023", + "version" : "1.1.2-rc.001", + "date" : "03/07/2023", "organization" : { "name" : "Fugerit Org", "url" : "https://www.fugerit.org" diff --git a/docgen/release-notes.txt b/docgen/release-notes.txt index c98086483..c296e124d 100644 --- a/docgen/release-notes.txt +++ b/docgen/release-notes.txt @@ -1,6 +1,9 @@ -1.1.2-rc.001 (2023-07-XX) +1.1.2-rc.001 (2023-07-03) ------------------ + Updated quarkus version to 3.1.3.Final ++ Added generation time on playgroud quarkus ++ Added lombok dependency ++ Added API for AOT type handlers initialization (especially useful for libraries like apache fop) 1.1.1-rc.001 (2023-07-02) ------------------ diff --git a/fj-doc-base-json/pom.xml b/fj-doc-base-json/pom.xml index c0a3544b9..a039bb173 100644 --- a/fj-doc-base-json/pom.xml +++ b/fj-doc-base-json/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-base-json diff --git a/fj-doc-base-yaml/pom.xml b/fj-doc-base-yaml/pom.xml index 2caa8766b..ff389eafb 100644 --- a/fj-doc-base-yaml/pom.xml +++ b/fj-doc-base-yaml/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-base-yaml diff --git a/fj-doc-base/pom.xml b/fj-doc-base/pom.xml index 8073ebd50..952c12591 100644 --- a/fj-doc-base/pom.xml +++ b/fj-doc-base/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-base diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/config/InitHandler.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/config/InitHandler.java new file mode 100644 index 000000000..58d663ba1 --- /dev/null +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/config/InitHandler.java @@ -0,0 +1,52 @@ +package org.fugerit.java.doc.base.config; + +import java.io.ByteArrayOutputStream; +import java.io.InputStreamReader; + +import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.core.lang.helpers.ClassHelper; +import org.fugerit.java.core.util.checkpoint.CheckpointUtils; + +import lombok.extern.slf4j.Slf4j; + +/** + * DocTypeHandler Initializer. + * If AOT initialization is needed it is possible to call these Facade. + * + */ +@Slf4j +public class InitHandler { + + public static final String PATH_INIT_DOC = "config/init_doc/doc-init.xml"; + + public static boolean initDoc( DocTypeHandler handler ) throws ConfigException { + boolean init = true; + long startTime = System.currentTimeMillis(); + try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( PATH_INIT_DOC ) ); + ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { + handler.handle( DocInput.newInput( handler.getType() , reader ) , DocOutput.newOutput( baos ) ); + log.info( "Init handler time {} -> {}", handler, CheckpointUtils.formatTimeDiffMillis( startTime , System.currentTimeMillis() ) ); + } catch (Exception e) { + throw new ConfigException( "Init exception : "+e, e ); + } + return init; + } + + public static void initDocAsync( DocTypeHandler handler ) { + Runnable runInitDoc = new Runnable() { + @Override + public void run() { + log.info( "Init handler start : {}", handler ); + try { + boolean initOk = initDoc(handler); + log.info( "Init handler end : {} -> {}", handler, initOk ); + } catch (ConfigException e) { + log.info( "Init handler error "+e, e ); + } + } + }; + Thread t = new Thread( runInitDoc ); + t.start(); + } + +} diff --git a/fj-doc-base/src/main/resources/config/init_doc/doc-init.xml b/fj-doc-base/src/main/resources/config/init_doc/doc-init.xml new file mode 100644 index 000000000..b180e6853 --- /dev/null +++ b/fj-doc-base/src/main/resources/config/init_doc/doc-init.xml @@ -0,0 +1,22 @@ + + + + + 10;10;10;10 + Test XML 01 title + Test XML 01 subject + Fugerit + fj-doc (Venus) Sample + en + + Bookmark 1 + Bookmark 2 + + + + Header 1 + + \ No newline at end of file diff --git a/fj-doc-bom-core/pom.xml b/fj-doc-bom-core/pom.xml index e410f5ab0..0bc4e0d86 100644 --- a/fj-doc-bom-core/pom.xml +++ b/fj-doc-bom-core/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-bom-core diff --git a/fj-doc-bom-fop/pom.xml b/fj-doc-bom-fop/pom.xml index 79e935c2b..3d8f80d86 100644 --- a/fj-doc-bom-fop/pom.xml +++ b/fj-doc-bom-fop/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-bom-fop diff --git a/fj-doc-freemarker/pom.xml b/fj-doc-freemarker/pom.xml index f540c3ab5..78d679fb5 100644 --- a/fj-doc-freemarker/pom.xml +++ b/fj-doc-freemarker/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-freemarker diff --git a/fj-doc-lib-autodoc/pom.xml b/fj-doc-lib-autodoc/pom.xml index 2139aa613..d71860bf3 100644 --- a/fj-doc-lib-autodoc/pom.xml +++ b/fj-doc-lib-autodoc/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-lib-autodoc diff --git a/fj-doc-lib-simpletable/pom.xml b/fj-doc-lib-simpletable/pom.xml index b2d1d4930..3a0a190e0 100644 --- a/fj-doc-lib-simpletable/pom.xml +++ b/fj-doc-lib-simpletable/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-lib-simpletable diff --git a/fj-doc-mod-fop/pom.xml b/fj-doc-mod-fop/pom.xml index 18be5e0dc..b3bcc4fa7 100644 --- a/fj-doc-mod-fop/pom.xml +++ b/fj-doc-mod-fop/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-mod-fop diff --git a/fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/InitFopHandler.java b/fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/InitFopHandler.java new file mode 100644 index 000000000..629045e62 --- /dev/null +++ b/fj-doc-mod-fop/src/main/java/org/fugerit/java/doc/mod/fop/InitFopHandler.java @@ -0,0 +1,23 @@ +package org.fugerit.java.doc.mod.fop; + +import org.fugerit.java.core.cfg.ConfigException; +import org.fugerit.java.doc.base.config.InitHandler; + +/** + * PdfFopTypeHandler Initializer based on a base configuration. + * If AOT initialization is needed it is possible to call these Facade. + * + */ +public class InitFopHandler { + + public static final PdfFopTypeHandler HANDLER = new PdfFopTypeHandler(); + + public static boolean initDoc() throws ConfigException { + return InitHandler.initDoc( HANDLER ); + } + + public static void initDocAsync() { + InitHandler.initDocAsync( HANDLER ); + } + +} diff --git a/fj-doc-mod-opencsv/pom.xml b/fj-doc-mod-opencsv/pom.xml index f1491a7cb..e97e57acc 100644 --- a/fj-doc-mod-opencsv/pom.xml +++ b/fj-doc-mod-opencsv/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-mod-opencsv diff --git a/fj-doc-mod-poi/pom.xml b/fj-doc-mod-poi/pom.xml index 264c683ef..21c6edc96 100644 --- a/fj-doc-mod-poi/pom.xml +++ b/fj-doc-mod-poi/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-mod-poi diff --git a/fj-doc-playground-quarkus/pom.xml b/fj-doc-playground-quarkus/pom.xml index f66d3f691..a69d19405 100644 --- a/fj-doc-playground-quarkus/pom.xml +++ b/fj-doc-playground-quarkus/pom.xml @@ -4,7 +4,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-playground-quarkus diff --git a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/config/InitPlayground.java b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/config/InitPlayground.java new file mode 100644 index 000000000..da335018b --- /dev/null +++ b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/config/InitPlayground.java @@ -0,0 +1,23 @@ +package org.fugerit.java.doc.playground.config; + +import org.fugerit.java.doc.base.config.InitHandler; +import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler; + +import io.quarkus.runtime.StartupEvent; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.event.Observes; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@ApplicationScoped +public class InitPlayground { + + public static final PdfFopTypeHandler PDF_FOP_TYPE_HANDLER = new PdfFopTypeHandler(); + + void onStart(@Observes StartupEvent ev) { + log.info( "InitPlayground start" ); + InitHandler.initDocAsync( PDF_FOP_TYPE_HANDLER ); + log.info( "InitPlayground end" ); + } + +} diff --git a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateOutput.java b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateOutput.java index 2f371e783..5095cf1b2 100644 --- a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateOutput.java +++ b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateOutput.java @@ -2,16 +2,17 @@ import org.fugerit.java.doc.playground.facade.BasicOutput; +import lombok.Getter; +import lombok.Setter; + public class GenerateOutput extends BasicOutput { + @Setter + @Getter + private String generationTime; + + @Setter + @Getter private String docOutputBase64; - - public String getDocOutputBase64() { - return docOutputBase64; - } - - public void setDocOutputBase64(String docOutputBase64) { - this.docOutputBase64 = docOutputBase64; - } } diff --git a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateRest.java b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateRest.java index aa499fc4b..8fda5b5a3 100644 --- a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateRest.java +++ b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateRest.java @@ -5,6 +5,7 @@ import java.util.Base64; import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.core.util.checkpoint.CheckpointUtils; import org.fugerit.java.doc.base.config.DocInput; import org.fugerit.java.doc.base.config.DocOutput; import org.fugerit.java.doc.base.config.DocTypeHandler; @@ -16,12 +17,10 @@ import org.fugerit.java.doc.lib.simpletable.SimpleTableFacade; import org.fugerit.java.doc.lib.simpletable.model.SimpleRow; import org.fugerit.java.doc.lib.simpletable.model.SimpleTable; -import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler; import org.fugerit.java.doc.mod.poi.XlsxPoiTypeHandler; +import org.fugerit.java.doc.playground.config.InitPlayground; import org.fugerit.java.doc.playground.facade.BasicInput; import org.fugerit.java.doc.playground.facade.InputFacade; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import jakarta.enterprise.context.ApplicationScoped; import jakarta.ws.rs.Consumes; @@ -30,13 +29,13 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; +import lombok.extern.slf4j.Slf4j; @ApplicationScoped +@Slf4j @Path("/generate") public class GenerateRest { - private final static Logger logger = LoggerFactory.getLogger(GenerateRest.class); - private byte[] generateHelper( GenerateInput input, DocTypeHandler handler) throws Exception { byte[] result = null; if ( input.getDocContent() != null ) { @@ -49,7 +48,7 @@ private byte[] generateHelper( GenerateInput input, DocTypeHandler handler) thro sourceType = DocFacadeSource.SOURCE_TYPE_YAML; } String type = input.getOutputFormat().toLowerCase(); - logger.info( "output format : {}", type ); + log.info( "output format : {}", type ); DocInput docInput = DocInput.newInput( type, reader , sourceType ); DocOutput docOutput = DocOutput.newOutput( baos ); handler.handle(docInput, docOutput); @@ -60,7 +59,7 @@ private byte[] generateHelper( GenerateInput input, DocTypeHandler handler) thro } private DocTypeHandler findHandler( BasicInput input ) { - DocTypeHandler handler = new PdfFopTypeHandler(); + DocTypeHandler handler = InitPlayground.PDF_FOP_TYPE_HANDLER; if ( "XLSX".equalsIgnoreCase( input.getOutputFormat() ) ) { handler = XlsxPoiTypeHandler.HANDLER; } else if ( "HTML".equalsIgnoreCase( input.getOutputFormat() ) ) { @@ -86,13 +85,15 @@ private DocParser findParser( BasicInput input ) { public Response document( GenerateInput input) { Response res = Response.status(Response.Status.BAD_REQUEST).build(); try { + long time = System.currentTimeMillis(); DocTypeHandler handler = this.findHandler(input); byte[] data = this.generateHelper(input, handler); GenerateOutput output = new GenerateOutput(); output.setDocOutputBase64( Base64.getEncoder().encodeToString( data ) ); + output.setGenerationTime( CheckpointUtils.formatTimeDiffMillis( time , System.currentTimeMillis() ) ); res = Response.ok().entity( output ).build(); } catch (Exception e) { - logger.info("Error : " + e, e); + log.info("Error : " + e, e); res = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return res; @@ -145,7 +146,7 @@ public Response validate( GenerateInput input) { res = Response.ok().entity( output ).build(); } } catch (Exception e) { - logger.info("Error : " + e, e); + log.info("Error : " + e, e); res = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return res; diff --git a/fj-doc-playground-quarkus/src/main/react/src/playground/DocXmlEditor.jsx b/fj-doc-playground-quarkus/src/main/react/src/playground/DocXmlEditor.jsx index 77e94a42d..14e268bb9 100644 --- a/fj-doc-playground-quarkus/src/main/react/src/playground/DocXmlEditor.jsx +++ b/fj-doc-playground-quarkus/src/main/react/src/playground/DocXmlEditor.jsx @@ -24,7 +24,8 @@ class DocXmlEditor extends Component { outputFormat: 'HTML', docContent: '', docOutput: null, - docFormat: null + docFormat: null, + generationTime: null } } @@ -45,7 +46,8 @@ class DocXmlEditor extends Component { if (response.success) { reactState.setState({ docOutput: response.result.docOutputBase64, - docFormat: this.state.outputFormat + docFormat: this.state.outputFormat, + generationTime: response.result.generationTime }) } }) @@ -123,6 +125,7 @@ class DocXmlEditor extends Component { let srcData = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,'+ this.state.docOutput; outputData = generated_document.xlsx } + outputData = {outputData}Generation time : {this.state.generationTime} } return diff --git a/fj-doc-sample/pom.xml b/fj-doc-sample/pom.xml index ca1b7921c..915c2ce88 100644 --- a/fj-doc-sample/pom.xml +++ b/fj-doc-sample/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-sample diff --git a/fj-doc-sample/src/test/resources/dev/test-xml-01.xml b/fj-doc-sample/src/test/resources/dev/test-xml-01.xml index 3332b0b77..52526656b 100644 --- a/fj-doc-sample/src/test/resources/dev/test-xml-01.xml +++ b/fj-doc-sample/src/test/resources/dev/test-xml-01.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://javacoredoc.fugerit.org http://www.fugerit.org/data/java/doc/xsd/doc-2-0.xsd" > 10;10;10;10 diff --git a/fj-doc-sample/src/test/resources/dev/test-xml-02.xml b/fj-doc-sample/src/test/resources/dev/test-xml-02.xml index 51da373b7..13cf685de 100644 --- a/fj-doc-sample/src/test/resources/dev/test-xml-02.xml +++ b/fj-doc-sample/src/test/resources/dev/test-xml-02.xml @@ -3,7 +3,7 @@ + xsi:schemaLocation="http://javacoredoc.fugerit.org http://www.fugerit.org/data/java/doc/xsd/doc-2-0.xsd" > diff --git a/fj-doc-val-core/pom.xml b/fj-doc-val-core/pom.xml index a6977460f..5470bec30 100644 --- a/fj-doc-val-core/pom.xml +++ b/fj-doc-val-core/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-val-core diff --git a/fj-doc-val-pdfbox/pom.xml b/fj-doc-val-pdfbox/pom.xml index 4d0b26060..b1b077d66 100644 --- a/fj-doc-val-pdfbox/pom.xml +++ b/fj-doc-val-pdfbox/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-val-pdfbox diff --git a/fj-doc-val-poi/pom.xml b/fj-doc-val-poi/pom.xml index 97e835e7b..b7aa922df 100644 --- a/fj-doc-val-poi/pom.xml +++ b/fj-doc-val-poi/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-val-poi diff --git a/fj-doc-val/pom.xml b/fj-doc-val/pom.xml index 85e7f3747..27e452e61 100644 --- a/fj-doc-val/pom.xml +++ b/fj-doc-val/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 fj-doc-val diff --git a/pom.xml b/pom.xml index 480c01a5a..18e418a9c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ fj-doc - 1.1.1-rc.001 + 1.1.2-rc.001 pom fj-doc @@ -269,6 +269,12 @@ compile + + org.projectlombok + lombok + provided + + org.apache.logging.log4j log4j-api
Generation time : {this.state.generationTime}