protected List<ProcessInstance> fetchProcessInstancesPage(CommandContext commandContext,
ProcessDefinition processDefinition, int currentPageStartIndex) {
if (SuspensionState.ACTIVE.equals(getProcessDefinitionSuspensionState())){
return new ProcessInstanceQueryImpl(commandContext)
.processDefinitionId(processDefinition.getId())
.suspended()
.listPage(currentPageStartIndex, commandContext.getProcessEngineConfiguration().getBatchSizeProcessInstances());
} else {
return new ProcessInstanceQueryImpl(commandContext)
.processDefinitionId(processDefinition.getId())
.active()
.listPage(currentPageStartIndex, commandContext.getProcessEngineConfiguration().getBatchSizeProcessInstances());
}
}