It's all about the answers!

Ask a question

List parents and children relationship


marcos fukaya (61) | asked Jun 10 '10, 7:32 a.m.
Hi fellows,

I am building an app that lists assets and their relationships (belongs to,
has).

Here is a part of code:

RAMAssetQueryBuilder query;

query.addQueryField(query.QUERY_FIELD_NAME, "*");
query.addQueryField(query.QUERY_FIELD_VERSION, "*");


RAMCommunity com = session.getCommunity("Services");
query.addSearchFilter(com);

SearchResult result = session.getAssets(query);
RAMAssetSearchResult[] serviceAssets = (RAMAssetSearchResult)result.getAssetSearchResults();


This code will return me a list of assets.
But now I need to get asset relationships informations (parents, children). How to do this? I know there is a getRelationships() method for RAMAsset object, but the relationship returned do not give to me information about the related assets. I also know there is a getParentAsset() method for RAMRelationship object, but I cannot cast Relationship to RAMRelationship. How to get parents and children informations?



Thanks!!!

One answer



permanent link
Kevin Bauer (34621) | answered Jun 10 '10, 1:46 p.m.
JAZZ DEVELOPER
First

query.addQueryField(query.QUERY_FIELD_NAME, "*");
query.addQueryField(query.QUERY_FIELD_VERSION, "*");

is not adding anything you can just use the community filter in your search and get the same result.

Second

You can cast the Relationship you get back from getRelationships() to a RAMRelationship.

Your answer


Register or to post your answer.