我一直试图使用COM API直接从PowerDesigner存储库中获取实时模型,但没有成功。 这是我在 VBA 中一直在尝试的内容:
Set pd = CreateObject("PowerDesigner.Application")
Set conn = pd.RepositoryConnection
conn.Open "", "", "ShhMahPW"
Set model = conn.FindChildByPath("Program/Project/Logical Models/MahLOM", PdOOM_Classes.cls_Model)
MsgBox model.ShortDescription 'This fails because model is null!
同样,我一直在Eclipse中使用Java COM桥尝试同样的事情:
Application pd = this.getApplicationHook();
//Make live connection to proxy repository
RepositoryConnection conn = new RepositoryConnection( pd.GetRepositoryConnection() );
conn.Open( "", "", ConnectionParams.PASSWORD );
BaseObject model = conn.FindChildByPath( "Program/Project/Logical Models/MahLOM",
PdOOM_Classes.cls_Model );
//Null model, COMException: "Action can not be performed. result = -2147467259"
System.out.println( model.GetShortDescription() )
有人可以建议一种潜入存储库的好方法吗? 我已经能够确认我与存储库有连接,然后在该顶级列出子项。 我正在努力挖掘根级别以外的文件夹。 谢谢!
我要从存储库中提取的模型已经存在于我的本地工作区中。 实际上,这是对本地工作区模型的更新。 为此,可以使用UpdateFromRepository()
的方法!
因此,我能做的就是获取本地PowerDesigner模型的句柄,然后在检索子项之前调用更新。 请注意从BaseObject
到BaseModel
的转换,以便刷新...
private BaseObject getModel(){
Application pd = this.getApplicationHook();
model = pd.OpenModel(this.basePath + this.modelName);
System.out.println( "Retrieving model updates from repository... ");
RepositoryConnection conn = new RepositoryConnection( pd.GetRepositoryConnection() );
conn.Open( "", "", ConnectionParams.PASSWORD);
boolean success = new BaseModel(model).UpdateFromRepository();
if( success )
System.out.println( "Update successful!" );
else
System.out.println( "Update failed. Check PowerDesigner settings." );
return this.model;
}
您的主要问题是搜索ChildKind
应该是 Cls_RepositoryModel
,而不是PdOOM_Class.cls_Model
。
option explicit
' assuming we're already connected
if RepositoryConnection.Connected then
Descent RepositoryConnection,""
end if
dim c
set c = RepositoryConnection.FindChildByPath("Folder_7/ConceptualDataModel_1", Cls_RepositoryModel)
if not c is nothing then
output "*** found object " & c.classname
end if
sub Descent(obj,ofs)
output ofs & obj.name & " - " & obj.ObjectType & " - " & obj.ClassName
if obj.ObjectType = "RepositoryModel" then exit sub
if obj.PermanentID = 3 then exit sub ' to save time, don't enter Library
if not obj.HasCollection("ChildObjects") then exit sub
dim c
for each c in obj.ChildObjects
Descent c,ofs & " "
next
end sub