Sparx Systems Forum

Discussion => General Board => Topic started by: anderspe on December 19, 2017, 07:23:49 pm

Title: Change the Connector Property "Direction" for multiple association
Post by: anderspe on December 19, 2017, 07:23:49 pm
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 
Title: Re: Change the Connector Property "Direction" for multiple association
Post by: Uffe 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
Title: Re: Change the Connector Property "Direction" for multiple association
Post by: anderspe 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
Title: Re: Change the Connector Property "Direction" for multiple association
Post by: Uffe 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
Title: Re: Change the Connector Property "Direction" for multiple association
Post by: anderspe 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
Title: Re: Change the Connector Property "Direction" for multiple association
Post by: Uffe on December 20, 2017, 03:09:02 am
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