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.?
Accepted answer
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; }