@Test public void readTasks1() { TaskDataReader.Result result = reader.readTasks(0, null, null, pageSize, null); verifyTasks(result.getTasks()); }
public Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode) { final List<TaskData> result = new ArrayList<>(); boolean finished = false; List<TaskData> partialResult; TaskDataList taskDataList; TaskData lastItem = null; LocalDateTime queryTime = null; long taskId = fromTaskId; int nextPageSize = pageSize; while (!finished) { taskDataList = runtimeClient.findTasks(taskId, status, fromLastModificationDate, 0, nextPageSize, taskInputVariablesReadMode); partialResult = new ArrayList<>(taskDataList.getItems()); if (queryTime == null) { queryTime = taskDataList.getQueryTime(); } if (partialResult.isEmpty()) { finished = true; } else { if (lastItem == null || partialResult.size() > 1) { lastItem = partialResult.remove(partialResult.size() - 1); taskId = lastItem.getTaskId(); nextPageSize = pageSize; result.addAll(partialResult); } else { if (lastItem.getTaskId().equals(partialResult.get(0).getTaskId())) { if (partialResult.get(0).getPotentialOwners().isEmpty()) { result.add(partialResult.get(0)); lastItem = null; taskId++; nextPageSize = pageSize; } else if (partialResult.get(0).getPotentialOwners().size() < nextPageSize) { result.add(partialResult.get(0)); finished = true; } else { nextPageSize = nextPageSize * 2; } } else { lastItem = partialResult.get(0); taskId = lastItem.getTaskId(); nextPageSize = pageSize; } } } } return new Result(queryTime, result); }
TaskDataReader { public Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode) { final List<TaskData> result = new ArrayList<>(); boolean finished = false; List<TaskData> partialResult; TaskDataList taskDataList; TaskData lastItem = null; LocalDateTime queryTime = null; long taskId = fromTaskId; int nextPageSize = pageSize; while (!finished) { taskDataList = runtimeClient.findTasks(taskId, status, fromLastModificationDate, 0, nextPageSize, taskInputVariablesReadMode); partialResult = new ArrayList<>(taskDataList.getItems()); if (queryTime == null) { queryTime = taskDataList.getQueryTime(); } if (partialResult.isEmpty()) { finished = true; } else { if (lastItem == null || partialResult.size() > 1) { lastItem = partialResult.remove(partialResult.size() - 1); taskId = lastItem.getTaskId(); nextPageSize = pageSize; result.addAll(partialResult); } else { if (lastItem.getTaskId().equals(partialResult.get(0).getTaskId())) { if (partialResult.get(0).getPotentialOwners().isEmpty()) { result.add(partialResult.get(0)); lastItem = null; taskId++; nextPageSize = pageSize; } else if (partialResult.get(0).getPotentialOwners().size() < nextPageSize) { result.add(partialResult.get(0)); finished = true; } else { nextPageSize = nextPageSize * 2; } } else { lastItem = partialResult.get(0); taskId = lastItem.getTaskId(); nextPageSize = pageSize; } } } } return new Result(queryTime, result); } }
TaskDataReader { public Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode) { final List<TaskData> result = new ArrayList<>(); boolean finished = false; List<TaskData> partialResult; TaskDataList taskDataList; TaskData lastItem = null; LocalDateTime queryTime = null; long taskId = fromTaskId; int nextPageSize = pageSize; while (!finished) { taskDataList = runtimeClient.findTasks(taskId, status, fromLastModificationDate, 0, nextPageSize, taskInputVariablesReadMode); partialResult = new ArrayList<>(taskDataList.getItems()); if (queryTime == null) { queryTime = taskDataList.getQueryTime(); } if (partialResult.isEmpty()) { finished = true; } else { if (lastItem == null || partialResult.size() > 1) { lastItem = partialResult.remove(partialResult.size() - 1); taskId = lastItem.getTaskId(); nextPageSize = pageSize; result.addAll(partialResult); } else { if (lastItem.getTaskId().equals(partialResult.get(0).getTaskId())) { if (partialResult.get(0).getPotentialOwners().isEmpty()) { result.add(partialResult.get(0)); lastItem = null; taskId++; nextPageSize = pageSize; } else if (partialResult.get(0).getPotentialOwners().size() < nextPageSize) { result.add(partialResult.get(0)); finished = true; } else { nextPageSize = nextPageSize * 2; } } else { lastItem = partialResult.get(0); taskId = lastItem.getTaskId(); nextPageSize = pageSize; } } } } return new Result(queryTime, result); } private  TaskDataReader(TaskAssigningRuntimeClient runtimeClient); }
TaskDataReader { public Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode) { final List<TaskData> result = new ArrayList<>(); boolean finished = false; List<TaskData> partialResult; TaskDataList taskDataList; TaskData lastItem = null; LocalDateTime queryTime = null; long taskId = fromTaskId; int nextPageSize = pageSize; while (!finished) { taskDataList = runtimeClient.findTasks(taskId, status, fromLastModificationDate, 0, nextPageSize, taskInputVariablesReadMode); partialResult = new ArrayList<>(taskDataList.getItems()); if (queryTime == null) { queryTime = taskDataList.getQueryTime(); } if (partialResult.isEmpty()) { finished = true; } else { if (lastItem == null || partialResult.size() > 1) { lastItem = partialResult.remove(partialResult.size() - 1); taskId = lastItem.getTaskId(); nextPageSize = pageSize; result.addAll(partialResult); } else { if (lastItem.getTaskId().equals(partialResult.get(0).getTaskId())) { if (partialResult.get(0).getPotentialOwners().isEmpty()) { result.add(partialResult.get(0)); lastItem = null; taskId++; nextPageSize = pageSize; } else if (partialResult.get(0).getPotentialOwners().size() < nextPageSize) { result.add(partialResult.get(0)); finished = true; } else { nextPageSize = nextPageSize * 2; } } else { lastItem = partialResult.get(0); taskId = lastItem.getTaskId(); nextPageSize = pageSize; } } } } return new Result(queryTime, result); } private  TaskDataReader(TaskAssigningRuntimeClient runtimeClient); static TaskDataReader from(TaskAssigningRuntimeClient runtimeClient); Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate,
                            int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode); Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize); }
TaskDataReader { public Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode) { final List<TaskData> result = new ArrayList<>(); boolean finished = false; List<TaskData> partialResult; TaskDataList taskDataList; TaskData lastItem = null; LocalDateTime queryTime = null; long taskId = fromTaskId; int nextPageSize = pageSize; while (!finished) { taskDataList = runtimeClient.findTasks(taskId, status, fromLastModificationDate, 0, nextPageSize, taskInputVariablesReadMode); partialResult = new ArrayList<>(taskDataList.getItems()); if (queryTime == null) { queryTime = taskDataList.getQueryTime(); } if (partialResult.isEmpty()) { finished = true; } else { if (lastItem == null || partialResult.size() > 1) { lastItem = partialResult.remove(partialResult.size() - 1); taskId = lastItem.getTaskId(); nextPageSize = pageSize; result.addAll(partialResult); } else { if (lastItem.getTaskId().equals(partialResult.get(0).getTaskId())) { if (partialResult.get(0).getPotentialOwners().isEmpty()) { result.add(partialResult.get(0)); lastItem = null; taskId++; nextPageSize = pageSize; } else if (partialResult.get(0).getPotentialOwners().size() < nextPageSize) { result.add(partialResult.get(0)); finished = true; } else { nextPageSize = nextPageSize * 2; } } else { lastItem = partialResult.get(0); taskId = lastItem.getTaskId(); nextPageSize = pageSize; } } } } return new Result(queryTime, result); } private  TaskDataReader(TaskAssigningRuntimeClient runtimeClient); static TaskDataReader from(TaskAssigningRuntimeClient runtimeClient); Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate,
                            int pageSize, TaskInputVariablesReadMode taskInputVariablesReadMode); Result readTasks(long fromTaskId, List<String> status, LocalDateTime fromLastModificationDate, int pageSize);  }