Book a Demo

Author Topic: Getting diagrams for a given Element.  (Read 5282 times)

Hermes

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Getting diagrams for a given Element.
« on: November 27, 2009, 08:01:13 am »
Dear EA comunity,

I'm working on a traceability mechanism that enable users to trace a pierce of diagram to other elments.
Actually I was trying to implement this feature using a stereotyped InteractionFragment as a pierce of diagram, but I have a problem:

How can I get the set of diagrams containing a given Element by an add-in?

Or, in alternative, is possible to get a diagram (Just One) that contains a given element via automation interface...
it should be possible since EA GUI provides a "in diagrams.." option placed in the context menu that is exactly what I need for my add-in.

Moreover, I have another set of questions about the use of two Element attributes:

1.Element.CompositeDiagram. how does it works?
if the Element type is an InteractionFragment, why it is null?
in which case it is not null?

2. Element.Diagrams: which kind of Element have this collection populated?


Thank you all

/Hermes

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting diagrams for a given Element.
« Reply #1 on: November 27, 2009, 07:26:49 pm »
Quote
Dear EA comunity,

I'm working on a traceability mechanism that enable users to trace a pierce of diagram to other elments.
Actually I was trying to implement this feature using a stereotyped InteractionFragment as a pierce of diagram, but I have a problem:

How can I get the set of diagrams containing a given Element by an add-in?

Or, in alternative, is possible to get a diagram (Just One) that contains a given element via automation interface...
it should be possible since EA GUI provides a "in diagrams.." option placed in the context menu that is exactly what I need for my add-in.
Hermes,

AFAIK there is no API function to get the diagrams, but there are some alternatives.
If I need something like that I usually use the Repository.SQLQuery function to get me a list of diagramID's. Then use the Repository.GetDiagramByID to get the actual diagram objects.

You could also traverse through the whole model, visit each diagram to find out if it displays the element you are after, but that will be an order of magnitude slower.

Quote
Moreover, I have another set of questions about the use of two Element attributes:

1.Element.CompositeDiagram. how does it works?
if the Element type is an InteractionFragment, why it is null?
in which case it is not null?
I think that attribute it meant to store the diagram that is linked to that element as the composite diagram. I.e. the diagram that is shown when you doubleclick the element on a diagram.
To enable this right-click on an element and select "Advanced/Composite". That will assign the first diagram nested under the element as the composite diagram.
Quote
2. Element.Diagrams: which kind of Element have this collection populated?

I think that is the collection of diagrams nested under an element (in the project browser.


Geert

beginner

  • Guest
Re: Getting diagrams for a given Element.
« Reply #2 on: November 27, 2009, 07:39:56 pm »
Check out http://community.sparxsystems.com/resources/community/scripts/extending-ea-perl
The EaControlReposWrapper.pm has a routine childrenDiagrams which does what you want.

b.

Hermes

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Getting diagrams for a given Element.
« Reply #3 on: November 27, 2009, 09:26:08 pm »
Quote
AFAIK there is no API function to get the diagrams, but there are some alternatives.
If I need something like that I usually use the Repository.SQLQuery function to get me a list of diagramID's. Then use the Repository.GetDiagramByID to get the actual diagram objects.

You could also traverse through the whole model, visit each diagram to find out if it displays the element you are after, but that will be an order of magnitude slower.


Yes, of course performing a linear seach could be a solution, but
my addin will work on large systems, so slowness could be a problem.

but, using the SQL API interface looks interesting...
where can I get more infos about the EA repository schema?
I haven't found anything about... no ER diagrams no detailed documentation about the internal structure of the repositoy...

for example... does the api support JOIN operations?

(I'd like to build a query directy to the DiagramObject... this should solve the problem... )

Quote

I think that attribute it meant to store the diagram that is linked to that element as the composite diagram. I.e. the diagram that is shown when you doubleclick the element on a diagram.
To enable this right-click on an element and select "Advanced/Composite". That will assign the first diagram nested under the element as the composite diagram.

[...]
I think that is the collection of diagrams nested under an element (in the project browser.

That's great... you showed me a really nice feature :)


Thank you Geert :)


@beginner:

where can I find documentation about the childrenDiagrams routine?

if it gives the set of diagram where the element is represented, it could be really interesting... ;)

thanks

/Hermes
« Last Edit: November 27, 2009, 09:28:44 pm by hermes »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting diagrams for a given Element.
« Reply #4 on: November 27, 2009, 09:36:31 pm »
Quote

but, using the SQL API interface looks interesting...
where can I get more infos about the EA repository schema?
I haven't found anything about... no ER diagrams no detailed documentation about the internal structure of the repositoy...

for example... does the api support JOIN operations?

(I'd like to build a query directy to the DiagramObject... this should solve the problem... )

You can't since there isn't any documentation :'(
Luckily the database is pretty simple.
Diagrams can be found in t_diagram, DiagramObjects in t_diagramObjects and elements in t_Object,...

Depending on the database you use (eap files are MS Access databases) you'll have to adjust the query.
The query you pass to the operation SQLQuery is directly passed on to the database, so if it works on the database it'll work using the API.

Geert

PS. The performance difference between traversing a model, and using the SQLQuery to find the objects you need is pretty huge.
As an example: I created an excel export that had to export about 6000 objects all contained in one rootpackage.
Using the conventional API objects to visit all packages, subpackages etc... took about three hours.
After refactoring to use the SQLQuery operation it took 3 seconds  :o, including excel document creation and save...

Hermes

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Getting diagrams for a given Element.
« Reply #5 on: November 27, 2009, 10:19:44 pm »
Quote
You can't since there isn't any documentation :'(

:'(

Quote
Luckily the database is pretty simple.
Diagrams can be found in t_diagram, DiagramObjects in t_diagramObjects and elements in t_Object,...

Thankyou,

I'm trying to build my own query:

Code: [Select]
SELECT * FROM t_diagramobjects WHERE ElementID=11

but when it runs returns the following error:

Quote
DAO.Database [3061]
Too few parameters, expected 1.

 :'(


What does it means? How can I face it?

Quote
Depending on the database you use (eap files are MS Access databases) you'll have to adjust the query.
The query you pass to the operation SQLQuery is directly passed on to the database, so if it works on the database it'll work using the API.

Geert

PS. The performance difference between traversing a model, and using the SQLQuery to find the objects you need is pretty huge.
As an example: I created an excel export that had to export about 6000 objects all contained in one rootpackage.
Using the conventional API objects to visit all packages, subpackages etc... took about three hours.
After refactoring to use the SQLQuery operation it took 3 seconds  :o, including excel document creation and save...

Yes, as I was thinking before this post,  the API fetch overhead is really heavy,

I think that a better documentation of the low level rapresentation of the repository should really improve the usability of the yet powerful EA addin support.  :)

Thanks
/D

Hermes

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Getting diagrams for a given Element.
« Reply #6 on: November 27, 2009, 10:25:54 pm »
I made it works!!   :)

the right query was...

Code: [Select]
SELECT Diagram_ID FROM t_diagramobjects WHERE Object_ID=11