powerdesigner 概念模型(CDM)中Code下划线后首字母大写
Posted yixingzhou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powerdesigner 概念模型(CDM)中Code下划线后首字母大写相关的知识,希望对你有一定的参考价值。
(1)打开powerDesigner概念模型文件(cdm)点击工具选择edit/Run Script 进入。
(2)将vbs脚本文件粘贴点击run运行
(3)powerdesigner 概念模型(CDM)中Code下划线后首字母大写 脚本
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl ‘当前model
‘获取当前活动model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model "
ElseIf Not mdl.IsKindOf(PdCDM.cls_Model) Then ‘如果是处理pdm,这里换成PdPDM.cls_Model
MsgBox "The current model is not an Physical Data model. "
Else
ProcessFolder mdl
End If
Private sub ProcessFolder(folder)
Dim item ‘要处理的对象
‘先处理每个实体或类的Name和Code,相当于每张表的表名
for each item in folder.Entities
if not item.isShortcut then
Dim ecode
ecode = item.code
Dim i
i=2
‘Do While i < 3
Do While i < len(ecode)
If mid(ecode,i,1)=ucase(mid(ecode,i,1)) and mid(ecode,i-1,1)=lcase(mid(ecode,i-1,1)) and mid(ecode,i-1,1)<>"_" and mid(ecode,i,1)<>"_" Then ‘连续大写字母不用加_
ecode = left(ecode,i-1) + "_" + mid(ecode,i)
i =i+ 1
End If
i =i+ 1
Loop
‘item.code=ecode
‘item.name=ecode
dim col
‘处理当前实体下的每个属性,相当于每张表的字段
for each col in item.Attributes
Dim acode
acode = col.code
Dim a
Dim b
a = split(acode, "_")
b = ubound(a)
for i = 0 to b
Dim c
if i<>0 then
c=c+ucase(mid(a(i),1,1))+right(a(i),len(a(i))-1)
‘MsgBox right(a(i),len(a(i))-1)
‘MsgBox ucase(mid(a(i),1,1))+right(a(i),len(a(i)-1))
else
c=c+a(i)
‘MsgBox a(i)
end if
next
‘MsgBox c
col.code=c
c=""
‘col.name=c
next
end if
‘再处理每个folder下的关系的名称
dim rel
for each rel in folder.relationships
if not rel.isshortcut then
rel.name =rel.code
end if
next
next
‘递归遍历子文件夹
Dim f ‘子文件夹
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
以上是关于powerdesigner 概念模型(CDM)中Code下划线后首字母大写的主要内容,如果未能解决你的问题,请参考以下文章
powerdesigner 概念模型(CDM)中Code下划线后首字母大写
powerdesigner 概念模型(CDM)中Code下划线后首字母大写