Fetching also sub-categories from a project area
Hi Everyone,
I saw several examples demonstrating how to fetch available categories from RTC project area.
Problem is, the fetched categories are only the ones that are positioned as root categories - their children sub categories aren't fetched along with them.
I haven't noticed any way of doing that using the latest 2.0 SDK and the pure java API... If anyone is familiar with such a way, I would be thankful.
Best,
Lior
I saw several examples demonstrating how to fetch available categories from RTC project area.
Problem is, the fetched categories are only the ones that are positioned as root categories - their children sub categories aren't fetched along with them.
I haven't noticed any way of doing that using the latest 2.0 SDK and the pure java API... If anyone is familiar with such a way, I would be thankful.
Best,
Lior
One answer
Hi Mr.Lior Zimmerman,
There are no apis available for fetching sub categories for a given project area. Nevertheless, for a given category, we can fetch all its immediate sub categories.
1 public void getImmediateSubCategories(ICategory iCategory,
2 IProjectArea iProjectArea) throws TeamRepositoryException {
3
4 //initialise the workitem client
5 IWorkItemClient workItemClient = (IWorkItemClient) repo
6 .getClientLibrary(IWorkItemClient.class);
7
8 //get all categories of a given project area
9 List<ICategory> categories = workItemClient.findCategories(
10 iProjectArea, ICategory.FULL_PROFILE, monitor);
11
12 //printing all the immediate sub categories for the given category
13 for (ICategory iCategoryChild : categories) {
14 if (iCategoryChild.getParentId().equals(iCategory.getCategoryId())) {
15 System.out.println(iCategoryChild.getName());
16 }
17 }
}
Using this method, we can find all the sub categories of root categories and recursively all of them.
Note to be noted: API used in line 9 will fetch the categories which are active i.e unarchived. we cannot obtain archived categories using the same. I'm yet to find a way to list all archived categories.
Hope this suffice your query.
There are no apis available for fetching sub categories for a given project area. Nevertheless, for a given category, we can fetch all its immediate sub categories.
1 public void getImmediateSubCategories(ICategory iCategory,
2 IProjectArea iProjectArea) throws TeamRepositoryException {
3
4 //initialise the workitem client
5 IWorkItemClient workItemClient = (IWorkItemClient) repo
6 .getClientLibrary(IWorkItemClient.class);
7
8 //get all categories of a given project area
9 List<ICategory> categories = workItemClient.findCategories(
10 iProjectArea, ICategory.FULL_PROFILE, monitor);
11
12 //printing all the immediate sub categories for the given category
13 for (ICategory iCategoryChild : categories) {
14 if (iCategoryChild.getParentId().equals(iCategory.getCategoryId())) {
15 System.out.println(iCategoryChild.getName());
16 }
17 }
}
Using this method, we can find all the sub categories of root categories and recursively all of them.
Note to be noted: API used in line 9 will fetch the categories which are active i.e unarchived. we cannot obtain archived categories using the same. I'm yet to find a way to list all archived categories.
Hope this suffice your query.