码迷,mamicode.com
首页 > 其他好文 > 详细

powerdesigner 概念模型(CDM)中Code下划线后首字母大写

时间:2020-05-28 16:50:55      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:技术   RoCE   名称   表名   概念   roc   实体   字段   http   

(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下划线后首字母大写

标签:技术   RoCE   名称   表名   概念   roc   实体   字段   http   

原文地址:https://www.cnblogs.com/yixingzhou/p/12981314.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!