0

I tried doing in but I get a blank project in return. When I select a DBMS to be JSON, thats when I get a blank. I dont know if theres another way around it?

skipa
  • 1
  • 1
  • 1
    I don't think the JSON DBMS definition supports reverse engineering. There is no comment at the beginning, but I guess it's only used for generation. – pascal Mar 30 '21 at 18:53
  • So there is no way of reverse engineering the JSON in PowerDesigner? If there is, do please let me know. – skipa Apr 01 '21 at 05:34
  • I don't know a way of doing it directly with PowerDesigner, right out of the box. You can write some JavaScript to read the contents of this JSON, and create a Physical Data Model, or an XML Model, through Automation API though... – pascal Apr 01 '21 at 10:56
  • Sounds interesting, how can i do it? can you direct me to a tutorial or instructions to do so please? – skipa Apr 02 '21 at 11:37

1 Answers1

0

It does not directly answer the question, but here is an example of scripting PowerDesigner from JavaScript (tested with NodeJS 14, NPM 7). You can then parse your JSON with JavaScript, and create objects (entities, tables...) on the fly through Automation.

"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");
pascal
  • 3,287
  • 1
  • 17
  • 35