Skip to content

Commit

Permalink
1.1.2-rc.001 (2023-07-03)
Browse files Browse the repository at this point in the history
+ 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)
  • Loading branch information
fugerit79 committed Jul 3, 2023
1 parent e950892 commit 0c7049f
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 42 deletions.
4 changes: 2 additions & 2 deletions docgen/parameters.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 4 additions & 1 deletion docgen/release-notes.txt
Original file line number Diff line number Diff line change
@@ -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)
------------------
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-base-json</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base-yaml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-base-yaml</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-base</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}
22 changes: 22 additions & 0 deletions fj-doc-base/src/main/resources/config/init_doc/doc-init.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<doc
xmlns="http://javacoredoc.fugerit.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://javacoredoc.fugerit.org http://www.fugerit.org/data/java/doc/xsd/doc-2-0.xsd" >

<metadata>
<info name="margins">10;10;10;10</info>
<info name="doc-title">Test XML 01 title</info>
<info name="doc-subject">Test XML 01 subject</info>
<info name="doc-author">Fugerit</info>
<info name="doc-creator">fj-doc (Venus) Sample</info>
<info name="doc-language">en</info>
<bookmark-tree>
<bookmark ref="b1">Bookmark 1</bookmark>
<bookmark ref="b2">Bookmark 2</bookmark>
</bookmark-tree>
</metadata>
<body>
<h head-level="1" align="center" id="b1">Header 1</h>
</body>
</doc>
2 changes: 1 addition & 1 deletion fj-doc-bom-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-bom-core</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-bom-fop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-bom-fop</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-freemarker</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-lib-autodoc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-lib-autodoc</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-lib-simpletable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-lib-simpletable</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-mod-fop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-mod-fop</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 );
}

}
2 changes: 1 addition & 1 deletion fj-doc-mod-opencsv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-mod-opencsv</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-mod-poi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-mod-poi</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-playground-quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>
<artifactId>fj-doc-playground-quarkus</artifactId>
<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -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" );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 ) {
Expand All @@ -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);
Expand All @@ -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() ) ) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class DocXmlEditor extends Component {
outputFormat: 'HTML',
docContent: '',
docOutput: null,
docFormat: null
docFormat: null,
generationTime: null
}
}

Expand All @@ -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
})
}
})
Expand Down Expand Up @@ -123,6 +125,7 @@ class DocXmlEditor extends Component {
let srcData = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,'+ this.state.docOutput;
outputData = <a href={srcData} download='generated_document.xlsx'>generated_document.xlsx</a>
}
outputData = <Fragment>{outputData}<p>Generation time : {this.state.generationTime}</p></Fragment>
}

return <Fragment>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>1.1.1-rc.001</version>
<version>1.1.2-rc.001</version>
</parent>

<name>fj-doc-sample</name>
Expand Down
Loading

0 comments on commit 0c7049f

Please sign in to comment.