How to get Team Area of a WorkItem [using multiple timelines] in Plain Java API
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.
EDIT:
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 categoryICategoryHandle cat = myCurrentWorkItem.getCategory();ICategory category = (ICategory) teamRepository.itemManager().fetchCompleteItem(cat, IItemManager.REFRESH, monitor);logger.info("category name: " +category.getName());// get all team areas associated to the above categoryList<ITeamAreaHandle> tAreas = category.getAssociatedTeamAreas();for(ITeamAreaHandle tArea : tAreas) {ITeamArea teamArea = (ITeamArea) teamRepository.itemManager().fetchCompleteItem(tArea, IItemManager.REFRESH, monitor);logger.info("team area: " + teamArea.getName());}// check whether default team area is usefulITeamAreaHandle teamAreaHandle = category.getDefaultTeamArea();ITeamArea defaultTeamArea = (ITeamArea) teamRepository.itemManager().fetchCompleteItem(teamAreaHandle, IItemManager.REFRESH, monitor);logger.info("default team area: " + defaultTeamArea.getName());
2 answers
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();
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,
jazzServer.getMonitor());
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.
List<ICategory> findCategories = service.findCategories(
projectArea, ICategory.FULL_PROFILE,
jazzServer.getMonitor());
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.