Book a Demo

Author Topic: Make a Class a Collection Base  (Read 4832 times)

Tryst

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Make a Class a Collection Base
« on: July 13, 2005, 08:33:55 am »
Simple task here, but not sure how on earth I do it in EA.

I have a Class called 'Task' and I want another Class which is to be a Collection of 'Tasks', thus being Collection Class.

I know this is possible, as I have imported C# files that had Collection Classes and noticed that these Collection Classes has the label 'Collection Base' on them in the diagram.

Hope you can help me.

Thanks

Tryst
Tryst

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Make a Class a Collection Base
« Reply #1 on: July 13, 2005, 04:08:48 pm »
Hello Tryst.

I'm not sure what you're after, or what you got from reverse engineering.

But EA has a feature called collection classes, I'll give you some details in the hope that it helps.

I would start by modelling Task and Tasks exactly as you need them to appear.

Open the properties for Task.

Go to the Detail Tab.

Click the Collection Classes... button.

Set the default collection class to Tasks.  (You may also want to set other collection classes)

You can then create associations with the multiplicity set to 1..* and the attribute that will be generated will be of type Tasks.

For more information see http://sparxsystems.com.au/EAUserGuide/index.html?settingcollectionclasses.htm

Tryst

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Make a Class a Collection Base
« Reply #2 on: July 14, 2005, 12:46:14 am »
Hi Simonm, thanks for the reply.

I have done what you have stated and have created two Classes on the diagram (Task and Tasks) and set the Default Collection Class to 'Tasks', as well as setting the Multiplicity value to 1..*. I set this in the 'Collection Class for ordered Multipicity' (do I leave the Collection for QualifiedMultiplicity blank? What is this for?).

After doing this I notice nothing new/changed on my Diagram. The Tasks class is the same. What I got from reverse engineering was that Collection Classes has the word 'Collection Base' labelled to the top-right of it. This is what I want on my Collection Classes.

Tryst
Tryst

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Make a Class a Collection Base
« Reply #3 on: July 14, 2005, 02:09:25 am »
Hi Tryst,

if there is a word in the ot the top-right of a class, this means, that this class has a base calss which is not visible in that diagram with the labelled name.

Example: You hava a Class 'MyBaseClass' and a class 'MyChildClass' which is derived form 'MyBaseClass.

If you now drag 'MyChildClass' to an empty diagram, it should have the label 'MyBaseClass' on the top-right.

Hope that explains what the label means in reality.

bye
Andreas
bye
Andreas

Rick

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Make a Class a Collection Base
« Reply #4 on: July 14, 2005, 08:03:23 am »
Simon & Andreas,

I had the same question as Tryst. Thanks for the help. I have a couple of additional, related question as well.

1) How do I model a class that inherits from another class that is not in my model? For example I don't want to reverse engineer the entire .NET framework, but want to show that classes I am creating inherit from, for example, System.Collections.CollectionBase.

2) How do I make sure that when I generate code from my model that the inheritance is included in the model?

Thanks in advance.

Rick Petrecca

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Make a Class a Collection Base
« Reply #5 on: July 14, 2005, 08:48:40 am »
Hi Rick,

Quote
1) How do I model a class that inherits from another class that is not in my model? For example I don't want to reverse engineer the entire .NET framework, but want to show that classes I am creating inherit from, for example, System.Collections.CollectionBase.

I don't know a solution for that. In my case I all the time reverse engineer the classes.

Quote
2) How do I make sure that when I generate code from my model that the inheritance is included in the model?

I think, that I don't understand your question. Because if you gerenreate code from your model, the inheritance should already exist.  ???

bye Andreas
bye
Andreas

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Make a Class a Collection Base
« Reply #6 on: July 14, 2005, 06:42:50 pm »
Hi Rick,

1) Open the Type Hierarchy dialog for the child class.
Type in System.Collections.CollectionBase to the class name field.  Make sure that "Accept classifier even if not in model" is checked.

2) I'm not sure what you're after here either.

Tryst

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Make a Class a Collection Base
« Reply #7 on: July 15, 2005, 12:31:02 am »
Hi simonm, how exactly do I get to the 'Type Heirarchy' dialog?

Thanks

Tryst
Tryst

thomaskilian

  • Guest
Re: Make a Class a Collection Base
« Reply #8 on: July 15, 2005, 03:36:18 am »
Right click/Advanced Settings/Set Element Parent
or Ctrl+I

Tryst

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Make a Class a Collection Base
« Reply #9 on: July 18, 2005, 02:17:17 am »
Got it. thanks.

(Though I don't have the 'Advanced Settings' option when I right-click. The 'Set Element Parent' option is amongst the main options when I right-click)

Tryst
Tryst

thomaskilian

  • Guest
Re: Make a Class a Collection Base
« Reply #10 on: July 18, 2005, 11:29:35 am »
That's because you have an older release than me. However, it's fine that it's working :)