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

Query for work items in just one ProjectArea

I have code to query for work items in a particular project area, but it's returning work items in ALL the project areas in the repository (or maybe it's in my workspace--for now those are the same). The method takes the IProjectArea as a parameter, so I'm surprised that it doesn't limit the results to that project. What's the right code to get just the work items in a single project?

Here's my current code. The important line (I think) is the last line just before the return that does the query and passes the IProjectArea:

private IQueryResult<IResolvedResult<IWorkItem>> findWorkItemsByType(ITeamRepository repo,
IProjectArea project,
String typeName,
ItemProfile<IWorkItem> theProfile)
throws TeamRepositoryException {
//get needed libraries
IQueryClient queryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class);
IAuditableClient auditableClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
IQueryableAttributeFactory attFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute typeAttribute =
attFactory.findAttribute(project, IWorkItem.TYPE_PROPERTY, auditableClient, null);
Expression expression= new AttributeExpression(typeAttribute, AttributeOperation.EQUALS, typeName);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(project,
expression, theProfile);
return result;
}

0 votes



2 answers

Permanent link
I have code to query for work items in a particular project area, but
it's returning work items in ALL the project areas in the repository
(or maybe it's in my workspace--for now those are the same). The
method takes the IProjectArea as a parameter, so I'm surprised that
it doesn't limit the results to that project. What's the right code
to get just the work items in a single project?

The project area condition is not automatically added. While this API is
typically used for work item queries, it is not fundamentally limited to
work items, so the correct project area attribute (if there is any) is
not known automatically.

To restrict the results, add a project area condition:

....
Expression expression= new AttributeExpression(typeAttribute,
AttributeOperation.EQUALS, typeName);

IQueryableAttribute projectAreaAttribute= findAttribute(projectArea,
IWorkItem.PROJECT_AREA_PROPERTY, monitor);
AttributeExpression projectAreaExpression= new
AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS,
projectArea);

Term term= new Term(Operator.AND);
term.add(projectAreaExpression);
term.add(expression);

You may be interested in some new documentation that is available on the
Wiki: https://jazz.net/wiki/bin/view/Main/QueryDevGuide
It is still a draft, but you may find it useful already.

Regards,
Patrick,
Jazz Work Item Team

0 votes


Permanent link
Hi all.

How much custom attributes could I create by work item or project area?
Thanks.

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: Jun 12 '08, 11:56 a.m.

Question was seen: 7,080 times

Last updated: Jun 12 '08, 11:56 a.m.

Confirmation Cancel Confirm