}
public List<CaseInstanceDto> queryCaseInstances(CaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
CaseInstanceQuery query = queryDto.toQuery(engine);
List<CaseInstance> matchingInstances;
if (firstResult != null || maxResults != null) {
matchingInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingInstances = query.list();
}
List<CaseInstanceDto> instanceResults = new ArrayList<CaseInstanceDto>();
for (CaseInstance instance : matchingInstances) {
CaseInstanceDto resultInstance = CaseInstanceDto.fromCaseInstance(instance);