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

Querying Work Items based on IWorkItemType

Hi,

I want to query the Work items based on certain work item types along with other conditions. Since more than one workitem types I want to check, I used AttributeOperation.MATCHES in the expression and it doesn't seem to work. At the same time, if I use AttributeOperation.EQUALS, it works. I understand matches operation internally does an equals operation on every object in the supplied Collection. Given below is the code snippet.


IQueryableAttribute workItemTypeAttribute = factory.findAttribute(
projectArea, IWorkItem.TYPE_PROPERTY, getAuditableClient(),
monitor);

// This returns all 'task' type workitems.
AttributeExpression workItemTypeExpression = new AttributeExpression(
workItemTypeAttribute, AttributeOperation.EQUALS, "task");

// This doesn't return any workitems.
List<String> workItemTypes = new ArrayList<String>();
workItemTypes.add("task");
workItemTypes.add("defect");
AttributeExpression workItemTypeExpression = new AttributeExpression(
workItemTypeAttribute, AttributeOperation.MATCHES, workItemTypes);


Please correct me if I'm wrong and help me out.

Thanks and regards,
Sethu

0 votes



2 answers

Permanent link
// This doesn't return any workitems.
List<String> workItemTypes = new
ArrayList<String>();
workItemTypes.add("task");
workItemTypes.add("defect");
AttributeExpression workItemTypeExpression = new
AttributeExpression(
workItemTypeAttribute, AttributeOperation.MATCHES,
workItemTypes);

MATCHES is the same as EQUALS and exists only for backward compatibility
reasons.

Your statement looks ok to me (although using EQUALS would be recommended).

Alternatively, you can OR the different values explicitly:

AttributeExpression defectExpression = new
AttributeExpression(workItemTypeAttribute, AttributeOperation.EQUALS,
"defect");
AttributeExpression taskExpression = new
AttributeExpression(workItemTypeAttribute, AttributeOperation.EQUALS,
"task");

Term term= new Term(Operator.OR);
term.add(defectExpression);
term.add(taskExpression);

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
Thanks very much Patrick.

Since my workitem types are known only at run time, I'm creating and adding attribute expressions to an OR Term in a loop. It works.

Regards,
Sethu

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,936

Question asked: Oct 12 '09, 1:43 a.m.

Question was seen: 6,733 times

Last updated: Oct 12 '09, 1:43 a.m.

Confirmation Cancel Confirm