Author Topic: Change the Connector Property "Direction" for multiple association  (Read 816 times)

anderspe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
I have imported a class diagrams from RSA. All associations ends up "Bi-Directional" (Connector property "Direction) but I want them to be "Unspecified". It is possible to carry out the change association by association but is it possible to carry out the change for all association at one time?

/Anders 

Uffe

  • EA Practitioner
  • ***
  • Posts: 1274
  • Karma: +93/-8
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Change the Connector Property "Direction" for multiple association
« Reply #1 on: December 19, 2017, 07:29:16 pm »
Hej Anders,

If you know what you're doing you can always call the undocumented Repository.Execute() in a script, passing it something like
Code: [Select]
update t_connector set Direction = 'Unspecified' where Direction = 'Bi-Directional'
/Uffe
My theories are always correct, just apply them to the right reality.

anderspe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Change the Connector Property "Direction" for multiple association
« Reply #2 on: December 19, 2017, 08:53:35 pm »
Thanks Uffe, my problem with scripts is that I don't know what I am doing  :)

/Anders

Uffe

  • EA Practitioner
  • ***
  • Posts: 1274
  • Karma: +93/-8
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Change the Connector Property "Direction" for multiple association
« Reply #3 on: December 19, 2017, 10:33:59 pm »
Well no worries. The context for a script in EA includes a global variable Repository, so you can just create a script and call Repository.Execute() with a SQL statement and it'll do it. That method is undocumented, which is for a reason: it will bypass a lot of the stuff EA normally does to make sure the database stays consistent. In other words, it is quite possible to break a project beyond repair.

Note that while the snippet I posted should work (haven't tested it), it will change the direction of every single connector in the project. You did say "all". :) So either you'll have to narrow that statement down, or run the script in a temp project that only contains the stuff you want to modify.

I'm guessing that even in a temp project not all your connectors will be associations, so perhaps this would be more appropriate:
Code: [Select]
update t_connector set Direction = 'Unspecified' where Connector_Type = 'Association' and Direction = 'Bi-Directional'
/Uffe
My theories are always correct, just apply them to the right reality.

anderspe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Change the Connector Property "Direction" for multiple association
« Reply #4 on: December 20, 2017, 01:51:09 am »
Thanks Uffe,

I have som knowledge of SQL (30 years old knowledge) but I have no clue how to write a script in EA but I will try to find someone at the IT department  :)

Regards
Anders

Uffe

  • EA Practitioner
  • ***
  • Posts: 1274
  • Karma: +93/-8
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Change the Connector Property "Direction" for multiple association
« Reply #5 on: December 20, 2017, 03:09:02 am »
  • Open the scripting window. (Depends on the version you're using, in 11 it's in the Tools menu.
  • Top left icon, New Normal Group. Call it Tmp or whatever.
  • Second icon, New VBScript. Call it Fix Directions or something.
  • Cut & paste.
Code: [Select]
option explicit

Repository.Execute("update......")
Hit the fourth icon ( S ->) to run it.

That's it.

This is a quick and dirty hack. Do not use it in a production environment. Do not run it on blind faith. Do not pass Go. Do not inkassera kr 4000.


/Uffe
My theories are always correct, just apply them to the right reality.