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

Query to get all the categories of currently loged in user.

I have the below method to get all the categories the current logged in user is associated with.
The query result does not returns any result.
Can you please help me in this

private IItemHandle[] getAssociatedCategories() throws Exception {
CategoryQueryModel catQueryModel = BaseCategoryQueryModel.CategoryQueryModel.ROOT;
IItemQuery catQuery = IItemQuery.FACTORY.newInstance(catQueryModel);
IPredicate contributorPredicate = catQueryModel.defaultTeamArea().contributors()._contains(catQuery.newItemHandleArg());
catQuery.filter(contributorPredicate);

List<IItemHandle> categoriesList = runQuery(catQuery, new Object[]{getAuthenticatedContributor()}, -1);
if (categoriesList == null || categoriesList.isEmpty()) {
throw new Exception("No Category found for the current user");
}
IItemHandle[] categories = new IItemHandle;
int i = 0;
for (Iterator<IItemHandle> iterator = categoriesList.iterator(); iterator.hasNext(); i++) {
IItemHandle catHandle = (IItemHandle) iterator.next();
System.out.println("category ID" + catHandle.getItemId());
categories = catHandle;
}
return categories;
}

Thanks
Aradhya

0 votes



One answer

Permanent link
I have the below method to get all the categories the current logged
in user is associated with.
The query result does not returns any result.

We currently don't expose this as API, but you could take a look at:

WorkItemQueries#categoriesByContributor(IAuditableCommon auditableCommon,
IContributorHandle contributor)

The query is basically:

CategoryQueryModel model= CategoryQueryModel.ROOT;
IItemQuery query= IItemQuery.FACTORY.newInstance(model);
IItemHandleInputArg contributorArg= query.newItemHandleArg();
query.filter(model.defaultTeamArea().contributors()._contains(contributorArg)._or(model.teamAreas().contributors()._contains(contributorArg)));


--
Regards,
Patrick
Jazz Work Item Team

0 votes

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: Jan 29 '09, 9:57 p.m.

Question was seen: 6,041 times

Last updated: Jan 29 '09, 9:57 p.m.

Confirmation Cancel Confirm