Search in sources :

Example 1 with TaskModelWrapper

use of org.dataportabilityproject.dataModels.tasks.TaskModelWrapper in project data-transfer-project by google.

the class GoogleTaskService method getTasks.

private TaskModelWrapper getTasks(String taskListId, Optional<PaginationInformation> pageInfo) throws IOException {
    com.google.api.services.tasks.model.Tasks result;
    Tasks.TasksOperations.List query = taskClient.tasks().list(taskListId).setMaxResults(PAGE_SIZE);
    if (pageInfo.isPresent()) {
        query.setPageToken(((StringPaginationToken) pageInfo.get()).getId());
    }
    result = query.execute();
    List<TaskModel> newTasks = result.getItems().stream().map(t -> new TaskModel(taskListId, t.getTitle(), t.getNotes())).collect(Collectors.toList());
    PaginationInformation newPageInfo = null;
    if (result.getNextPageToken() != null) {
        newPageInfo = new StringPaginationToken(result.getNextPageToken());
    }
    return new TaskModelWrapper(null, newTasks, new ContinuationInformation(null, newPageInfo));
}
Also used : Importer(org.dataportabilityproject.dataModels.Importer) Resource(org.dataportabilityproject.dataModels.Resource) ExportInformation(org.dataportabilityproject.dataModels.ExportInformation) IOException(java.io.IOException) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) Tasks(com.google.api.services.tasks.Tasks) TaskModel(org.dataportabilityproject.dataModels.tasks.TaskModel) Collectors(java.util.stream.Collectors) TaskModelWrapper(org.dataportabilityproject.dataModels.tasks.TaskModelWrapper) Task(com.google.api.services.tasks.model.Task) ArrayList(java.util.ArrayList) Exporter(org.dataportabilityproject.dataModels.Exporter) List(java.util.List) TaskList(com.google.api.services.tasks.model.TaskList) PaginationInformation(org.dataportabilityproject.dataModels.PaginationInformation) JobDataCache(org.dataportabilityproject.cloud.interfaces.JobDataCache) ContinuationInformation(org.dataportabilityproject.dataModels.ContinuationInformation) Optional(java.util.Optional) Credential(com.google.api.client.auth.oauth2.Credential) TaskLists(com.google.api.services.tasks.model.TaskLists) GoogleStaticObjects(org.dataportabilityproject.serviceProviders.google.GoogleStaticObjects) TaskListModel(org.dataportabilityproject.dataModels.tasks.TaskListModel) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken) TaskModelWrapper(org.dataportabilityproject.dataModels.tasks.TaskModelWrapper) ContinuationInformation(org.dataportabilityproject.dataModels.ContinuationInformation) TaskModel(org.dataportabilityproject.dataModels.tasks.TaskModel) PaginationInformation(org.dataportabilityproject.dataModels.PaginationInformation) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken)

Example 2 with TaskModelWrapper

use of org.dataportabilityproject.dataModels.tasks.TaskModelWrapper in project data-transfer-project by google.

the class RememberTheMilkTaskService method exportTaskList.

private TaskModelWrapper exportTaskList(Resource resource, Optional<PaginationInformation> paginationInformation) throws IOException {
    int oldListId = Integer.parseInt(((IdOnlyResource) resource).getId());
    GetListResponse oldList = getList(oldListId);
    List<TaskList> taskLists = oldList.tasks.list;
    List<TaskModel> tasks = new ArrayList<>();
    for (TaskList taskList : taskLists) {
        if (taskList.taskSeriesList != null) {
            for (TaskSeries taskSeries : taskList.taskSeriesList) {
                tasks.add(new TaskModel(Integer.toString(oldListId), taskSeries.name, taskSeries.notes.toString()));
                for (Task task : taskSeries.tasks) {
                // Do something here with completion date, but its odd there can be more than one.
                }
            }
        }
    }
    return new TaskModelWrapper(null, tasks, null);
}
Also used : GetListResponse(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.GetListResponse) TaskModelWrapper(org.dataportabilityproject.dataModels.tasks.TaskModelWrapper) Task(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.Task) TaskList(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.TaskList) ArrayList(java.util.ArrayList) TaskSeries(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.TaskSeries) TaskModel(org.dataportabilityproject.dataModels.tasks.TaskModel)

Example 3 with TaskModelWrapper

use of org.dataportabilityproject.dataModels.tasks.TaskModelWrapper in project data-transfer-project by google.

the class GoogleTaskService method getTaskLists.

private TaskModelWrapper getTaskLists(Optional<PaginationInformation> pageInfo) throws IOException {
    Tasks.Tasklists.List query = taskClient.tasklists().list().setMaxResults(PAGE_SIZE);
    if (pageInfo.isPresent()) {
        query.setPageToken(((StringPaginationToken) pageInfo.get()).getId());
    }
    TaskLists result = query.execute();
    List<TaskListModel> newTaskLists = new ArrayList<>(result.getItems().size());
    List<Resource> newResources = new ArrayList<>(result.getItems().size());
    for (TaskList taskList : result.getItems()) {
        newTaskLists.add(new TaskListModel(taskList.getId(), taskList.getTitle()));
        newResources.add(new IdOnlyResource(taskList.getId()));
    }
    PaginationInformation newPageInfo = null;
    if (result.getNextPageToken() != null) {
        newPageInfo = new StringPaginationToken(result.getNextPageToken());
    }
    return new TaskModelWrapper(newTaskLists, null, new ContinuationInformation(newResources, newPageInfo));
}
Also used : TaskList(com.google.api.services.tasks.model.TaskList) ArrayList(java.util.ArrayList) Resource(org.dataportabilityproject.dataModels.Resource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) TaskModelWrapper(org.dataportabilityproject.dataModels.tasks.TaskModelWrapper) ContinuationInformation(org.dataportabilityproject.dataModels.ContinuationInformation) TaskLists(com.google.api.services.tasks.model.TaskLists) TaskListModel(org.dataportabilityproject.dataModels.tasks.TaskListModel) PaginationInformation(org.dataportabilityproject.dataModels.PaginationInformation) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken)

Example 4 with TaskModelWrapper

use of org.dataportabilityproject.dataModels.tasks.TaskModelWrapper in project data-transfer-project by google.

the class RememberTheMilkTaskService method exportTaskLists.

private TaskModelWrapper exportTaskLists(Optional<PaginationInformation> paginationInformation) throws IOException {
    List<TaskListModel> lists = new ArrayList<>();
    List<Resource> subResources = new ArrayList<>();
    for (ListInfo oldListInfo : getLists().listInfoList.lists) {
        if (oldListInfo.name.equals("All Tasks")) {
            // don't copy that over.
            continue;
        }
        lists.add(new TaskListModel(Integer.toString(oldListInfo.id), oldListInfo.name));
        subResources.add(new IdOnlyResource(Integer.toString(oldListInfo.id)));
    }
    return new TaskModelWrapper(lists, null, new ContinuationInformation(subResources, null));
}
Also used : TaskModelWrapper(org.dataportabilityproject.dataModels.tasks.TaskModelWrapper) ContinuationInformation(org.dataportabilityproject.dataModels.ContinuationInformation) ListInfo(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.ListInfo) ArrayList(java.util.ArrayList) Resource(org.dataportabilityproject.dataModels.Resource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) TaskListModel(org.dataportabilityproject.dataModels.tasks.TaskListModel)

Aggregations

ArrayList (java.util.ArrayList)4 TaskModelWrapper (org.dataportabilityproject.dataModels.tasks.TaskModelWrapper)4 ContinuationInformation (org.dataportabilityproject.dataModels.ContinuationInformation)3 Resource (org.dataportabilityproject.dataModels.Resource)3 TaskListModel (org.dataportabilityproject.dataModels.tasks.TaskListModel)3 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)3 TaskList (com.google.api.services.tasks.model.TaskList)2 TaskLists (com.google.api.services.tasks.model.TaskLists)2 PaginationInformation (org.dataportabilityproject.dataModels.PaginationInformation)2 TaskModel (org.dataportabilityproject.dataModels.tasks.TaskModel)2 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)2 Credential (com.google.api.client.auth.oauth2.Credential)1 Tasks (com.google.api.services.tasks.Tasks)1 Task (com.google.api.services.tasks.model.Task)1 IOException (java.io.IOException)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 JobDataCache (org.dataportabilityproject.cloud.interfaces.JobDataCache)1 ExportInformation (org.dataportabilityproject.dataModels.ExportInformation)1