I have a problem with my script for converting stereotypes. (see code below)
It seems to work perfectly
- The package is checked out
- The stereotype is changed (I immediately see the changen in project browser)
- The package is check in again
BUT when I click on the changed package (which is already checked in again), the stereotype visibly changes to old+new stereotype. (in the properties, the old and new stereotype are checked)
Can anybody explain why this is happening?? And why it first shows the new stereotype and after selecting the package it adds the old one?? (I tested it several times, always same result!)
Thanks for the help!
sub main
dim collection as EA.Collection
dim packageElement as EA.Element
dim package as EA.Package
dim diagram as EA.Diagram
dim sql, count, comment
dim fromStereotype, toStereotype
fromStereotype = "Process L3"
toStereotype = "Process"
sql = "SELECT t_object.Object_ID FROM t_object WHERE t_object.stereotype = '" & fromStereotype & "' AND t_object.name LIKE '268.%'"
count = 0
set collection = Repository.GetElementSet(sql, 2) '= collection of Package ELEMENTS (no collection of packages)
for each packageElement in collection
set package = Repository.GetPackageByGUID(packageElement.ElementGUID)
if package.VersionControlGetStatus = 1 then '1 = package is checkedIn
package.VersionControlCheckout("checkout for stereotype change")
end if
'Change stereotype of package element
packageElement.StereotypeEx = toStereotype
if not packageElement.Update() then
Msgbox packageElement.GetLastError()
end if
'Create a message
comment = "stereotype: " & fromStereotype & " changed to " & toStereotype
'Check in package
package.VersionControlCheckin (comment)
next
Msgbox "# = " & collection.Count
end sub
main