Java 通过COM访问PowerDesigner存储库模型

Java 通过COM访问PowerDesigner存储库模型,java,vba,com,sybase,powerdesigner,Java,Vba,Com,Sybase,Powerdesigner,我一直在尝试使用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

我一直在尝试使用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\u RepositoryModel
,而不是
PdOOM\u Class.Cls\u 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