我可以使用 JSON 模式而不是 XML 对 PowerDesigner 进行逆向工程吗?

问题描述

我尝试过,但我得到了一个空白项目作为回报。 当我选择一个 DBMS 为 JSON 时,那是我得到一个空白的时候。 不知道有没有别的办法?

解决方法

它没有直接回答问题,但这里有一个从 JavaScript 编写 PowerDesigner 脚本的示例(使用 NodeJS 14、NPM 7 测试)。然后,您可以使用 JavaScript 解析您的 JSON,并通过自动化动态创建对象(实体、表...)。

"use strict";
// you can get these constants with a VBScript like this:
// option explicit
// dim lib,libname,cls,keep,x
// for each lib in application.metamodel.libraries
//    libname = lcase(lib.publicname)
//    if left(libname,2) = "pd" then libname = mid(libname,3)
//    for each cls in lib.classes
//       keep = cls.inheritsfrom(cls_NamedObject)
//       if keep and cls.inheritsfrom(cls_BaseClassifierMapping) then keep = false 
//       if keep and cls.abstract then keep = false
//       if keep and ((cls.flags and 1024) <> 0) then keep = false
//       if keep then
//          x = right("00000000" & hex(cls.kind),8)
//          output "const cls_"&libname&cls.publicname & " = 0x" & x & ";"
//       end if
//    next
// next
const cls_cdmModel = 0x1E597170;
const cls_cdmEntity = 0x1E597172;

console.log("... connecting");
let winax = require('winax');
let app = new ActiveXObject("PowerDesigner.Application");
console.log("... create model");
let model = app.CreateModel(cls_cdmModel);
let entt = model.CreateObject(cls_cdmEntity);
entt.Name = 'foo';
console.log("... save model");
model.Save('c:\\temp\\foo.cdm');
winax.release(model,entt);
// close Workspace without saving
app.ActiveWorkspace.Close(1);
winax.release(app);
console.log("... happily done");