Search in sources :

Example 1 with ListInfo

use of org.datatransferproject.transfer.rememberthemilk.model.tasks.ListInfo in project data-transfer-project by google.

the class RememberTheMilkTasksExporter method exportTaskList.

private ExportResult exportTaskList(RememberTheMilkService service) {
    List<TaskListModel> lists = new ArrayList<>();
    List<IdOnlyContainerResource> subResources = new ArrayList<>();
    List<ListInfo> listInfoList;
    try {
        listInfoList = service.getLists().lists;
    } catch (IOException e) {
        return new ExportResult(e);
    }
    for (ListInfo oldListInfo : listInfoList) {
        if (oldListInfo.name.equals("All Tasks")) {
            // All Tasks is a special list that contains everything, don't copy that over
            continue;
        }
        lists.add(new TaskListModel(Integer.toString(oldListInfo.id), oldListInfo.name));
        subResources.add(new IdOnlyContainerResource(Integer.toString(oldListInfo.id)));
    }
    TaskContainerResource taskContainerResource = new TaskContainerResource(lists, null);
    ContinuationData continuationData = new ContinuationData(null);
    subResources.forEach(continuationData::addContainerResource);
    // TODO: what do we do with pagination data?
    return new ExportResult(ResultType.CONTINUE, taskContainerResource, continuationData);
}
Also used : ListInfo(org.datatransferproject.transfer.rememberthemilk.model.tasks.ListInfo) ArrayList(java.util.ArrayList) IdOnlyContainerResource(org.datatransferproject.types.common.models.IdOnlyContainerResource) ContinuationData(org.datatransferproject.spi.transfer.types.ContinuationData) IOException(java.io.IOException) TaskContainerResource(org.datatransferproject.types.common.models.tasks.TaskContainerResource) TaskListModel(org.datatransferproject.types.common.models.tasks.TaskListModel) ExportResult(org.datatransferproject.spi.transfer.provider.ExportResult)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExportResult (org.datatransferproject.spi.transfer.provider.ExportResult)1 ContinuationData (org.datatransferproject.spi.transfer.types.ContinuationData)1 ListInfo (org.datatransferproject.transfer.rememberthemilk.model.tasks.ListInfo)1 IdOnlyContainerResource (org.datatransferproject.types.common.models.IdOnlyContainerResource)1 TaskContainerResource (org.datatransferproject.types.common.models.tasks.TaskContainerResource)1 TaskListModel (org.datatransferproject.types.common.models.tasks.TaskListModel)1