Hi all,
I am in the process of finalizing a profile delivered in MDG, and unfortunately I have realized a little late in the game that I should make sure the profile stereotype names are unique, due to the flat stereotype namespace in sparx. For example I had stereotypes like "Report" "Interface" "Screen" etc., and these are just too generic and likely to clash with other stereotypes and cause subtle problems in the future, so I have changed the profile stereotype names to be more unique.
I already have model elements using the previous stereotypes, and now I need to migrate them in place using a script. I have performed some tests and I am achieving partial success in replacing the stereotypes with a script, but not complete success. In the end I have to invoke "synchronize stereotype" from a toolbox to get the last change. I was hoping to completely automate this migration. Running a script, and invoking the synchronize once is not too bad, but I am wondering if I am missing something in my script.
Here is the relevant jscript code:
//copy tagged values
var myTag as EA.TaggedValue;
myTag = GetTaggedValue (theElement, "TagName");
//remove all old stereotypes
theElement.Stereotype = "";
theElement.StereotypeEx = "";
theElement.Update();
theElement.Refresh();
//add new stereotype
theElement.Stereotype = "ExScreen";
theElement.Metatype = "ExScreen";
theElement.Update;
theElement.Refresh();
//restore tagged values
TVSetElementTaggedValue( theElement ,"TagName",myTag.Value ,true);
//final update
theElement.Update();
theElement.Refresh();
This seems to do everything, except when I look for my profile defined tags, they do not show up grouped under the profile name, like they do when creating a new element. If I run a script I can see the tags are not associated with the profile with fully qualified names. If I invoke "synchronize stereotype" from the toolbox, then the profile name grouping appears with my values intact and everything looks fine.
Am I doing some thing wrong or missing a step?
(I am sure I may be going overboard with the Update() and Refresh() also)