Book a Demo

Author Topic: Accessing properties from the Code Template Editor  (Read 4960 times)

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Accessing properties from the Code Template Editor
« on: October 03, 2011, 05:59:50 pm »
Hi,

I want to read the property "Direction" of an assoziation between two classes from the Code Template Editor - there is no field substitution macro available to access it directly, so I tried %connectorTag:"Direction"%, %connectorSourceTag:"Direction"%, ... without success.

Any idea how to do this? (EA9.1.910)

Cheers,
mrks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #1 on: October 04, 2011, 08:44:24 am »
At a guess, you're not in the connector template.

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #2 on: October 05, 2011, 05:07:45 am »
... I cannot find any connector templates in the code template editor - do you mean the templates in the transformation editor? I want to access the properties from the Linked Attribute Template.

I have tried adding a custom template of type Connector, but I still cannot access the properties I need.

Is there a difference between the available field substitution macros and the template I use? - Aren't these always the same?

Any help is welcome  8-)
« Last Edit: October 05, 2011, 05:20:58 am by mrks »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #3 on: October 05, 2011, 09:09:25 am »
The connector templates aren't used by default in the code generation tempates, but you can still add one in and use it. You will of course have to add a list over the connectors before it will be used.

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #4 on: October 07, 2011, 06:34:14 am »
Simon, I do not understand how to add a list over the connectors. I added a custom template of type connector, named "Assoziation" and placed it at the position where I want to use the connector property 'Direction'.

Code: [Select]
...
%if linkCard != ""%
$direction=%list="Connector__Assoziation" @separator="\n"%
@system.annotation.LinkDirection (
            direction="$direction"
)
%endIf%
...

the code above results in:

Code: [Select]
...
@system.annotation.LinkDirection (
            direction="connectorDirection=Source -> Destination
connectorDirection=Source -> Destination
connectorDirection=Bi-Directional
connectorDirection=Source -> Destination
connectorDirection=Source -> Destination
connectorDirection=Source -> Destination"
)
public java.util.Set<SessionStatus> sessionStatus;
...

where the "Connector__Assoziation" template is:

Code: [Select]
connectorDirection=%connectorDirection%

and the following is what I need:
Code: [Select]
...
@system.annotation.LinkDirection (
            direction="connectorDirection=Source -> Destination"
)
public java.util.Set<SessionStatus> sessionStatus;
...

What am I doing wrong?  :o
« Last Edit: October 07, 2011, 06:43:29 am by mrks »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #5 on: October 07, 2011, 08:16:32 am »
a) You're listing over all connectors from the class.
Code: [Select]
%list="Connector__Assoziation" @indent="\t" @separator="\n" connectorGUID=linkGUID%
I also added an indent to match your expected indent.

b)Your connector template isn't coded to give what you want.
Code: [Select]
direction=%qt%connectorDirection=%connectorDirection%%qt%
Note, I have not executed this or touched the templates for some time so the specifics might need to be corrected.

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Accessing properties from the Code Template Ed
« Reply #6 on: October 08, 2011, 03:06:45 am »
Hi Simon, thanks a lot, that's it!  :)

I corrected the syntax to:

Code: [Select]
"%list="Connector__Assoziation" connectorGUID==linkGUID%"

... I do not even need the separator, there can always only be one link direction for each linked attribute.

cheers!  ;)