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

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

0 votes



4 answers

Permanent link
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

0 votes

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.


Permanent link
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.


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

0 votes


Permanent link
results = queryClient.getResolvedExpressionResults(projectArea, (Expression) queryRefgterm, IWorkItem.FULL_PROFILE);

results = queryClient.getResolvedExpressionResults(projectArea, statement, IWorkItem.FULL_PROFILE);

--
Regards,
Huanfeng,Cai

0 votes


Permanent link
results = queryClient.getResolvedExpressionResults(projectArea, (Expression) queryRefgterm, IWorkItem.FULL_PROFILE);

results = queryClient.getResolvedExpressionResults(projectArea, statement, IWorkItem.FULL_PROFILE);

--
Regards,
Huanfeng,Cai

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

Question asked: Mar 10 '09, 6:43 p.m.

Question was seen: 7,949 times

Last updated: Mar 28 '19, 5:09 a.m.

Confirmation Cancel Confirm