It's all about the answers!

Ask a question

How to get 1000+ (all) workitems of project area ?


Kartik Gajjar (112) | asked Nov 09 '10, 10:51 a.m.
retagged Nov 13 '12, 11:10 a.m. by Morten Madsen (3052842)
- the project area has 1000+ work items

- following code returns me work item of the project area, however it stops at 1000 count.

How do I get all the work item of project area ?




private static IQueryResult<IResolvedResult<IWorkItem>> queryForWI(String tag, ITeamRepository teamRepository, String projectAreaName)
throws TeamRepositoryException {
IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IQueryClient queryClient= (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
//IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);

URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
if (projectArea == null) {
throw new ItemNotFoundException(NLS.bind("Project area {0} not found", projectAreaName));
}

Term term= new Term(Operator.AND);
SortCriteria[] sortCriteria= new SortCriteria[] { new SortCriteria(IWorkItem.ID_PROPERTY, true) };
Statement statement = new Statement(new SelectClause(), (Expression) term, sortCriteria);

return queryClient.getResolvedExpressionResults(projectArea, (Expression) term, IWorkItem.FULL_PROFILE);
}

7 answers



permanent link
Tamir Klinger (91165) | answered Mar 13 '12, 4:48 p.m.
JAZZ DEVELOPER
Hi,

I had to make sure to use

results.setLimit(Integer.MAX_VALUE-1); // First thing to do!!!!!!

as the very first thing to do with the resultset. I assume later the iterators are already set up with a linit and that does not change anymore.


Thanks. Not sure what I was doing wrong -- I definitely wasn't iterating before I set the limit -- but setting it immediately after getting it seems to have done the trick.

Best,
Tim

permanent link
Tamir Klinger (91165) | answered Mar 12 '12, 2:24 p.m.
JAZZ DEVELOPER
- the project area has 1000+ work items

- following code returns me work item of the project area, however it
stops at 1000 count.

How do I get all the work item of project area ?

You can set the limit for a query on IQueryResult (before iterating over
the results):

Instead of

return queryClient.getResolvedExpressionResults(projectArea,
(Expression) term, IWorkItem.FULL_PROFILE);

You could write

IQueryResult result= queryClient.getResolvedExpressionResults(projectArea,
(Expression) term, IWorkItem.FULL_PROFILE);

result.setLimit(5000);

return result;

--
Regards,
Patrick
RTC Work Item Component Lead

Hi Patrick,

Picking up on this old thread. I'm trying to do this with v2 of the API and it doesn't seem to be working. Is there something I have to do to iterate other than:

result.setLimit(totalSize);

for (int i = 1; result.hasNext(null); i++) {


where totalSize is the total number of workitems?

Thanks,
Tim

permanent link
Mike Shkolnik (9657160143) | answered Jun 30 '11, 8:33 p.m.
Having updated the property, there is no effect. Does this require a server side reboot?


I have the same problem. Were you able to get this resolved?

permanent link
David Doughty (1812119) | answered May 11 '11, 9:52 a.m.
I can't tell you how to get all the work items from a query, but it is controlled by a property on the server. From the server admin web page, select "Advanced Properties" and search for 1000. You will eventually come to the property for max query result size (it is "Maximum Query Result Set Size" in 3.0). The tool tip seems to indicate that the result set size could be set for the individual query itself.


Having updated the property, there is no effect.


Does this require a server side reboot?

permanent link
Patrick Streule (4.9k21) | answered Nov 10 '10, 4:53 a.m.
JAZZ DEVELOPER
- the project area has 1000+ work items

- following code returns me work item of the project area, however it
stops at 1000 count.

How do I get all the work item of project area ?

You can set the limit for a query on IQueryResult (before iterating over
the results):

Instead of

return queryClient.getResolvedExpressionResults(projectArea,
(Expression) term, IWorkItem.FULL_PROFILE);

You could write

IQueryResult result= queryClient.getResolvedExpressionResults(projectArea,
(Expression) term, IWorkItem.FULL_PROFILE);

result.setLimit(5000);

return result;

--
Regards,
Patrick
RTC Work Item Component Lead

permanent link
Kirk Woods (8158) | answered Nov 09 '10, 3:37 p.m.
I can't tell you how to get all the work items from a query, but it is controlled by a property on the server. From the server admin web page, select "Advanced Properties" and search for 1000. You will eventually come to the property for max query result size (it is "Maximum Query Result Set Size" in 3.0). The tool tip seems to indicate that the result set size could be set for the individual query itself.

- the project area has 1000+ work items

- following code returns me work item of the project area, however it stops at 1000 count.

How do I get all the work item of project area ?


permanent link
Ralph Schoon (59.0k23642) | answered Mar 13 '12, 8:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

I had to make sure to use

results.setLimit(Integer.MAX_VALUE-1); // First thing to do!!!!!!

as the very first thing to do with the resultset. I assume later the iterators are already set up with a linit and that does not change anymore.

Your answer


Register or to post your answer.