我一直试图使用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() )
有人可以建议一个潜入存储库的好方法吗?我已经确认我有一个与回购的连接,然后列出那个顶级的孩子。我正在努力挖掘超出根级别的文件夹。谢谢!
答案 0 :(得分:0)
我知道我想要从回购中删除的模型已经存在于我的本地工作区中。真的,这是对本地工作空间模型的刷新。要执行此操作,可以使用方法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;
}
答案 1 :(得分:0)
您的主要问题是搜索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