Search in sources :

Example 1 with TaskBean

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;
}
Also used : TaskListBean(org.glassfish.jersey.examples.oauth2.googleclient.entity.TaskListBean) ArrayList(java.util.ArrayList) TaskBean(org.glassfish.jersey.examples.oauth2.googleclient.entity.TaskBean) WebTarget(javax.ws.rs.client.WebTarget) TaskListModel(org.glassfish.jersey.examples.oauth2.googleclient.model.TaskListModel) TaskModel(org.glassfish.jersey.examples.oauth2.googleclient.model.TaskModel)

Aggregations

ArrayList (java.util.ArrayList)1 WebTarget (javax.ws.rs.client.WebTarget)1 TaskBean (org.glassfish.jersey.examples.oauth2.googleclient.entity.TaskBean)1 TaskListBean (org.glassfish.jersey.examples.oauth2.googleclient.entity.TaskListBean)1 TaskListModel (org.glassfish.jersey.examples.oauth2.googleclient.model.TaskListModel)1 TaskModel (org.glassfish.jersey.examples.oauth2.googleclient.model.TaskModel)1