ERD файлы из Common Data Model - как открыть? Erwin / PowerDesigner? - PullRequest
0 голосов
/ 30 апреля 2020

Я пытаюсь получить доступ к файлам ERD здесь: https://github.com/microsoft/Industry-Accelerator-Health/tree/master/documentation

Теперь я бы предпочел использовать такой инструмент, как PowerDesigner / Erwin, чтобы реально увидеть физическую структуру. Любые предложения будут оценены.

1 Ответ

0 голосов
/ 30 апреля 2020

Вот скрипт, который берет такую ​​модель 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
...