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