Telosys generator classes called by the Telosys API
- The generator itslef
- The "context" objects
- Generation task
- Documentation builder
Telosys generator based on Velocity template engine
Home Page: https://www.telosys.org/
License: GNU Lesser General Public License v3.0
A BigDecimal created from 1AA23.456
value with lead to an exception with a null message in Java 8 but with a non null message in Java 11 (Character A is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
).
As the documentation mention "Java 8 (or +)" I was expecting to be able to build using Java 11.
Maybe the fix is to update the documentation.
Hello,
I am trying to write templates in VTL to generate java classes with telosys. My starting point is a directory (src/main/resources/templates/es) that contains json files (mapping1.json, mapping2.json). I have to generate several java classes per json files. I have already write a template for each java classe that i have to generate. But these templates work with a static embedded json object. This an example:
`
#set($json = {
"template":"acces_formation",
"mappings":{
"data":{
"properties":{
"MATRICULE":{
"type":"string",
"index":"not_analyzed"
},
"NOM":{
"type":"string",
"index":"not_analyzed"
},
"DATE_NAIS":{
"type":"date",
"format":"dd/MM/yyyy"
},
"SEXE":{
"type":"string",
"index":"not_analyzed"
},
"GRADE":{
"type":"string",
"index":"not_analyzed"
}
}
}
}
})
#macro(javaName $s)$s.substring(0,1).toUpperCase()$s.substring(1)#end
#macro(setter $s)set#javaName($s)#end
#macro(getter $s)get#javaName($s)#end
########################################start macro toCamelCase
#macro(toCamelCase $s)
#set($datas = $s.split("_"))
#set($name = "")
#foreach($data in $datas)
#set($data = $data.substring(0,1).toUpperCase()+$data.substring(1))
#set($name = $name+$data)
#end
$name##
#end
#######################################End macro toCamelCase
#######################################Start macro #tab
#macro(tab $nbreTotal)
#if($nbreTotal >= 1)
#foreach($nbre in [1..$nbreTotal])
##
#end
#end
#end
#######################################End macro #tab
#######################################Start macro javaType
#macro(javaType $f, $nbreTab)
#if($f.equals("string"))
#tab($nbreTab)String##
#elseif($f.equals("boolean"))
#tab($nbreTab)Boolean##
#elseif($f.equals("long"))
#tab($nbreTab)Long##
#elseif($f.equals("float"))
#tab($nbreTab)Float##
#elseif($f.equals("double"))
#tab($nbreTab)Double##
#elseif($f.equals("int"))
#tab($nbreTab)Integer##
#elseif($f.equals("integer"))
#tab($nbreTab)Integer##
#elseif($f.equals("date"))
#tab($nbreTab)String##
#elseif($f.equals("array"))
#tab($nbreTab)java.util.List<#javaType($f)>##
#else
#tab($nbreTab)$f##
#end
#end
#############################################End macro javaType
#############################################
#set($templateName = $json.template)
#set($entity = "#toCamelCase($json.template)")
#set($entityDto = $entity+"Dto")
#set($param = "_param")
/*
package ${target.javaPackageFromFolder(${SRC})};
import java.util.Date;
import ${ROOT_PKG}.helper.contract.SearchParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(alphabetic = true)
@getter
@Setter
@NoArgsConstructor
@tostring
public class $entityDto implements Cloneable {
#set($properties = $json.mappings.data.properties)
private String#tab(3)_id;
#foreach($key in $properties.keySet())
#set($field = $key.toLowerCase())
#tab(1)private #javaType($properties.get($key).type,0)#tab(3)$field ;
#end
private SearchParam<String>#tab(3)_id$param;
#foreach($key in $properties.keySet())
#set($field = $key.toLowerCase())
#tab(1)private SearchParam<#javaType($properties.get(
#end
private String orderDirection;
private String orderField;
}
`
What i need now is to browse my json directory, get each json file and apply the template on that json to create a java classe.
Thank you for helping me please !
I tried to generate code with Telosys CLI
here's my settings
oracle.properties
content
conv.tableName = ANACONDA_CASE
conv.columnName = snake_case
conv.pkName = PascalCase
conv.fkName = camelCase
type.long= NUMBER
And in my template files(.vm)
#set ( $env.databaseConvFile = $fn.file('TelosysTools/oracle.properties') )
but..... It's not wokring
I follow Telosys Documentation
plz give me more example or solution
Hi,
It would be interesting to have access to a unique feature from the model in the same way we have currently access to .isNotBlank() , .isNotEmpty(), .isNotNull().
A more generic approach would be to add a features array to the model allowing people to add any type of informations they require.
Hi,
I encountred some issues when i generated file.
e.g : I generate file with $today.date, my local is "FR", so the month is "Déc". However the month was encoding like : "Created on 22 d�c. 2016 ( Time 11:12:59 )", and maven won't compile this (force utf 8 compilation).
Thanks you.
Hi,I'm chuck.I'm a coder in china.I use your team project TelosysTool generate Code,but some chinese words happen encoding problem.My project encoding is 'UTF-8',I want know how let it right?
I read a little source code,in the 'Generator.java'
OutputStream out = new FileOutputStream(file);
if change it
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file),"UTF-8");
can make it right?
help me,please.
Allow generation without current entity (just generate a specific file without entity dependency )
$generator.generate($fileName, $folder, "template.vm" )
Ability to pass an object map to transmit certain variables from the original template
$generator.generate($entityName, $fileName, $folder, "template.vm", map )
$generator.generate($fileName, $folder, "template.vm", map )
I use multi-module with spring. This is error when i double-click on file DSL model(.model) or .dbcfg
java.lang.RuntimeException: Model folder '/Users/frederic/Documents/workspace-sts-3.8.3.RELEASE/oci-bpm-telosys-module/TelosysTools/demo_model' not found
at org.telosys.tools.dsl.DslModelUtil.getEntitiesAbsoluteFileNames(DslModelUtil.java:122)
Tag identified by a special character like "#"
for example ‘#mytag’ or ‘#mytag2(123)’
usable in templates with something like
'$attribute.hasTag ("mytag")'
and
'$attribute.tagValue ("mytag2")'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.