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

Is it possible to fetch ChangeSets greater than IWorkspaceManager.MAX_QUERY_SIZE using IChangeSetSearchCriteria

I am trying to fetch the Changesets within a date interval. There is MAX_QUERY_SIZE = 512. I am not able to fetch changesets above that limit. 

My search criteria will be returning more than 512 changesets. Is there any possible ways to fetch the remaining changesets using client java api.?

1

0 votes


Accepted answer

Permanent link
I don't think there is any way to override the MAX_QUERY_SIZE.

However, as the results are fetched in date order it is possible to run a batch of separate queries and combine the results. This appears to be how the Eclipse UI control works. (in com.ibm.team.internal.filesystem.ui.views.search.changeset.ChangeSetQuery)

This code worked for me (RTC 4.0.4), and was able to return 80000 results.

public static List<IChangeSetHandle> getAllChangeSets(
    final ITeamRepository repository,
    final IChangeSetSearchCriteria searchCriteria,
    final IProgressMonitor monitor, final int maxResults)
    throws TeamRepositoryException {
  int toFetch = maxResults;
  final List<IChangeSetHandle> result = new ArrayList<>(
      toFetch);

  final IWorkspaceManager mgr = SCMPlatform
      .getWorkspaceManager(repository);

  final IChangeSetSearchCriteria pagingCriteria = (IChangeSetSearchCriteria) EcoreUtil
      .copy((EObject) searchCriteria);

  List<IChangeSetHandle> findResult = mgr.findChangeSets(pagingCriteria,
      toFetch, monitor);
  result.addAll(findResult);

  while (toFetch > IWorkspaceManager.MAX_QUERY_SIZE
      && findResult.size() == IWorkspaceManager.MAX_QUERY_SIZE) {
    toFetch = toFetch - findResult.size();
    final IChangeSet lastChangeSet = (IChangeSet) repository
        .itemManager().fetchCompleteItem(
            result.get(result.size() - 1),
            IItemManager.DEFAULT, monitor);
    // update the modified before/after to get the remaining change sets
    if (pagingCriteria.isOldestFirst()) {
      pagingCriteria.setModifiedAfter(new Timestamp(lastChangeSet
          .getLastChangeDate().getTime()));
    } else {
      pagingCriteria.setModifiedBefore(new Timestamp(lastChangeSet
          .getLastChangeDate().getTime()));
    }

    findResult = mgr.findChangeSets(pagingCriteria, toFetch, monitor);
    result.addAll(findResult);
  }
  return result;
}
	
	

Reji GL selected this answer as the correct answer

4 votes

Comments

This solution works perfectly... thanks.. 

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
× 411
× 10

Question asked: Sep 26 '13, 5:34 p.m.

Question was seen: 5,406 times

Last updated: Oct 01 '13, 11:43 a.m.

Confirmation Cancel Confirm