Author Topic: script detecting connectors ?  (Read 10719 times)

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
script detecting connectors ?
« on: March 26, 2010, 02:05:39 am »
Hello,

I would like to write a script in C# detecting every links (for example an association link) in my project, and their target.

I’ve found on the EA website an example describing how to find every tagged values and tried to adapt it for my case, but it doesn’t work.


I tried the following code :

String printedText="";
                    EA.Package aPackage;
                    aPackage = Repository.GetTreeSelectedPackage();

                    foreach (EA.Connector connect in aPackage.Connectors)
                    {
                        printedText = printedText + connect.ClientEnd.End + ",";
                    }

but nothing is printed when I display « printedText ».
I think I don’t even excecute the loop 1 time because if I write
foreach (EA.Connector connect in aPackage.Connectors)
                    {
                        printedText = “test”;
                    }
I have exactly the same result: nothing.


Do you have an idea to solve this problem ?

Thank you.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: script detecting connectors ?
« Reply #1 on: March 26, 2010, 08:43:52 am »
I've only ever used Element.Connectors, not Package.Connectors.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: script detecting connectors ?
« Reply #2 on: March 26, 2010, 12:41:18 pm »
Quote
I've only ever used Element.Connectors, not Package.Connectors.
Has anybody ever used Package.Connectors?

Did it work?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: script detecting connectors ?
« Reply #3 on: March 26, 2010, 07:20:07 pm »
Indeed the result is better with Element.Connector.
Package.Connector didn't identify anything in my project (but maybe I have not the adapted objects)


Do you know how to hobtain the name of the target of the link ?
Because in Connector properties there are"ClientID" and "ClientEnd" but there is nothing in CleintEnd giving the name of the target.
(I have an idea using ClientID and then using it to find the name of the target, but there is surely a simpler method) ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: script detecting connectors ?
« Reply #4 on: March 26, 2010, 07:34:50 pm »
Use Repository.GetElementByID to get the element the connector is pointing to.
(not there is no simpler way)

Geert

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: script detecting connectors ?
« Reply #5 on: March 26, 2010, 08:13:54 pm »
OK thanks,

But what happen if the target is an operation or an attribute ? It will probably give the ID of the class containing the operation and not the ID of the operation ??
« Last Edit: March 26, 2010, 08:14:14 pm by utilisateurEA »

beginner

  • Guest
Re: script detecting connectors ?
« Reply #6 on: March 26, 2010, 08:35:04 pm »
You can not have a connector to attributes or operations.

b.

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: script detecting connectors ?
« Reply #7 on: March 26, 2010, 08:51:38 pm »
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: script detecting connectors ?
« Reply #8 on: March 26, 2010, 09:09:31 pm »
Quote
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")
You have to be careful...  The linkage is (effectively) a rendering ONLY.  The t_connector details - as beginner says - ONLY refer to the end Elements (not Features).  It is NOT a simple matter to extract the rendering information and convert it to the (derived) Feature linkages.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

beginner

  • Guest
Re: script detecting connectors ?
« Reply #9 on: March 26, 2010, 09:10:14 pm »
Quote
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")
You're right, but that's still a link between elements. I do not know where they store the "Linked Element" information. Probably in the MiscData as this feature had been added in a later release of EA.

b.

P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.
« Last Edit: March 26, 2010, 09:25:02 pm by beginner »

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: script detecting connectors ?
« Reply #10 on: March 26, 2010, 09:46:16 pm »
Quote
P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.

how could you access to  the MiscData informations of a connector ? I used get_MiscData but obtained nothing ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: script detecting connectors ?
« Reply #11 on: March 26, 2010, 09:46:53 pm »
There was a topic a few weeks ago about this "link to element" feature and how it is stored in the database.

Use the search button on the top left to try and find it.

Geert

beginner

  • Guest
Re: script detecting connectors ?
« Reply #12 on: March 26, 2010, 10:32:45 pm »
Quote
Quote
P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.

how could you access to  the MiscData informations of a connector ? I used get_MiscData but obtained nothing ?
I emphasized the relevant part.

b.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: script detecting connectors ?
« Reply #13 on: March 26, 2010, 10:48:03 pm »
you can always use Repository.SQLQuery to get details from the database that are not exposed in the API.

Geert

utilisateurEA

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: script detecting connectors ?
« Reply #14 on: March 27, 2010, 02:10:49 am »
How do you have details of what is contained in a connector for example ?

I don't really understand how a SQLQuery(string SQL) works :
do you have to write a SQL request in in the string or the name of the connector ?
(every time I try to use it I have "the SELECT statement includes a reserved word or an argument name is mispelled or missing")

Thank you !