Author Topic: Changing diagram types and default element child diagrams for existing elements  (Read 956 times)

adepreter

  • EA User
  • **
  • Posts: 128
  • Karma: +2/-2
    • View Profile
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
« Last Edit: July 25, 2019, 12:38:30 am by adepreter »

qwerty

  • EA Guru
  • *****
  • Posts: 10597
  • Karma: +232/-194
  • I'm no guru at all
    • View Profile
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.

adepreter

  • EA User
  • **
  • Posts: 128
  • Karma: +2/-2
    • View Profile
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

qwerty

  • EA Guru
  • *****
  • Posts: 10597
  • Karma: +232/-194
  • I'm no guru at all
    • View Profile
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.