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

How to query work-items with more than one status as condition via client API

We are aware we can query work-items on their single status as:
Identifier<IState> stateId = ...
IQueryableAttribute stateAttr = ...
AttributeExpression stateExpr = new AttributeExpression(stateAttr, AttributeOperation.EQUALS, state.getStringIdentifier());
	
	
or we can query work-items on their status group as:
IQueryableAttribute stateAttr = ...
AttributeExpression stateExpr = new VariableAttributeExpression(stateAttr, AttributeOperation.EQUALS, new StatusVariable(IWorkflowInfo.IN_PROGRESS_STATES));
but we would be able to query work-items for a set of status as condition:
Identifier<IState>[] stateIds = ...
IQueryableAttribute stateAttr = ...
AttributeExpression stateExpr = new VariableAttributeExpression(stateAttr, AttributeOperation.EQUALS, new StatusVariable(stateIds);
It seems to be pretty easy via UI: https://jazz.net/forum/questions/170377/how-to-build-complex-rtc-query-combining-and-or-conditions/170383
We tried to extend the com.ibm.team.workitem.common.expression.variables.StatusVariable class to achieve our desiderata, but then the override method IAttributeValue#evaluate was never call during the IQueryCommon#getResolvedExpressionResults execution.
Any advice? On QueryDevGuide we did not find any helpful example.
Thanks in advance.

0 votes



One answer

Permanent link
Well, at least the naïve solution is working:
Term subterm = new Term(Operator.OR);
for (Identifier<IState> stateId : stateIds) {
AttributeExpression stateExpr = new AttributeExpression(stateAttr, AttributeOperation.EQUALS, state.getStringIdentifier());
subterm.add(stateExpr);
}
Term term = new Term(Operator.AND);
term.add(subterm);
Cheers.

1 vote

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,937
× 201

Question asked: Sep 02 '15, 9:48 a.m.

Question was seen: 3,873 times

Last updated: Sep 02 '15, 10:57 a.m.

Confirmation Cancel Confirm