Book a Demo

Author Topic: attaching property to aggregated member  (Read 3307 times)

larmue

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
attaching property to aggregated member
« on: June 13, 2006, 01:26:39 am »
Hi,

having explicitely modelled the aggregation or composition between two classes I now need a property that returns the aggregated object. I can define a method with stereotype <<property>> but where and how can I define the instance it should return?

Thanks for any help,
Lars Müller

thomaskilian

  • Guest
Re: attaching property to aggregated member
« Reply #1 on: June 13, 2006, 01:49:15 am »
I guess you should use a named role. Select the connector and there the target tab.

larmue

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: attaching property to aggregated member
« Reply #2 on: June 13, 2006, 01:58:32 am »
the role is named of course. I create a method with property stereotype but the connection between the two, how can I define it ? The generated sourcecode is : get{ return <unknown>; }

Thanks, Lars Müller
« Last Edit: June 13, 2006, 01:59:15 am by larmue »

thomaskilian

  • Guest
Re: attaching property to aggregated member
« Reply #3 on: June 13, 2006, 04:12:18 am »
You should use the property checkbox in the according attribute. You will be asked what to do with it. Note that you have to create an attribute (it will not be created by just entering a role name, but you can use a drop down in the role names from existing attributes).

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: attaching property to aggregated member
« Reply #4 on: June 13, 2006, 04:21:55 am »
Lars,

This is tricky. I think you want to define the collection class to use for associations. EA lets you do this in two places: in the generation options, and from the Detail page of the Class Properties dialog.

The former option is available from the specific languages under the Tools / Options / Source Code Engineering dialog. This is language-dependant, and not available for all languages (depending on each language's support for collections). IMHO this is best used as a default; even so, be careful with this since a default can produce incorrect but working code if you forget to assign the correct collection class for a given instance - you won't get an error message...

The latter option is fairly easy to use, but be aware that this page is not documented in the help available from the Class Properties dialog (as of Build 791). Search help for class detail and you'll find help for both options. Here you will find some additional information - mostly a reminder if you've gotten this far already - about setting multiplicity on the attribute and association.

David

[The following might have something to do with this, but I really don't know. Take it with a grain of salt, and please don't break a working model just to see what happens... Depending on where and how you use the property, you may want to define it as a collection of some kind. This can be done from the Details tab of the Attribute Properties dialog. There is a dropdown for this, but I seem to have limited success in populating it.]
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: attaching property to aggregated member
« Reply #5 on: June 13, 2006, 03:09:06 pm »
Quote
the role is named of course. I create a method with property stereotype but the connection between the two, how can I define it ? The generated sourcecode is : get{ return <unknown>; }

You can generate the correct code by adding a tagged value "attribute_name" with the value of the role the property is for.