skipa
skipa

Reputation: 1

Can I do a reverse engineering on a PowerDesigner using JSON schema and not XML?

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?

Upvotes: 0

Views: 545

Answers (1)

pascal
pascal

Reputation: 3365

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");

Upvotes: 0

Related Questions