通用数据模型中的ERD文件-如何打开?欧文/PowerDesigner



我正在尝试访问此处的ERD文件:https://github.com/microsoft/Industry-Accelerator-Health/tree/master/documentation

现在,我更喜欢使用PowerDesigner/Erwin这样的工具来实际查看物理结构。如有任何建议,我们将不胜感激。

这里有一个脚本,它采用了这样一个ERD模型,并试图从中创建一个PowerDesigner面向对象模型。它并不完整,忽略了一些信息,但它只是一个开始。

在PowerDesigner中使用Tools > Execute Commands > Edit/Run Script运行。

option explicit
' load XML document
dim doc : set doc = CreateObject("MSXML2.DOMDocument")
doc.load("C:TEMPDynamics.365.Electronic.Medical.Records.erd")
' create model
dim model : set model = CreateModel(PdOOM.Cls_Model, "|Language=Analysis|Diagram=ClassDiagram")
dim diagram : set diagram = model.DefaultDiagram
' start entities enumeration
dim entities : set entities = doc.getElementsByTagName("Entity")
dim e, count
count = 0
dim mapent : set mapent = createobject("Scripting.Dictionary")
for each e in entities
count = count+1
dim name : name = "Class_" + cstr(count)
dim n : set n = e.getElementsByTagName("Name")
if n.length > 0 then
name = n.item(0).firstChild.nodeValue
end if
dim p : set p = e.getElementsByTagName("Location")
dim x,y
if p.length > 0 then
x = p.item(0).attributes.getNamedItem("left").nodeValue
y = p.item(0).attributes.getNamedItem("top").nodeValue
else
x = 0
y = 0
end if
dim c : set c = model.classes.CreateNew
' keep track of entity by number, to draw relationships
mapent.add cstr(count),c
c.setNameAndCode name,name
dim sym : set sym = diagram.AttachObject(c)
if x <> 0 and y <> 0 then
'TODO check coordinates conversion, especially if autolayout is not called...
dim pos : set pos = sym.position
pos.x = x*50
pos.y = y*50 - 20000
end if
' add attributes
dim atts : set atts = e.getElementsByTagName("Member")
dim m
for each m in atts
if m.attributes.getNamedItem("type").nodeValue = "Field" then
dim str : str = m.firstChild.nodeValue
dim parts : parts = split(str,": ")
dim att : set att = c.attributes.CreateNew
att.setNameAndCode parts(0),parts(0)
att.datatype = parts(1)
end if
next
next
' create relatonships
dim rels : set rels = doc.getElementsByTagName("Relationship")
dim r
for each r in rels
dim first,second
first = cstr(r.attributes.getNamedItem("first").nodeValue)
second = cstr(r.attributes.getNamedItem("second").nodeValue)
if not mapent.exists(first) then output "cannot find " + first
if mapent.exists(first) and mapent.exists(second) then
dim cf,cs
set cf = mapent.item(first)
set cs = mapent.item(second)
dim a : set a = model.associations.createnew
'TOOD check direction...
set a.object1 = cf
set a.object2 = cs
end if
next
diagram.completelinks
diagram.autolayout

相关内容

  • 没有找到相关文章

最新更新