use of org.datatransferproject.transfer.rememberthemilk.model.tasks.GetListResponse in project data-transfer-project by google.
the class RememberTheMilkTasksExporter method exportTask.
private ExportResult exportTask(RememberTheMilkService service, IdOnlyContainerResource resource) {
String oldListId = resource.getId();
GetListResponse oldList = null;
try {
oldList = service.getList(oldListId);
} catch (IOException e) {
return new ExportResult(e);
}
List<TaskList> taskLists = oldList.tasks.list;
List<TaskModel> tasks = new ArrayList<>();
for (TaskList taskList : taskLists) {
if (taskList.taskseries != null) {
for (TaskSeries taskSeries : taskList.taskseries) {
// TODO: figure out what to do with notes
String notesStr = taskSeries.notes == null ? "" : taskSeries.notes.toString();
for (Task task : taskSeries.tasks) {
// TODO: How to handle case with multiple tasks in a series? Is this good enough?
Instant completedTime = null;
Instant dueTime = null;
if (task.completed != null && !Strings.isNullOrEmpty(task.completed)) {
completedTime = Instant.parse(task.completed);
}
if (task.due != null && !Strings.isNullOrEmpty(task.due)) {
dueTime = Instant.parse(task.due);
}
tasks.add(new TaskModel(oldListId, taskSeries.name, notesStr, completedTime, dueTime));
}
}
}
}
TaskContainerResource taskContainerResource = new TaskContainerResource(null, tasks);
// TODO: what do we do with pagination data?
return new ExportResult(ResultType.CONTINUE, taskContainerResource, null);
}
Aggregations