It's all about the answers!

Ask a question

RTC Plain Java API: How to get parent team areas / project area for an ITeamArea

Martin Muellenberg (7259) | asked Oct 23 '13, 10:50 a.m.
edited Oct 23 '13, 10:51 a.m.
Hello all,

I use the RTC Plain Java API in version 4.0.4 and need to get the parent team areas of a given ITeamArea until the top-level IProjectArea is discovered (I also need the name of the IProjectArea at the end). Is that possible?

Kind regards and thanks
Martin Muellenberg

Accepted answer

permanent link
Aradhya K (1.4k44345) | answered Oct 24 '13, 2:22 a.m.
ITeamArea has getProjectArea() to get the IProjectAreaHandle, resolving which will get you IProjectArea 
You can use IProjectArea.getTeamAreaHierarchy(); which will return you ITeamAreaHierarchy.
ITeamAreaHierarchy has a lot of methods to access the process area tree.
Martin Muellenberg selected this answer as the correct answer

Martin Muellenberg commented Oct 24 '13, 2:43 a.m.

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

Martin Muellenberg commented Oct 24 '13, 3:13 a.m. | edited Oct 24 '13, 3:14 a.m.

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...

Ralph Schoon commented Oct 24 '13, 4:51 a.m.

One other answer

permanent link
Surender Biyyala (402548) | answered Mar 10 '14, 9:44 a.m.
 Hi Aradhya,

Im using the following code to for one of my plugin to get the current iteration.

  IProjectAreaHandle iProjectAreaHandle = ((IProjectAreaHandle) workItem.getProjectArea());
                       IProjectArea iProjectArea = (IProjectArea)iProjectAreaHandle;
                        ITeamAreaHandle teamAreaHandle = null;
                      String teamAreaName =  ((String)workItem.getValue(categoryattribute));
                        for(ITeamAreaHandle iTeamAreaHandle : (List<ITeamAreaHandle>)iProjectArea.getTeamAreas()) {
                             if (iTeamAreaHandle.getItemType().getName().equalsIgnoreCase(teamAreaName)) {
                                teamAreaHandle = iTeamAreaHandle;
                        IDevelopmentLine dev = iac.getDevelopmentLine(teamAreaHandle, monitor);

but here Im getting a class cast exception .. Im a new bee for RTC API so bit confused of what to be used exactly to get what we want.. please correct me if Im wrong some where.


Ralph Schoon commented Mar 10 '14, 9:58 a.m. | edited Mar 10 '14, 9:59 a.m.

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 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 or the internet for things like IProjectAreaHandle and the like and find additional information.

Your answer

Register or to post your answer.