Author Topic: Generate annotations for Java  (Read 3330 times)

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Generate annotations for Java
« 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Generate annotations for Java
« Reply #1 on: September 06, 2012, 04:59:48 pm »
Open Help, search for "code generation template"

Geert

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: Generate annotations for Java
« Reply #2 on: September 06, 2012, 05:31:44 pm »
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.  :'(


zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: Generate annotations for Java
« Reply #3 on: September 09, 2012, 11:45:52 pm »
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 :'(


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Generate annotations for Java
« Reply #4 on: September 10, 2012, 10:23:16 am »
%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

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: Generate annotations for Java
« Reply #5 on: September 10, 2012, 04:12:32 pm »
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.

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: Generate annotations for Java
« Reply #6 on: September 10, 2012, 04:44:59 pm »
How to call a custom template from other template?

Thanks.