Book a Demo

Author Topic: Using Collections as Attributes  (Read 4818 times)

Margaret

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Using Collections as Attributes
« on: June 16, 2009, 06:21:29 am »
Hello,

I am new to EA and have a basic question about how to define an attribute that is a collection.  For example a "meeting" class contains a collection of employees that attended the meeting, among other attributes.

How can I get EA to generate this kind of code?

Thanks!!!

Margaret

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Using Collections as Attributes
« Reply #1 on: June 16, 2009, 08:55:48 pm »
Check the Advanced properties dialog for your attribute. Note that you may have to save the attribute before the Advanced button becomes enabled.
No, you can't have it!

Margaret

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Using Collections as Attributes
« Reply #2 on: June 17, 2009, 12:51:50 am »
I can not find and Advanced Properties dialog for attribibutes.  The only place I see an Advanced button is on the properties page of the "employee" class - the class that I want the attribute to be a collection of.  I experimented with this, but not exhaustively.  Can you give me more detail about what I am supposed to do?

THANK YOU!!!

Margaret

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: Using Collections as Attributes
« Reply #3 on: June 17, 2009, 03:14:37 am »
Margaret, Use the Attributes dialog to create your attribute and then select [Save]. You may then look on the <Detail> tab to set the Collection info. Make sure that you save here also!

Jim

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Using Collections as Attributes
« Reply #4 on: June 17, 2009, 06:37:21 pm »
Hi Margaret

What has been said is perfectly correct, however the UML modelling approach would be to use two classes

Meeting
Employee

Then create a directed association from Meeting to Employee

Double click this directed association and set the Target Role as

Role name - employees
Multiplicity - 1..*

This model represents that One or More employees attend a meeting

If you wanted to model One or More employees attending zero or more meetings then use a Bi-directional association setting role names and multiplicities at both ends of the association.

Are you intending to generate code from your classes?

If so you will need to set appropriate collection classes for your chosen language for the 1..* etc multiplicities

Cheers
Models are great!
Correct models are even greater!