Author Topic: Bulk creation of relationships  (Read 3080 times)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Bulk creation of relationships
« on: July 10, 2024, 03:06:36 am »
We have a use case to bulk create non-stereotyped relationships between existing elements; mostly associations, dependencies and realisations. What are our options?

I have thought of 3:
1) using the Office add-in/MDG, this doesn’t seem to be going very well,
2) writing a script to loop through pairs of names, or
3) hacking the repository.

My preferences, in order, are 1,2, and 3.

Has anybody tried this or has experience doing this?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk creation of relationships
« Reply #1 on: July 10, 2024, 06:20:17 am »
I do 2) all the time.

never tried 1) and will never do 3)

Geert

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Re: Bulk creation of relationships
« Reply #2 on: July 10, 2024, 03:25:52 pm »
Currently writing a script to do 2.
Agree with Geert that option 3 is a no-go.
And I believe there was an extension to the excel importer from Geert to do connector imports.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Re: Bulk creation of relationships
« Reply #3 on: July 10, 2024, 11:07:34 pm »
I was not really going to go for option 3 ;). I only propose it because we we have to run some complex queries to get the source and target elements.

Option 2 is still my prefer option but the Office MDG is failing with an error to create the new relationships.

rupertkiwi

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Re: Bulk creation of relationships
« Reply #4 on: July 11, 2024, 10:28:31 am »
This is something that i run in excel vba :

Function addConnector(SourceElementID, TargetElementID, ConnectorType, connectorname, connectordirection)
    Dim SourceElement As EA.element
    Dim newconnector As EA.connector
        Dim repository As EA.repository
        Set eaapp = GetObject(, "EA.App")
    Set repository = eaapp.repository
    Set SourceElement = repository.GetElementByID(SourceElementID)
   
    Set newconnector = SourceElement.connectors.AddNew(" ", ConnectorType)
   
    newconnector.SupplierID = TargetElementID
    newconnector.Name = connectorname
    newconnector.Direction = connectordirection
    newconnector.Update
    Set addConnector = newconnector
End Function


you will need the source and target ids to run this

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1311
  • Karma: +120/-10
  • Its the results that count
    • View Profile
Re: Bulk creation of relationships
« Reply #5 on: July 11, 2024, 04:03:23 pm »
If the elements are in two different packages you could create a matrix and bulk create relationships by selecting all the cells and adding relationship
Happy to help
:)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Re: Bulk creation of relationships
« Reply #6 on: July 11, 2024, 05:04:12 pm »
Thank you Rupert, the code could save a significant amount of time, getting the ID requires a query but it should not be too complicated.

Sunshine, thank you for the tip. We tried the matrix, this was my first attempted solution, but hit several problems:
1) the source and target are the same package, at least for associations,
2) there are way too many elements and the resulting matrix is huge, something in excess of 1,000 by 1,000; Sparx EA struggles badly with it,
3) we considered filtering the matrix by diagram or non-blank/empty alias, but it may not be possible/easy,
4) ideally we need the alias, which cannot be added to the matrix, though a colleague working with me has found a temporary work around, and
5) the matrix does not retain the column heights and widths.

Still hoping Sparx Systems perfects the matrix functionality and makes it less frustrating.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Re: Bulk creation of relationships
« Reply #7 on: July 16, 2024, 07:55:05 pm »
Since we got the MDG Integration for Office to work - i.e., it now creates relationships - and considering all the fun we had with scripting - please see https://sparxsystems.com/forums/smf/index.php/topic,48564.0.html - we are going to settle with using Excel for this.

Sparx Systems should listen to its customers/users and vastly improve the capabilities to import/ingest data from external systems. This has been a recurring topic in these forums for a long time.

DeBAAT

  • EA User
  • **
  • Posts: 63
  • Karma: +2/-0
    • View Profile
Re: Bulk creation of relationships
« Reply #8 on: July 17, 2024, 02:23:16 am »
As the Excel option is a bit cumbersome to use with the EA SaaS solution, I created some JavaScripts to do the import/export via an Excel.
See https://github.com/DeBAAT/EABaatScripts.
Any suggestions for improvement are welcome.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Re: Bulk creation of relationships
« Reply #9 on: July 17, 2024, 06:28:04 pm »
As the Excel option is a bit cumbersome to use with the EA SaaS solution, I created some JavaScripts to do the import/export via an Excel.
See https://github.com/DeBAAT/EABaatScripts.
Any suggestions for improvement are welcome.
I agree the MDG Integration for Office is indeed very cumbersome but has been vastly improved, the import and export object models/templates do not align, and nobody seems to have though about import and export round trips.

What do you mean with using EA SaaS solution? We use EA on IaaS with PCS; this is one of the reasons why we are using the MDG Integration for Office, we are not writing directly to the database.

If your scripts are PCS compatible, the may an option because they do something the MDG Integration for Office does not do, at least AFIK, the can create, update, and delete connectors.

DeBAAT

  • EA User
  • **
  • Posts: 63
  • Karma: +2/-0
    • View Profile
Re: Bulk creation of relationships
« Reply #10 on: July 17, 2024, 10:24:54 pm »
With EA SaaS I mean that the EA client also runs on a computer in the cloud.
We connect to the EA client via the browser.
Any files accessed by the EA client also reside on the cloud host.
This also means that an application running on my own pc has no access to the EA application running in the cloud.
So the im/exporter from Geert doesn't work either.

I assume my scripts are PCS compatible as they are running within the EA client, as other scripts.
And yes, there are scripts to im/export Elements as well as Connectors.
The Element export also exports the ElementID which can be used to import Connectors as they are relationships between ClientID and SupplierID.
I also tackled the handling of ArchiMate stereotypes for both Elements and Connectors.

Also the scripts are available for starting from a package or diagram defining the scope of the export.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1087
  • Karma: +28/-8
    • View Profile
Re: Bulk creation of relationships
« Reply #11 on: July 24, 2024, 03:13:15 am »
Well, we may need to think about using your scripts or Geert im/exporter. The Office Integration MDG is incredibly slow, the performance is only acceptable if we could run it as a scheduled sever job. It just takes an eternity to export a few thousand rows.