It's all about the answers!

Ask a question

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


SEC Servizi (94622244) | asked Sep 02 '15, 9:48 a.m.
edited Sep 02 '15, 10:57 a.m.
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.

One answer



permanent link
SEC Servizi (94622244) | answered Sep 02 '15, 10:05 a.m.
edited Sep 02 '15, 10:55 a.m.
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.

Your answer


Register or to post your answer.