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
}
}
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));
}
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();
}
}
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));
}
Aggregations