dimanche 11 août 2019

What's new in Telosys-CLI version 3.1.0




All the 'Telosys-Core 3.1.0' features are embedded in Telosys-CLI 3.1.0
See 'Telosys-Core 3.1.0' features :
https://telosys.blogspot.com/2019/08/whats-new-in-telosys-core-version-310.html

The new features specific to Telosys-CLI are described below ...

A basic text editor is now embedded in Telosys-CLI

Telosys-CLI has its own text editor. This text editor is used by default.


As before, it is always possible to define the editor of your choice in the tool configuration.

Some new commands have been added

  • 'cgh' : 'Check GitHub'
    to check if GitHub is accessible and get the API limits
  • 'ghu' : 'GitHub User'
    to define the GitHub user (in order to increase the API rate limit to 5000 requests per hour )
  • 'et' : 'Edit Template'
    to edit a template file ( ".vm" file )
  • 'ver' : 'Versions'
    to print all the components versions used by the CLI

Running a set of commands defined in a text file

It's now possible to run Telosys-CLI with an 'input file' containing a set of commands.
For this the '-i' option (for 'input file') has been added

Examples :
  • tt -i myfile.txt 
  • tt -i foo.telosys
  • tt -h myhomedir  -i mycommands.telosys

All commands with confirmation have a "-y" option

In order to be usable in a commands file all the commands with confirmation message have now a '-y' option.
'-y' option means 'answer yes' to the question.



Comments

All input started with '//' is considered as a comment.
This new feature allows to add comments in commands files.


Commands file example :

cd /tmp/tmp10
// Set this folder as Telosys HOME
h .

// Choose the current model
m cars
// Print the current model
m

// Choose the current bundle
b mvc-bottle
// Print the current bundle
b

// Print environment
env

// Launch code generation
gen * * -r -y


 




What's new in Telosys Core version 3.1.0

All the improvements described below are implemented in Telosys-Core

All these features will be used in the upcoming version 3.1.0 of Telosys-CLI and Telosys-Eclipse-Plugin

 

Code generation for 'Go language' 

Go language is now supported as an 'explicit target language' by Telosys.

To define 'Go' as the target language in a template file use this directive :
  #set ( $env.language = 'Go' )

For more information about 'Go' specificities see the documentation
http://www.telosys.org/doc/telosys-core-v310/languages/language-go.html

 

Code generation for 'PHP language'

PHP language is now supported as an 'explicit target language' by Telosys.

To define 'PHP' as the target language in a template file use this directive :
  #set ( $env.language = 'PHP' )

For more information about 'PHP' specificities see the documentation
http://www.telosys.org/doc/telosys-core-v310/languages/language-php.html


Table comment is now available in $entity object


You can use it in a template (.vm file) with  $entity.databaseComment
The comment comes from the database, hence it is only available for a DB model
otherwise it returns a void string.


GitHub user authentication allows to extend the API rate limit

For unauthenticated requests, the GitHub API allows only 60 requests per hour (for a given IP address). That is very limited especially if the IP address is shared by many users (with a proxy for example).
For more information see : https://developer.github.com/v3/rate_limit/
This can cause errors when installing bundles.

Telosys 3.1.0 now supports GitHub authentication ( user + password )
When you're authenticated you can send up to 5000 requests per hour .

vendredi 5 juillet 2019

Create a database model from SQLite DB

If you want to create a DBModel from an existing SQLite database here is how to proceed...

1) Download the ".jar" file containing the SQLite JDBC driver
from https://bitbucket.org/xerial/sqlite-jdbc/downloads/


2) Put the ".jar" file in "TelosysTools/lib"


3) Configure the JDBC connection in the "databases.dbcfg" file
  • With Telosys-CLI use the "edb" command or edit the file with any text editor
  • With Telosys Eclipse Plugin open it with the specialized editor
 Here's a configuration example :

 <db id = "1"
    name     = "SQLiteDB"
    driver   = "org.sqlite.JDBC"
    url      = "jdbc:sqlite:D:/mypath/database.sqlite"
    typeName = "SQLLITE"
    dialect  = "org.hibernate.dialect.SQLiteDialect"
    isolationLevel = ""
    poolSize       = "10" >
       <property name="user"      value="" />
       <property name="password"  value="" />
       <metadata catalog="" schema=""
            table-name-pattern="%" table-types="TABLE  VIEW  "
            table-name-exclude=""  table-name-include=""  />
  </db>


In "url" parameter replace "D:/mypath/database.sqlite" by your database file path

4) Test the connection
With Telosys-CLI you can use the following "Check DataBase" commands :
  > cdb     ( check the connection )
  > cdb -i  ( check the connection and get database information )
  > cdb -t  ( check the connection and get database tables )
  > cdb -c  ( check the connection and get database colomns )
 ( enter "? cdb" for all options )
With Telosys Eclipse Plugin use the GUI (tabs "Information", "Meta-data", buttons "Get tables", "Get columns", etc)

5) If the connection is OK you can create the database model
With Telosys-CLI  run the "New Db Model" command
  > ndbm
With Telosys Eclipse Plugin use the GUI

Info : with SQLite DB only the tables and columns are retrieved (the model created doesn't contain Primary Keys and Foreign Keys)

lundi 15 avril 2019

How to use Telosys code generation without entities


In some cases you may need to use templates to generate only a few files unrelated to the notion of model and entities.

This can be useful for generating configuration files or isolated files for which the variables defined in the project are sufficient.

In its current version Telosys can launch a generation only if there is a "model". But there is a simple way to use code generation without entities : just create a void model.

To do that create a "DSL model" (you can name it "void-model" for example )
Once the "void model" is created select this model as the current model (in Eclipse just open it).



Then select a bundle containing your templates and execute them...



NB: all the templates present in the bundle must respect the following rules:
  • in the "templates.cfg" file they must have a  cardinality of "1" so that each template is executed just once regardless of the number of entities
  • in the ".vm" file they must not refer to entity ( ${entity}, ${attribute}, etc )

Example of template definition in "templates.cfg" :



So you can generate files from templates that only use project variables and no entity.

vendredi 12 avril 2019

How to manipulate strings in a Telosys template


All Java objects methods can be used in a template (".vm" file),
hence it’s possible to use all the methods defined in the Java class “String”.



For all information about 'String' methods see the Java doc :
 https://docs.oracle.com/javase/7/docs/api/java/lang/String.html



Examples :


length is $STR.length()

#set($STR = $STR.replaceFirst("def", "xy" )

#if ( $STR.endsWith("ef") )
YES, it ends with "ef"
#else
NO
#end

charAt(2) : $STR.charAt(2)

#if ( $STR.equalsIgnoreCase($STR2) )
YES
#else
NO
#end


$STR.toUpperCase()
$STR.toLowerCase()


lundi 27 août 2018

How to generate files outside the current location


With the default configuration the telosys tooling is located in the project folder where the files are generated.



It's possible to change the configuration in order to specify a specific destination for the generated files.

With this configuration, it is possible to generate files anywhere.
You just have to indicate the destination directory.

If you are using Telosys-CLI


  Use the command "ecfg" (Edit Configuration) to edit the "telosys-tools.cfg" file.

  Define the "SpecificDestinationFolder" property
  Examples :
  SpecificDestinationFolder=C\:\\dir1\\dir2
  SpecificDestinationFolder=/dir1/dir2


If you are using Telosys Eclipse Plugin 

  In the project workspace open the "Telosys Tools properties editor"
  from the menu : "File" - "Properties" - "Telosys Tools"
  or with a Right-Click on the project "Properties" - "Telosys Tools"

  Select the "Advanced" tab and set the specific location for code generation


Hence it's possible to create a "General project" just for Telosys tooling and use it to generate outside the workspace.