Home > Mobile >  Using Telosys DSL model to generate code for asp.net core razor pages (solution with multiple projec
Using Telosys DSL model to generate code for asp.net core razor pages (solution with multiple projec

Time:10-14

I know there is an example of Solution structure

The content of the solution file is like this (pointing to individual project files which are in separate folders)

Solution file

** Q3: How to have a metadata annotation to exclude an attribute in a list form or exclude it from editing**

CodePudding user response:

Q3 answer :

When you need a specific information for an attribute the simplest solution is to use a "tag".

You create any tag as you want (it's just a string starting with "#").

For example use "#exclude" tag for an attribute in the model :

 comment : string { #exclude } ;

and use it in the template file :

#if ( ! $attribute.hasTag("exclude") )
use attribute here
#end

See : https://doc.telosys.org/dsl-model/tags

CodePudding user response:

Q1 answer :

Regarding the "standard variables" they are not specific for Java (only the example is for Java). You can use them as you want for any kind of target language. These variables are usually used in the "templates.cfg" file to define the folders where generated files will be located (their use is not mandatory).

By convention :

  • SRC : folder where to generate "sources" files
  • RES : folder where to generate "resources" files (configuration files, etc)
  • WEB : folder for any web files (HTML, CSS, etc )
  • TEST_SRC : folder for unit tests sources
  • TEST_RES : folder for unit tests resources (config files, etc)
  • DOC : for documentation files
  • TMP : for temporary files (generation tests, etc)

You can organize your project structure as you want

Example in a "templates.cfg" for C# ( only $SRC is used ) :

#--- Models
Entity class                ; ${BEANNAME}.cs                    ; ${SRC}/Models/${BEANNAME}     ; Models/Xxx_cs.vm                  ; *
Entity CreateViewModel      ; Create${BEANNAME}ViewModel.cs     ; ${SRC}/Models/${BEANNAME}     ; Models/CreateXxxViewModel_cs.vm   ; *
Entity UpdateViewModel      ; Update${BEANNAME}ViewModel.cs     ; ${SRC}/Models/${BEANNAME}     ; Models/UpdateXxxViewModel_cs.vm   ; *

#-- Controllers
Entity controller           ; ${BEANNAME}sController.cs         ; ${SRC}/Controllers            ; Controllers/Xxxcontroller_cs.vm       ; *

#-- Views
Index View                  ; Index.cshtml                      ; ${SRC}/Views/Home             ; Views/Home/Index_cshtml.vm            ; 1
List View                   ; List${BEANNAME}View.cshtml        ; ${SRC}/Views/${BEANNAME}s     ; Views/ListXxxView_cshtml.vm       ; *
Create View                 ; Create${BEANNAME}View.cshtml      ; ${SRC}/Views/${BEANNAME}s     ; Views/CreateXxxView_cshtml.vm     ; *
Update View                 ; Update${BEANNAME}View.cshtml      ; ${SRC}/Views/${BEANNAME}s     ; Views/UpdateXxxView_cshtml.vm     ; *
Application Layout          ; _Layout.cshtml                    ; ${SRC}/Views/Shared           ; Views/Shared/_Layout_cshtml.vm        ; 1

Q2 answer :

The simplest way is probably to have one Telosys project for each target project (to keep each project as small as possible).

But you can also create your own "global variables" and use them in a "big project" with a complex structure.

Example of specific variables definition (in "telosys-tools.cfg") :

ProjectVariable.MODULE_APPLICATION    = my-app
ProjectVariable.MODULE_DOMAIN         = my-domaine
ProjectVariable.MODULE_INFRASTRUCTURE = my-infrastructure

Example of usage in a "templates.cfg" file :

${MODULE_INFRASTRUCTURE}/${RES}/db
${MODULE_DOMAIN}/${SRC}/repository
${MODULE_APPLICATION}/${SRC}/handler 
  • Related