Book a Demo

Author Topic: Script to change connector stereotype leaves old stereotype in the label  (Read 4380 times)

peterc

  • Guest
I have written a script (Jscript) to change the type and stereotype of connectors (aim is to correct a diagram where many connectors have been drawn of the wrong type). It successfully changes the type and stereotype, but leaves the old stereotype visible in the label.

I am changing "trace" stereotypes to "satisfy". The label starts with <<trace>> and ends up with <<satisfy,trace>>.

Using an SQL query on the t_connector table I can see that a true satisfy relationship (created within the GUI) has a Btm_Mid_label value of <<satisfy>> but my script modified ones have a value of <<trace>>. It looks like EA is combining entries in Btm_Mid_Label and Stereotype when they differ.

So, how can I modify Btm_Mid_Label in a script so that the values match? I can't find anything documented around this.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script to change connector stereotype leaves old stereotype in the label
« Reply #1 on: December 11, 2018, 09:36:02 pm »
If you show us the code you wrote we might be able to help.

It should suffice to set the EA.Connector.StereotypeEx and then Update() the connector.

The changes might not become visible until after a reload.

Geert

peterc

  • Guest
Re: Script to change connector stereotype leaves old stereotype in the label
« Reply #2 on: December 11, 2018, 10:43:58 pm »
Thanks Geert - your suggestion works.

What I had was conn.Stereotype = desired_stereotype, but when I use only conn.StereotypeEx it works (I had tried both and it hadn't worked!). The automation PDF document doesn't explain the difference - do you know what it is and when/why to choose .Stereotype or .StereotypeEx?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script to change connector stereotype leaves old stereotype in the label
« Reply #3 on: December 11, 2018, 11:44:11 pm »
.Stereotype only contains the first stereotype and should typically only be used to read, in case you are certain there will only be one stereotype. -> represents the Stereotype column in the database

.StereotypeEx contains a list of all stereotypes. You can set the stereotype(s) using their Fully Qualified Name (e.g. MyProfile::MyStereotype) -> represents the t_xref entries for stereotype in the database.

Geert