PowerDesigner executes script name/comment/stereotype conversion

 

Execution method: Toolbar -> Tools -> Execute Commands -> Edit/Run Script (Ctrl+Shift+X)

 

1. Name goes to the Comment field

Option   Explicit 
ValidationMode   =   True 
InteractiveMode   =   im_Batch 

Dim   mdl   '   the   current   model 

'   get   the   current   active   model 
Set   mdl   =   ActiveModel 
If   (mdl   Is   Nothing)   Then 
      MsgBox   "There   is   no   current   Model " 
ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 
      MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 
Else 
      ProcessFolder   mdl
End   If 

'    This routine copy name into comment for each table, each column and each view 
'    of the current folder 
Private    sub    ProcessFolder(folder)    
       Dim    Tab    ' running table     
      for    each    Tab    in    folder.tables    
             if    not    tab .isShortcut then 
                     if   trim ( tab . comment) = ""  then ' If there is a table comment, don't change it. If there is no table comment, add name to the comment. 
                        tab .comment =    tab .name
                      end if   
                  Dim    col    '    running column     
                  for    each    col    in    tab .columns   
                         if  trim (col.comment)= ""  then  ' If the comment of col is empty, fill in the name, if there is a comment, it will not be added; this can avoid There are comments missing. 
                           col.comment=    col.name   
                         end  if  
                  next     
            end    if     
      next    
  
      Dim   view   'running   view    
      for   each   view   in   folder.Views    
            if   not   view.isShortcut and trim(view.comment)=""  then    
                  view.comment   =   view.name    
            end   if    
      next    
  
      '   go   into   the   sub-packages    
      Dim   f   '   running   folder    
      For   Each   f   In   folder.Packages    
            if   not   f.IsShortcut   then    
                  ProcessFolder   f    
            end   if    
      Next    
end   sub

 

 

2. Save the Comment content to NAME

Option   Explicit    
ValidationMode   =   True    
InteractiveMode   =   im_Batch    
  
Dim   mdl   '   the   current   model    
  
'   get   the   current   active   model    
Set   mdl   =   ActiveModel    
If   (mdl   Is   Nothing)   Then    
      MsgBox   "There   is   no   current   Model "    
ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then    
      MsgBox   "The   current   model   is   not   an   Physical   Data   model. "    
Else    
      ProcessFolder   mdl    
End   If    
  
Private   sub   ProcessFolder(folder)    
On Error Resume Next   
      Dim   Tab   'running     table    
      for   each   Tab   in   folder.tables    
            if   not   tab.isShortcut   then    
                  tab.name   =   tab.comment   
                  Dim   col   '   running   column    
                  for   each   col   in   tab.columns    
                  if col.comment="" then   
                  else  
                        col.name=   col.comment    
                  end if  
                  next    
            end   if    
      next    
  
      Dim   view   'running   view    
      for   each   view   in   folder.Views    
            if   not   view.isShortcut   then    
                  view.name   =   view.comment    
            end   if    
      next    
  
      '   go   into   the   sub-packages    
      Dim   f   '   running   folder    
      For   Each   f   In   folder.Packages    
            if   not   f.IsShortcut   then    
                  ProcessFolder   f    
            end   if    
      Next    
end   sub

 

3、name转stereotype

 

Option   Explicit 
ValidationMode   =   True 
InteractiveMode   =   im_Batch 

Dim   mdl   '   the   current   model 

'   get   the   current   active   model 
Set   mdl   =   ActiveModel 
If   (mdl   Is   Nothing)   Then 
      MsgBox   "There   is   no   current   Model " 
ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 
      MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 
Else 
      ProcessFolder   mdl
End   If 

'    This routine copy name into stereotype for each table, each column and each view 
'    of the current folder 
Private    sub    ProcessFolder(folder)    
       Dim    Tab    ' running table     
      for    each    Tab    in    folder.tables    
             if    not    tab .isShortcut then 
                     if   trim ( tab . stereotype) = ""  then ' If there is a table annotation, do not change it. If there is no table annotation. Add name to the annotation. 
                        tab .stereotype =    tab .name
                     end if  
                  Dim   col   '   running   column    
                  for   each   col   in   tab.columns   
                        if trim (col.stereotype)= ""  then  ' If the stereotype of col is empty, fill in the name, if there is a comment, it will not be added; this can avoid An existing comment is missing. 
                           col.stereotype=    col.name   
                         end  if  
                  next     
            end    if     
      next    
  
      Dim   view   'running   view    
      for   each   view   in   folder.Views    
            if   not   view.isShortcut and trim(view.stereotype)=""  then    
                  view.stereotype   =   view.name    
            end   if    
      next    
  
      '   go   into   the   sub-packages    
      Dim   f   '   running   folder    
      For   Each   f   In   folder.Packages    
            if   not   f.IsShortcut   then    
                  ProcessFolder   f    
            end   if    
      Next    
end   sub

 

 

 

Original address: https://www.cnblogs.com/eedc/p/7774111.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325331640&siteId=291194637