RTC Plain Java API: How to get parent team areas / project area for an ITeamArea
Accepted answer
Comments
Hello Aradhya,
Thanks for this. Yes, I know about ITeamAreaHierachy but using it would mean to traverse through all team area hierachies (of the whole project area) and compare each team area against the given one for which I need the parents. That is probably not as efficient (with regard to runtime performance as well as lines of code) as if one could simply call ITeamArea.getParent() recursively.
There is ITeamArea.getContextId() (inherited from IItem). What does this mean, isn't that the parent team area, if so, how to get the instance from the id? Anyway, if I cannot find a bottom-up approach I will implement it top-down...
Kind regards and thanks
Martin Muellenberg
Just found the solution I was looking for:
1.) ITeamAreaHierarchy teamAreaHierachy = IProjectArea.getTeamAreaHierarchy()
2.) teamAreaHierachy.getParent(ITeamAreaHandle)
Thank you Aradhya for the hint. I have not expected the parent method there. I thought it would be somewhere in the ITeamArea...
This post shows a lot of the required API in a working example: https://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/
One other answer
Comments
You can not just cast an IProjectAreaHandle to an IProjectArea object, you have to look it up and resolve the handle like in my answer on the other post where you asked.
See http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ for some API hints and best practices. A lot of the practices are also true for the server API. Often there are server API's that are similar to the client API's. Also, please note,you can search the blog and Jazz.net or the internet for things like IProjectAreaHandle and the like and find additional information.