It's all about the answers!

Ask a question

How to get Team Area of a WorkItem [using multiple timelines] in Plain Java API

Lukas Steiger (3131625) | asked Feb 04 '14, 4:58 a.m.
edited Feb 05 '14, 2:12 a.m.
I need to export work item information. I am able to export everything of a workitem except the calculated team area. I tried to calculate the teamarea by myself, but I stuck with the implementation of it.

Is there anyone who did this before or who can point me out how to do this?
Any tip is highly appreciated. 

I was successful getting all team areas of a category. But I don't know how to get further on as I have multiple timelines where another team area is associated to the same category
As you see in the example below, the Category "Test Category" is associated to the Project Area by default on the "Main Development" Timeline. As soon as I switch the timeline to "Timeline 1", the category is associated to the team "Team 1", the same for "Timeline 2" with "Team 2"

My current source:
// get the workitem's associated category
ICategoryHandle cat = myCurrentWorkItem.getCategory();
ICategory category = (ICategory) teamRepository.itemManager().fetchCompleteItem(cat, IItemManager.REFRESH, monitor);"category name: " +category.getName());
// get all team areas associated to the above category
List<ITeamAreaHandle> tAreas = category.getAssociatedTeamAreas();
for(ITeamAreaHandle tArea : tAreas) {
ITeamArea teamArea = (ITeamArea) teamRepository.itemManager().fetchCompleteItem(tArea, IItemManager.REFRESH, monitor);"team area: " + teamArea.getName());
// check whether default team area is useful
ITeamAreaHandle teamAreaHandle = category.getDefaultTeamArea();
ITeamArea defaultTeamArea = (ITeamArea) teamRepository.itemManager().fetchCompleteItem(teamAreaHandle, IItemManager.REFRESH, monitor);"default team area: " + defaultTeamArea.getName());

2 answers

permanent link
Lukas Steiger (3131625) | answered Feb 07 '14, 3:55 a.m.
 I have finally managed to find this out by myself. Here's the solution:

IWorkItem myWorkItem = ...;
IWorkItemCommon workItemCommon = (IWorkItemCommon) teamRepository.getClientLibrary(IWorkItemCommon.class);
IProcessAreaHandle processAreaHandle = workItemCommon.findProcessArea(myWorkItem, null);
IProcessArea processArea = (IProcessArea) teamRepository.itemManager().fetchCompleteItem(processAreaHandle, IItemManager.REFRESH, monitor);
String teamAreaName = processArea.getName();

permanent link
Kevin Ramer (4.5k8178197) | answered Feb 04 '14, 11:07 a.m.
edited Feb 04 '14, 3:00 p.m.
You can get the information from the work item category.   For example, given a connection the list of categories can be had:

            List<ICategory> findCategories = service.findCategories(
                    projectArea, ICategory.FULL_PROFILE,

You can get the category attribute from a IWorkItem workItem.getCategory().  Given the category you can use the getDefaultTeamArea() or getAssociatedTeamAreas().  However the workItem.getCategory() return might have to be cast or otherwise retrieved.

Lukas Steiger commented Feb 05 '14, 2:04 a.m.

 I have tried a similar approach as you (see my edited question above). But I have troubles if I have multiple timelines where the team area is different between the timelines

Your answer

Register or to post your answer.