Author Topic: Creating Associations in the database  (Read 4349 times)

Michel777

  • EA User
  • **
  • Posts: 228
  • Karma: +0/-0
    • View Profile
Creating Associations in the database
« on: September 29, 2013, 08:47:48 pm »
Hi,

we are importing elements from Mega with associations. All the elements (Classes, Messages, Datatypes) were imported successfully. Now we are going to import the associations between them.

Questions:

1) Is it possible at all to create associtaions visible on the GUI ?
2) If yes, in which tables should be inserted new rows ?
3) Especially: how to get the value for ea_guid in t_connector ?

Thanks in advance,

Michel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Creating Associations in the database
« Reply #1 on: September 30, 2013, 02:49:52 am »
Via GUI of course. EA would be rather pointless without :-)
Regarding automated insertion. Of course you can directly insert in the tables. But is there a good reason for that? I'd prefer to write a script and use the automation.

q.

Michel777

  • EA User
  • **
  • Posts: 228
  • Karma: +0/-0
    • View Profile
Re: Creating Associations in the database
« Reply #2 on: September 30, 2013, 04:45:15 am »
Hi,

what kind of script do you mean ?  If SQL, then I need to know, which table should be accessed, especially because of getting ea_guid.

BTW I cannot draw connectors, there is more than 3000.

Thanks in advance,

Michel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Creating Associations in the database
« Reply #3 on: September 30, 2013, 06:48:16 am »
I mean any kind of script - the API. You would need to add to Element.Connectors. You should not modify the database directly unless you know how to do it with the API. It's like going into a factory and pressing arbitrary knobs in the command center without knowing what happens.

The fact that you have 3000 connectors does not mean you have to have them all in a single diagram. That would definitely not make any sense. So I still do not really get what you are trying to do.

q.

Michel777

  • EA User
  • **
  • Posts: 228
  • Karma: +0/-0
    • View Profile
Re: Creating Associations in the database
« Reply #4 on: September 30, 2013, 07:12:05 am »
HI,

which API ? We will only use a part of relationships of course.

Thanks,

Michel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Creating Associations in the database
« Reply #5 on: September 30, 2013, 07:18:24 am »
You are talking in riddles :-/

You want to manipulate tables inside EA but you don't know its API??? Thats like opening your car's throttle not by pushing the accelerator pedal but leaning over to the motor and pulling at the cables of the carburetor.

I'd recommend you have a look in my Scripting book. You can download a free sample so maybe that will give you an impression of what EA's API means.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Creating Associations in the database
« Reply #6 on: September 30, 2013, 09:28:15 am »
Hi Michel,

The API that qwerty is referring to is EA's automation interface.

Enterprise Architect exposes an ActiveX / COM automation interface, allowing you to write an external application or Add-In to extend and automate Enterprise Architect functionality.  There is also a built-in Scripting window available with the Corporate Edition or higher for performing more ad-hoc automation tasks.
 
For more information on the automation interface (including full API reference), please refer to the help file included with Enterprise Architect.  The following link is to the online HTML version of this documentation:
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/usingtheautomationinterface.html
 
Some code samples are included in the installation directory with Enterprise Architect.  Example scripts can be found in the Scripting window.  Additional code samples to help get started with writing EA add-ins can be found under the Resources area of the Sparx Systems website and on the EA Community web site.
http://www.sparxsystems.com/resources/developers/autint.html
http://community.sparxsystems.com/

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Creating Associations in the database
« Reply #7 on: September 30, 2013, 04:13:00 pm »
Michel,

I agree with qwerty. Although it is possible to add association through SQL  directly I would strongly recommend to do it using the API.
It is really not that difficult.
Maybe the easiest way into it is to check out the VBA Excel Importer I wrote.
Adding associations it more or less the same thing.
You select one of the two elements involved, and do a MyElement.Connectors.AddNew("MyName","Assocation");
Then you need to make sure that you set the target ID of the association and save it by calling update() on the connector object.

Geert