use of org.glassfish.jersey.examples.oauth2.googleclient.entity.TaskBean in project jersey by jersey.
the class TaskResource method processTaskLists.
/**
* Process users task lists and read task details. Collect just
* @param baseTarget base JAX-RS client target with oauth context configured
* @param taskRootBean root task bean to be processed
* @return Detailed list of non-completed tasks or {@code null} if there is no task list available.
*/
private List<TaskListModel> processTaskLists(final WebTarget baseTarget, final TaskRootBean taskRootBean) {
final List<TaskListModel> listOfTaskLists = new ArrayList<>();
for (final TaskListBean taskListBean : taskRootBean.getItems()) {
final List<TaskModel> taskList = new ArrayList<>();
final WebTarget listTarget = baseTarget.path("lists/{tasklist}/tasks").resolveTemplate("tasklist", taskListBean.getId());
final TaskListBean fullTaskListBean = listTarget.request().get(TaskListBean.class);
for (final TaskBean taskBean : fullTaskListBean.getTasks()) {
if (taskBean.getCompleted() == null) {
taskList.add(new TaskModel(taskBean.getTitle()));
}
}
listOfTaskLists.add(new TaskListModel(taskListBean.getTitle(), taskList.size() > 0 ? taskList : null));
}
return listOfTaskLists.size() > 0 ? listOfTaskLists : null;
}
Aggregations