您可以使用此 VBScript 重命名 EA 中的构造型。
已经在.eap文件上测试过,之所以这么复杂,是因为MS Access SQL语法中缺少replace()。
只需转到脚本视图,添加一个新的 VBScript 并将此代码粘贴到您的新脚本中。然后修改它以指示 from 和 to 构造型。
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Script Name: Rename Stereotypes
' Author: Geert Bellekens
' Purpose: Rename stereotypes on all types of elements
' Environment: Tested on .eap file.
' Date: 13/10/2015
'
sub main
renameElementStereotypes "FromStereo", "ToStereo"
renameAttributeStereotypes "FromStereo", "ToStereo"
renameConnectorStereotypes "FromStereo", "ToStereo"
renameOperationStereotypes "FromStereo", "ToStereo"
renameDiagramStereotypes "FromStereo", "ToStereo"
Repository.RefreshModelView(0)
msgbox "Finished renaming stereotypes"
end sub
sub renameElementStereotypes(fromStereo, toStereo)
renameStereotypes "t_object", fromStereo, toStereo
end sub
sub renameAttributeStereotypes(fromStereo, toStereo)
renameStereotypes "t_attribute", fromStereo, toStereo
end sub
sub renameConnectorStereotypes(fromStereo, toStereo)
renameStereotypes "t_connector", fromStereo, toStereo
end sub
sub renameOperationStereotypes(fromStereo, toStereo)
renameStereotypes "t_operation", fromStereo, toStereo
end sub
sub renameDiagramStereotypes(fromStereo, toStereo)
renameStereotypes "t_diagram", fromStereo, toStereo
end sub
sub renameStereotypes (baseTable, fromStereo, toStereo)
dim updateSQL
'first the second part of of t_xref description
updateSQL = "update (" & baseTable & " o inner join t_xref x on o.[ea_guid] = x.[Client]) "&_
" set x.Description = MID( x.Description, 1, INSTR( x.Description, ':" & fromStereo & "') - 1) "&_
" + ':" & toStereo & "' "&_
" + MID(x.Description,INSTR( x.Description, ':" & fromStereo & "') "&_
" + LEN(':" & fromStereo & "'), LEN(x.Description) "&_
" - INSTR( x.Description, ':" & fromStereo & "') "&_
" - LEN(':" & fromStereo & "')+ 1) "&_
" where o.Stereotype = '" & fromStereo & "' "&_
" and x.Name = 'Stereotypes' "&_
" and INSTR( x.Description, ':" & fromStereo & "') > 0 "
Repository.Execute updateSQL
'then the first part of t_xref description
updateSQL = "update (" & baseTable & " o inner join t_xref x on o.[ea_guid] = x.[Client]) "&_
" set x.Description = MID( x.Description, 1, INSTR( x.Description, '=" & fromStereo & "') - 1) "&_
" + '=" & toStereo & "' "&_
" + MID(x.Description,INSTR( x.Description, '=" & fromStereo & "') "&_
" + LEN('=" & fromStereo & "'), LEN(x.Description) "&_
" - INSTR( x.Description, '=" & fromStereo & "') "&_
" - LEN('=" & fromStereo & "')+ 1) "&_
" where o.Stereotype = '" & fromStereo & "' "&_
" and x.Name = 'Stereotypes' "&_
" and INSTR( x.Description, '=" & fromStereo & "') > 0 "
Repository.Execute updateSQL
'then the stereotype itself
updateSQL = " update " & baseTable & " o "&_
" set o.[Stereotype] = '" & toStereo & "' "&_
" where o.Stereotype = '" & fromStereo & "' "
Repository.Execute updateSQL
end sub
main