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

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

0 votes



One answer

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


1 vote

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
× 10,938

Question asked: May 08 '11, 6:20 a.m.

Question was seen: 6,570 times

Last updated: May 22 '14, 2:46 a.m.

Confirmation Cancel Confirm