Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: adepreter on July 25, 2019, 12:30:41 am

Title: Changing diagram types and default element child diagrams for existing elements
Post by: adepreter on July 25, 2019, 12:30:41 am
Dear Sparxters,
After changing diagram types using C# code equivalent to the VB Script below...

I noticed that when I make an EXISTING element composite, the default diagram type defined in the MDG is not applied.
It works only for new elements.

Any idea what is missing in the code below to apply the diagram type changes to existing elements?

----
option explicit
sub MigrateDiagramsStereotype (oldType, oldStereotype, newType, newStereotype)
   Dim sql

   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"

   ' SQL SERVER SYNTAX ONLY - Cannot be translated to Access as Cast expression does not work with Access
   sql = "update t_diagram " &_
        "set Diagram_Type = '" + newType + "'" &_
        ", StyleEx = cast(replace(cast(StyleEx as nvarchar(max)), 'MDGDgm=" + oldStereotype + "', 'MDGDgm=" + newStereotype + "') as ntext) " &_
        "where " &_
        "Diagram_Type = '" + oldType + "' AND " &_
        "StyleEx like '%MDGDgm=" + oldStereotype + "%'"
   Repository.Execute (sql)
end sub

sub main
      MigrateDiagramsStereotype "Logical",   "MyDiagramPage::MyDiagramStereoyype", "Logical", ""MyNewDiagramPage::MyNewDiagramStereoype"
end sub

main
Title: Re: Changing diagram types and default element child diagrams for existing elements
Post by: qwerty on July 25, 2019, 02:43:19 am
I noticed that when I make an EXISTING element composite, the default diagram type defined in the MDG is not applied.
It works only for new elements.
I don't see what that's got to do with the code which only migrates a diagram stereotype.

q.
Title: Re: Changing diagram types and default element child diagrams for existing elements
Post by: adepreter on August 25, 2019, 10:46:01 pm
When you define an element stereotype, you define notably the
- tagged values
- their grouping
- the default child diagram types.

When you "synchronize stereotype", only the tagged values are updated.
Their grouping and the default child diagram are not updated.

So the "synchronize stereotype" feature does only part of its job.

Cheers,
Alain
Title: Re: Changing diagram types and default element child diagrams for existing elements
Post by: qwerty on August 26, 2019, 09:12:11 pm
Not sure where you "synchronize stereotype" in the above. The SQL for sure isn't one. It's a not supported feature. And still I don't get how this is connected to each other.

q.