It's all about the answers!

Ask a question

List of all categories


Robert Siara (821014) | asked Jan 09 '13, 12:33 p.m.
 Hi,

I have a simple question: how to get a list of all the categories using the JAVA PLAIN API?

 I will be very grateful for help 

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Jan 10 '13, 2:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Robert,

the code to get the categories of a given project are looks as below:
	/**
	 * Print the Categories for a given Project Area
	 * 
	 * @param teamRepository
	 * @param projectArea
	 * @param monitor
	 * @throws TeamRepositoryException
	 */
	private static void printProjectAreaCategories(ITeamRepository teamRepository,
			IProjectArea projectArea, IProgressMonitor monitor) throws TeamRepositoryException {
		IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
		List categories = workItemClient.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
		System.out.println("Categories of Project Area:");
		for (ICategory iCategory : categories) {
			System.out.println("\tID:" + iCategory.getCategoryId() + "\tName" + iCategory.getName()); 
		}	
	}

If you have an arbitrary process area (project area/team area) this gives you the associated categories, as far as I can tell.
	/**
	 * Print the Categories for a given Process Area
	 * 
	 * @param teamRepository
	 * @param processArea
	 * @param monitor
	 * @throws TeamRepositoryException
	 */
	private static void printProcessAreaCategories(ITeamRepository teamRepository,
			IProcessArea processArea, IProgressMonitor monitor) throws TeamRepositoryException {
		IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
		List categories = workItemClient.findCategoriesOfProcessArea(processArea, ICategory.FULL_PROFILE, monitor);
		System.out.println("Categories of Process Area:");
		for (ICategory iCategory : categories) {
			System.out.println("\tID:" + iCategory.getCategoryId() + "\tName" + iCategory.getName()); 
		}	
	}

Your answer


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