cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the parent of a Folder using SOA calls

Hello,

I am trying to get the list of parents up to the "Home Folder" of a given folder,  getting the list of 'all' Relationships including the target folder seems overkill to me. Could anyone provide a code snippet using ITK calls (if needed).

 

I have also tried inspecting the properties of the original folder Model Object and getting information about the parent, but in the uid field of the parent I get the type of it instead of its real UID :/ .

 

The code:

 

ModelObject fmo = _session.getConnection().getWebServicesMgr().
getModelObjectFromUID(folderId);

List<String> result = new ArrayList<>();

String parentName = fmo.getTypeObject().getParent().getName();
String parentUID = fmo.getTypeObject().getParent().getUid();
System.out.println("Parent folder Name:"+parentName);
System.out.println("Parent folder UID:"+parentUID);

 

 

Produces the 'wrong' output:

 

Parent folder Name:Folder
Parent folder UID:TYPE::Folder::Folder::WorkspaceObject

 

Thank you.

13 REPLIES

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom
Use of getTypeObject() seems to return the "Type" of object i.e. "Folder" in this case. Correct steps according to me would be
1. Write a function with "fmo" as input parameter which will get all references of type "Folder" and related with "content" relation using ExpandGRMRelation. This will give you the parent folder
2. call the above function recursively till you get no folder or home folder in return.

Re: Getting the parent of a Folder using SOA calls

"content" relation is literally written that way?

In the document 'Basic Customization Concepts' the base types of relations are:

- IMAN_master_form

- IMAN_requirement

- IMAN_manifestation

- IMAN_specification

- IMAN_reference

- IMAN_revision

- BOMView

- BOMView Revision

 

I was actually trying with "IMAN_reference"  and "IMAN_specification" but not getting the results:

 

ExpandGRMRelationsPref2 pref = new ExpandGRMRelationsPref2();
pref.info = new RelationAndTypesFilter[1];
pref.info[0] = new RelationAndTypesFilter();
pref.info[0].otherSideObjectTypes = parentTypes;
pref.info[0].relationTypeName = "IMAN_referenced";
ExpandGRMRelationsResponse2 orelated =
dmserv.expandGRMRelationsForSecondary(descendantMOs, pref);

 

Should I try the same with pref.info[0].relationTypeName = "content" ?

 

Thank you.

 

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom

You can try with "contents" as shown in screenshot (I typed wrongly in my last post)

 

 

 contents.jpg

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom

found a much simpler way. Create a query as shown in picture and use "ExecuteSavedQuery" API to get parent folder. OR  to avoid SavedQuery, use "ExecuteBusinessObjectQueries" and provide following criteria as input

 

 

 

 

ParentFolderQuery.jpg

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom
the object_name (Name) in above query should be name of folder represented by "fmo"

Re: Getting the parent of a Folder using SOA calls

I tried almost all IMAN_* shown on BMIDE for COTS objects and none of them reported any object. I would prefer to avoid using the query method as basically I would like to fix an existing code that should perform the basic task of getting all relations of a given type to a given object and hence obtain a general way for me to inspect a tree from bottom to top. 

 

"contents"  generated an error:

Error Val.: The relation type name is invalid.

 

I also tried IMAN_CCContents, that returned an empty array of objects, being that the general response to all tested IMAN types.

 

Any suggestion? Thanks a lot for your help.

 

 

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom

Try DataManagementService.WhereReferenced() Method. You will get all objects where input folder is referenced. you can filter the output objects with "Folder" type.

 

 

Re: Getting the parent of a Folder using SOA calls

Thank you xplm2005,

 

WhereReferenced is working like a charm, but it is reporting "" for the relation type info:

 

 

for (DataManagement.WhereReferencedOutput ref : rfr.output)
{
System.out.println("Referenced:" + ref.inputObject.getUid());
for (DataManagement.WhereReferencedInfo info : ref.info)
{
System.out.println("\tReferencer:");
System.out.println("\t\tlevel:" + info.level);
System.out.println("\t\tuid:" + info.referencer.getUid());
System.out.println("\tType of Reference:" + info.relation);
}
}

 

Indicates that no info.relation name is present:

Referenced:ClAAAARsILd6BD
Referencer:
level:1
uid:AkBAAAAYILd6BD
Type of Reference:

Could this be related to a policy? without that field information I cannot filter the type of the reference :/

 

 

 

Re: Getting the parent of a Folder using SOA calls

Phenom
Phenom

Not sure why this is not working, but I dont think this is related to property policy.

 

you can try filtering output ModelObject i.e. Referencer to check if it is of type Folder. If yes, find value of property "contents" (here property policy is needed) and make sure that the value of contents is the referenced object i.e. input.