Querying for sorted list of "unresolved" work item
The RTC SDK article "Developer's Guide to Querying Work Items" provides most of the information necessary to query and view results. Is there a way to do the following programmatically:
- Query for "unresolved" work items. The Query Editor allows you to specify that the "Status" attribute is "unresolved" and/or "resolved"
- Sort the result set
- Query for "unresolved" work items. The Query Editor allows you to specify that the "Status" attribute is "unresolved" and/or "resolved"
- Sort the result set
4 answers
The RTC SDK article "Developer's Guide to Querying Work
Items" provides most of the information necessary to query and
view results. Is there a way to do the following programmatically:
- Query for "unresolved" work items. The Query Editor
allows you to specify that the "Status" attribute is
"unresolved" and/or "resolved"
- Sort the result set
Yes, both is possible:
For all the open states, you can add an expression like:
Expression openStates= new VariableAttributeExpression(stateAttribute,
AttributeOperation.EQUALS, new StatusVariable(IWorkflowInfo.OPEN_STATES));
For the sorting, you would create a statement like:
SortCriteria[] sortCriteria= new SortCriteria[] { new
SortCriteria(IWorkItem.ID_PROPERTY, ascending) };
Statement statement= new Statement(new SelectClause(), expression,
sortCriteria);
--
Regards,
Patrick
Jazz Work Item Team
Comments
For the sorting, you would create a statement like:
SortCriteria[] sortCriteria= new SortCriteria[] { new SortCriteria(IWorkItem.ID_PROPERTY, ascending) };
Statement statement= new Statement(new SelectClause(), expression, sortCriteria);
Or even more simple:
String[] sortColumns = { IWorkItem.ID_PROPERTY };
String[] sortDirections = { SortCriteria.ASCENDING };
Expression expression = QueryUtils.createSortedStatement(queryRefgterm, QueryUtils.createSortCriteria(sortColumns, sortDirections));
Cheers.
Hi,
For sorting I tried to use this way but it seems not work because I am doing something wrong.
What I want is to ordering by "MODIFIED_PROPERTY".
Can you help me and show me how to do this.
Thank you very much for your help.
Best Regards,
Tony
For sorting I tried to use this way but it seems not work because I am doing something wrong.
What I want is to ordering by "MODIFIED_PROPERTY".
Can you help me and show me how to do this.
projectAreaAttribute = factory.findAttribute(projectArea,
IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
timeStampAttribute = factory.findAttribute(projectArea,
IWorkItem.MODIFIED_PROPERTY, auditableClient, monitor);
queryRefgterm = new Term(Operator.AND);
projectAreaExpression = new AttributeExpression(
projectAreaAttribute, AttributeOperation.EQUALS,
projectArea);
modifiedFromExpression = new AttributeExpression(
timeStampAttribute, AttributeOperation.GREATER_PLAIN, time);
queryRefgterm.add(projectAreaExpression);
queryRefgterm.add(modifiedFromExpression);
SortCriteria[] sortCriteria= new SortCriteria[] { new SortCriteria(IWorkItem.MODIFIED_PROPERTY, true) };
Statement statement = new Statement(new SelectClause(), (Expression) queryRefgterm, sortCriteria);
results = queryClient.getResolvedExpressionResults(projectArea,
(Expression) queryRefgterm, IWorkItem.FULL_PROFILE);
while (results.hasNext(monitor) {
//
.....
}
Thank you very much for your help.
Best Regards,
Tony