use of org.dataportabilityproject.dataModels.tasks.TaskModel 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));
}
use of org.dataportabilityproject.dataModels.tasks.TaskModel 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);
}
use of org.dataportabilityproject.dataModels.tasks.TaskModel 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.TaskModel 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();
}
}
Aggregations