Book a Demo

Author Topic: Problems with UseCase diagrams  (Read 7178 times)

ron10023

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Problems with UseCase diagrams
« on: June 22, 2008, 05:10:49 pm »
Hi all,

I'm trying to get the element from a UseCase diagram like so:

diagramElement = EAInterface.Repository.GetElementByID(diagram.DiagramID);

and it cant find it...

any ideas?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Problems with UseCase diagrams
« Reply #1 on: June 23, 2008, 12:04:46 am »
Hi Ron,

I'm not absolutely sure what you're trying to do, but if my guess is correct you might want something like:

diagramElement = EAInterface.Repository.GetElementByID(diagram.ParentID);

Does that help?

PS: Make sure you test that there is a valid parent. If the diagram is not 'owned' by an element - not all diagrams are, and there is no default owner - then you might get either an exception or a null return value.
David
« Last Edit: June 23, 2008, 12:06:37 am by Midnight »
No, you can't have it!

ron10023

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Problems with UseCase diagrams
« Reply #2 on: June 23, 2008, 01:51:35 pm »
Hi,

I'm trying to loop over all the tree in c#.

My line works well when i encounter an Actor diagram but when i encounter a UseCase diagram it fails, and i don't really know why

Thanks

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: Problems with UseCase diagrams
« Reply #3 on: June 23, 2008, 02:53:49 pm »
Hello Ron,
GetElementByID() requires an ElementID - it won't work for a Diagram ID.  Sounds like you need to loop through the elements of the Diagram.DiagramObjects Collection.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Problems with UseCase diagrams
« Reply #4 on: June 23, 2008, 03:23:00 pm »
As has been said twice here, a diagram ID is incompatible with an element ID.  Your code may appear to do something right just because there happens to be an object with the same ID as the diagram.  But really the behavior will be undefined.

From what I read, Dermot is probably correct that you want to iterate over the elements on a diagram.

ron10023

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Problems with UseCase diagrams
« Reply #5 on: June 23, 2008, 03:51:57 pm »
Hi,

My addin handles the creation of new elements in EA.
I need to return a list of EA.Element objects based on the user selection on the tree.

This means that i need to retrieve a List<EA.Element> representation of the subtree of the user-selected element.

I need to return the diagram itself too somehow so the user will be able to create diagram objects through my addin.

Thanks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Problems with UseCase diagrams
« Reply #6 on: June 23, 2008, 04:10:05 pm »
Then have a look at Repository.GetTreeSelectedItem.  However I think it only handles one item.

From that you can get an object and cast it appropriately depending on the return value.

ron10023

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Problems with UseCase diagrams
« Reply #7 on: June 23, 2008, 08:13:12 pm »
All i need is to get an EA.Element object that reflects the diagram.

Unless you tell me that the diagram is not really an element in which case there is no point in looping like i do

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Problems with UseCase diagrams
« Reply #8 on: June 24, 2008, 03:56:26 am »
No, a diagram is not really an element. This comment holds true for both EA and UML itself.

So you'll need to traverse two lists of things your parent element owns: the elements and the diagrams. [Assuming this is what you meant from your first post.] There are collections for both.

The ParentID of a diagram will return the ID of the element that owns the diagram, if any. Not all diagrams are owned by an element.

The PackageID of a diagram will return the package that owns a diagram, whether the diagram is 'directly' owned by the package or owned by an element within the package. [There can be a chain of ownership.] All diagrams have an 'owning' package, so this field should be populated.

HTH, David
No, you can't have it!