Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

1

0 votes


Accepted answer

Permanent link
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

2 votes

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


One other answer

Permanent link
 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);
                        dev.getCurrentIteration();


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.

Thanks
Surender

0 votes

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.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Oct 23 '13, 10:50 a.m.

Question was seen: 7,073 times

Last updated: Mar 10 '14, 9:59 a.m.

Confirmation Cancel Confirm