Indeed, the pagination parameters (startIndex, maxResults) are there to limit the number of results to retrieve at once.
The good practice is to loop on the searchArchivedFlowNodeInstances() to retrieve the next page of results each time, and to aggregate, on client-side, the results in one single list if necessary. Or even better, to treat the current page of result on the fly, and query the next page, without aggregating the results in one single list.
A code sample could something like:
I would improve it that way:
int min = 0;
int max = 1000;
List<ArchivedFlowNodeInstance> archListAll = new ArrayList<>();
List<ArchivedFlowNodeInstance> archList;
do {
archList =
processApi.searchArchivedFlowNodeInstances(getSearchOptions(min, max).done()).getResult();
archListAll.addAll(archList);
min += max;
} while (!archList.isEmpty());
Where getSearchOptions() method is just a way to build a SearchOptionBuilder with your specifiy search filters, and the pagination passed as parameter.
int min = 0;
int max = 1000;
int step = 1000;
List<ArchivedFlowNodeInstance> archListAll = new ArrayList<>();
while (true) {
SearchOptionsBuilder searchBuilder =
getSearchOptions(min, max, timeStartDateMillis, timeEndDateMillis);
List<ArchivedFlowNodeInstance> archList =
processApi.searchArchivedFlowNodeInstances(searchBuilder.done()).getResult();
if (archList.isEmpty()) {
break;
}
archListAll.addAll(archList);
min += step;
}
where getSearchOptions is a method that gives me the new searchBuilder with the min and max
int min = 0;
int max = 1000;
List<ArchivedFlowNodeInstance> archListAll = new ArrayList<>();
List<ArchivedFlowNodeInstance> archList;
do {
archList =
processApi.searchArchivedFlowNodeInstances(getSearchOptions(min, max, timeStartDateMillis, timeEndDateMillis).done()).getResult();
archListAll.addAll(archList);
min += max;
} while (!archList.isEmpty());
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.