Search in sources :

Example 1 with TaskListModel

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

the class RememberTheMilkTaskService method importItem.

@Override
public void importItem(TaskModelWrapper wrapper) throws IOException {
    String timeline = createTimeline();
    for (TaskListModel taskList : wrapper.getLists()) {
        ListInfo listInfo = createTaskList(taskList.getName(), timeline);
        jobDataCache.store(taskList.getId(), listInfo.id);
    }
    for (TaskModel task : wrapper.getTasks()) {
        int newList = jobDataCache.getData(task.getTaskListId(), Integer.class);
        TaskSeries addedTask = createTask(task.getText(), timeline, newList);
    // TODO add note here
    }
}
Also used : ListInfo(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.ListInfo) TaskSeries(org.dataportabilityproject.serviceProviders.rememberTheMilk.model.TaskSeries) TaskListModel(org.dataportabilityproject.dataModels.tasks.TaskListModel) TaskModel(org.dataportabilityproject.dataModels.tasks.TaskModel)

Example 2 with TaskListModel

use of org.dataportabilityproject.dataModels.tasks.TaskListModel 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 3 with TaskListModel

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

the class GoogleTaskService method importItem.

@Override
public void importItem(TaskModelWrapper wrapper) throws IOException {
    for (TaskListModel taskList : wrapper.getLists()) {
        TaskList newTaskList = new TaskList().setTitle("Imported copy - " + taskList.getName());
        TaskList insertedTaskList = taskClient.tasklists().insert(newTaskList).execute();
        System.out.println("Storing " + taskList.getId() + " as " + insertedTaskList.getId());
        jobDataCache.store(taskList.getId(), insertedTaskList.getId());
    }
    for (TaskModel oldTask : wrapper.getTasks()) {
        Task newTask = new Task().setTitle(oldTask.getText()).setNotes(oldTask.getNotes());
        String newTaskId = jobDataCache.getData(oldTask.getTaskListId(), String.class);
        taskClient.tasks().insert(newTaskId, newTask).execute();
    }
}
Also used : Task(com.google.api.services.tasks.model.Task) TaskList(com.google.api.services.tasks.model.TaskList) TaskListModel(org.dataportabilityproject.dataModels.tasks.TaskListModel) TaskModel(org.dataportabilityproject.dataModels.tasks.TaskModel)

Example 4 with TaskListModel

use of org.dataportabilityproject.dataModels.tasks.TaskListModel 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

TaskListModel (org.dataportabilityproject.dataModels.tasks.TaskListModel)4 TaskList (com.google.api.services.tasks.model.TaskList)2 ArrayList (java.util.ArrayList)2 ContinuationInformation (org.dataportabilityproject.dataModels.ContinuationInformation)2 Resource (org.dataportabilityproject.dataModels.Resource)2 TaskModel (org.dataportabilityproject.dataModels.tasks.TaskModel)2 TaskModelWrapper (org.dataportabilityproject.dataModels.tasks.TaskModelWrapper)2 ListInfo (org.dataportabilityproject.serviceProviders.rememberTheMilk.model.ListInfo)2 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)2 Task (com.google.api.services.tasks.model.Task)1 TaskLists (com.google.api.services.tasks.model.TaskLists)1 PaginationInformation (org.dataportabilityproject.dataModels.PaginationInformation)1 TaskSeries (org.dataportabilityproject.serviceProviders.rememberTheMilk.model.TaskSeries)1 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)1