Book a Demo

Author Topic: Read association properties source / target  (Read 4015 times)

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Read association properties source / target
« on: October 15, 2011, 07:23:09 pm »
Hi, I try to access the properties Source and Target that are visible in the accociation properties dialog from the code template editor. I was able to create a list and add it to a custom connector template.

The properties 'Name, Alias, ...' are available with the related macros, like e.g. %connectorDirection% - How can I access Source and Target?

the following all do not work:

Code: [Select]
%linkSource%
%linkTarget%
%connectorTag:"Source"%
%connectorTag:"Target"%
%attTag:"Source"%
%attTag:"Target"%
%linkTag:"Source"%
%linkTag:"Target"%
%connectorSourceTag:"Source"%
%connectorSourceTag:"Target"%
any suggestion?
« Last Edit: October 15, 2011, 07:26:44 pm by mrks »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Read association properties source / target
« Reply #1 on: October 17, 2011, 08:12:14 am »
The macros beginning with connector are only available from the Connector template, which isn't used by default in code generation.

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Read association properties source / target
« Reply #2 on: October 19, 2011, 05:15:23 am »
Hi Simon, I already added a connector, and I can read the values of e.g. %connectorDirection% - I just wonder how to get the values of the properties "Source" and "Target" - cheers!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Read association properties source / target
« Reply #3 on: October 19, 2011, 08:26:59 am »
If you can get the direction then you should be able to use any of the connector macros.

Go to http://www.sparxsystems.com/enterprise_architect_user_guide/9.0/standard_uml_models/fieldsubstitutionmacros.html and scroll down to the connector macros.

(Note: The current version of the help included with EA shows the connector macros on their own page. You can go directly to that page by creating a hyperlink on your diagram to help page connector_field_substitution_m.htm)

mrks

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Read association properties source / target
« Reply #4 on: October 21, 2011, 03:53:26 am »
Hi, I figured it out, the following does what I expect
Code: [Select]
@system.annotation.LinkProperties (
      direction="%connectorDirection%",
      %if className == connectorSourceElemName%position="Source",%endIf%%if className == connectorDestElemName%position="Destination",%endIf%      
      sourceMultiplicity="%connectorSourceMultiplicity%",
      destinationMultiplicity="%connectorDestMultiplicity%"
)

... e.g. result

Code: [Select]
     @system.annotation.LinkProperties (
            direction="Bi-Directional",
            position="Destination",
            sourceMultiplicity="1",
            destinationMultiplicity="0..1"
      )

I'm fine with that but there might be a easier way to do this - Cheers!