Skip to content

Commit

Permalink
[fj-doc-base-kotlin] fj-script-helper version set to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Oct 23, 2024
1 parent fbe7fd2 commit 4a5407c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- [fj-doc-base-kotlin] fj-script-helper version set to 2.0.0

## [8.10.0] - 2024-10-23

### Added
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</licenses>

<properties>
<fj-script-helper-version>1.0.0</fj-script-helper-version>
<fj-script-helper-version>2.0.0</fj-script-helper-version>
<kotlin.version>2.0.21</kotlin.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ public DocKotlinParser() {
this.docXmlParser = new DocXmlParser();
}

private static EvalScript evalScript = new EvalScriptWithJsonDataModel( "kts" );
/*
* This will create an eval script utility.
* The data model will be transformed to a json model with default name 'data'.
*/
private static EvalScript evalScript = EvalScriptWithJsonDataModel.newEvalScriptWithJsonDataModel( "kts" );

@Override
public String evalWithDataModel(Reader reader, Map<String, Object> dataModel) {
return dslDocToXml(reader, dataModel);
}

public static String dslDocToXml(Reader reader, Map<String, Object> dataModel ) {
Object res = evalScript.evalKts( reader, dataModel );
Object res = evalScript.handle( reader, dataModel );
String xml = res.toString();
log.debug( "evalWithDataModel xml content : \n{}", xml );
return xml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import freemarker.template.Version;
import jakarta.enterprise.context.ApplicationScoped;
import lombok.extern.slf4j.Slf4j;
import org.fugerit.java.script.helper.EvalScript;
import org.fugerit.java.script.helper.EvalScriptWithDataModel;

import javax.script.Bindings;
import javax.script.ScriptContext;
Expand All @@ -50,6 +52,8 @@ public class GenerateFacade {

private static final ObjectMapper MAPPER = new ObjectMapper();

private static final EvalScript EVAL_SCRIPT = new EvalScriptWithDataModel( "kts" ); // no need for data model json transformation

private void doHandle( DocTypeHandler handler, String type, int sourceType, Reader reader, ByteArrayOutputStream baos ) {
SafeFunction.apply( () -> {
SimpleCheckpoint checkpoint = new SimpleCheckpoint();
Expand Down Expand Up @@ -127,7 +131,7 @@ private void handleKts( DocTypeHandler handler, String type, Reader reader, Byte
try ( StringReader jsonReader = new StringReader(ktsJsonData) ) {
LinkedHashMap<String, Object> data = MAPPER.readValue( jsonReader, LinkedHashMap.class );
log.info( "kts read json data : {}", checkpoint.getFormatTimeDiffMillis() );
String xml = DocKotlinParser.dslDocToXml( reader, data );
String xml = EVAL_SCRIPT.handle( reader, data ).toString();
log.info( "kts eval with DocKotlinParser : {}", checkpoint.getFormatTimeDiffMillis() );
try ( StringReader xmlReader = new StringReader( xml) ) {
this.doHandle(handler, type, DocFacadeSource.SOURCE_TYPE_XML, xmlReader, baos);
Expand Down

0 comments on commit 4a5407c

Please sign in to comment.