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

Define RTC query term including workitem state

Hi,

I am trying to query a list of workitem base certain criteria:

term.add(projectAreaExpression);
term.add(workItemTypeExpression);
term.add(categoryExpression);

The query works fine until I try to add the filter of the workitem state.
The query returns null object. Could someone shed some light how to generate the query to look up list of workitem base on its state?

Thanks.



IQueryableAttribute stateAttribute = findAttribute(teamRepository, projectArea, IWorkItem.STATE_PROPERTY, monitor);
AttributeExpression workItemStateTypeExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "Open");
...

term.add(workItemStateTypeExpression);


Code snippet:

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


IQueryableAttribute categoryAttribute = findAttribute(teamRepository, projectArea, IWorkItem.CATEGORY_PROPERTY, monitor);
AttributeExpression categoryExpression = new AttributeExpression(categoryAttribute, AttributeOperation.EQUALS, category);


IQueryableAttribute workItemTypeAttribute = findAttribute(teamRepository, projectArea, IWorkItem.TYPE_PROPERTY, monitor);
AttributeExpression workItemTypeExpression = new AttributeExpression(workItemTypeAttribute, AttributeOperation.EQUALS, WorkItemType.getIdentifier());



IQueryableAttribute stateAttribute = findAttribute(teamRepository, projectArea, IWorkItem.STATE_PROPERTY, monitor);


AttributeExpression workItemStateTypeExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "Open");

/* //Owner is Kelvin Lui"
IQueryableAttribute ownerAttribute = findAttribute(teamRepository, projectArea, IWorkItem.OWNER_PROPERTY, monitor);
AttributeExpression ownerTypeExpression = new AttributeExpression(ownerAttribute, AttributeOperation.EQUALS, "Kelvin Lui" );

System.out.println(" ownerAttribute.getAttributeType()" + ownerAttribute.getAttributeType() + " "+
ownerAttribute.getDisplayName() + " " + ownerAttribute.getIdentifier());*/

/*//WorkItem ID
IQueryableAttribute idAttribute = findAttribute(teamRepository, projectArea, IWorkItem.ID_PROPERTY, monitor);
//AttributeExpression idExpression = new AttributeExpression(idAttribute, AttributeOperation.EQUALS, "57320" );
//new AttributeExpression(idAttribute, AttributeOperation.EQUALS, "57320" );
*/
//System.out.println("ownerTypeExpress: "+ownerTypeExpression.getValue()+ " "+ ownerTypeExpression.getAttributeIdentifier());

//Build the Query by doing an AND Operation among the 3 above sub-queries
Term term= new Term(Operator.AND);
term.add(projectAreaExpression);
term.add(workItemTypeExpression);
term.add(categoryExpression);
term.add(workItemStateTypeExpression);
//term.add(idExpression);

/* IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);

com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> result =
queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);

*/
// Evaluate Query

IQueryCommon queryService= getQueryCommon(teamRepository);
//ItemProfile<IWorkItem> profile= this.getProfile(projectAreaAttribute).createExtension(IWorkItem.CREATOR_PROPERTY);
this.getProfile(projectAreaAttribute).createExtension(IWorkItem.CREATOR_PROPERTY);
//IQueryResult<IResolvedResult<IWorkItem>> result= queryService.getResolvedExpressionResults(projectArea, term, profile);
IQueryResult<IResolvedResult<IWorkItem>> result= queryService.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);

//Add All Results in a list and return that list
List<IWorkItem> matchingWorkItems= new ArrayList<IWorkItem>(result.getResultSize(monitor).getTotalAvailable());
while (result.hasNext(monitor)) {
matchingWorkItems.add(result.next(monitor).getItem());
}

0 votes


Be the first one to answer this question!

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: Mar 26 '12, 1:07 p.m.

Question was seen: 4,759 times

Last updated: Mar 26 '12, 1:07 p.m.

Confirmation Cancel Confirm