Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: zalbina on September 06, 2012, 05:37:05 am
-
Hello,
I have got planty of entities and any design which is added to it. I need to generate annotations for Java. Where should I start?
Thanks.
-
Open Help, search for "code generation template"
Geert
-
Sure, but I did not move much further. I did not successed to write my own template and check if it works. I don't understand even how to check it. :'(
-
Well, I've worked on it and wrote some code, but it does not work like I wanted to see it.
$annot = "@Column("
%attTag:"name" ? $annot+="name="%
$annot+=%attTag:"name"%
$annot+=")"
$annot
The output of t is:
%attTag:"name" ?%
@Column(name=KOD_ISO2)
what is wrong: I need only the @Column(name=KOD_ISO2)
and KOD_ISO2 must be quoted like "KOD_ISO2".
Some ideas?
Help :'(
-
%attTag:"name" ? $annot+="name="%
Isn't valid syntax, so it outputs the text.
This will get you a little closer (but is untested)
$annot = "@Column("
%if attTag:"name" != ""%
$annot+="name="%+%qt%+%attTag:"name"%+%qt%
%endIf%
$annot+=")"
$annot
-
We got it. The write syntax is:
$annot = "@Column("
%if attTag:"name" != ""%
$annot+="name="
$annot+=%qt%+%attTag:"name"%+%qt%
%else%
%endIf%
Thanks a lot. It does work.
-
How to call a custom template from other template?
Thanks.