如何打开通用数据模型的ERD文件?Erwin PowerDesigner?

问题描述 投票:0回答:1

我试图访问这里的ERD文件。https:/github.commicrosoftIndustry-Accelerator-Healthtreemasterdocumentation。

现在,我更希望使用像PowerDesigner Erwin这样的工具来实际查看物理结构。 任何建议都将被感激。

erd datamodel powerdesigner erwin
1个回答
0
投票

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

要运行在 Tools > Execute Commands > Edit/Run Script 在PowerDesigner内。

option explicit
' load XML document
dim doc : set doc = CreateObject("MSXML2.DOMDocument")
doc.load("C:\TEMP\Dynamics.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
© www.soinside.com 2019 - 2024. All rights reserved.