|
|
|
@ -3,6 +3,8 @@ package com.todoroo.astrid.actfm.sync;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import com.todoroo.andlib.data.TodorooCursor;
|
|
|
|
|
import com.todoroo.andlib.service.Autowired;
|
|
|
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
@ -21,6 +23,8 @@ import com.todoroo.astrid.data.TaskOutstanding;
|
|
|
|
|
|
|
|
|
|
public class EmptyTitleOutstandingEntryMigration {
|
|
|
|
|
|
|
|
|
|
private static final String ERROR_TAG = "empty-title-migrate"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TaskOutstandingDao taskOutstandingDao;
|
|
|
|
|
|
|
|
|
@ -35,12 +39,13 @@ public class EmptyTitleOutstandingEntryMigration {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void performMigration() {
|
|
|
|
|
TodorooCursor<TaskOutstanding> outstandingWithTitle = null;
|
|
|
|
|
try {
|
|
|
|
|
TodorooCursor<TaskOutstanding> outstandingWithTitle = taskOutstandingDao
|
|
|
|
|
outstandingWithTitle = taskOutstandingDao
|
|
|
|
|
.query(Query.select(TaskOutstanding.TASK_ID, Task.UUID)
|
|
|
|
|
.join(Join.left(Task.TABLE, Task.ID.eq(TaskOutstanding.TASK_ID)))
|
|
|
|
|
.where(Criterion.and(TaskOutstanding.COLUMN_STRING.eq(Task.TITLE.name),
|
|
|
|
|
Criterion.or(TaskOutstanding.VALUE_STRING.isNotNull(), TaskOutstanding.VALUE_STRING.neq("")))) //$NON-NLS-1$
|
|
|
|
|
Criterion.and(TaskOutstanding.VALUE_STRING.isNotNull(), TaskOutstanding.VALUE_STRING.neq("")))) //$NON-NLS-1$
|
|
|
|
|
.groupBy(TaskOutstanding.TASK_ID));
|
|
|
|
|
List<Long> ids = new ArrayList<Long>();
|
|
|
|
|
List<String> uuids = new ArrayList<String>();
|
|
|
|
@ -49,7 +54,7 @@ public class EmptyTitleOutstandingEntryMigration {
|
|
|
|
|
ids.add(outstandingWithTitle.get(TaskOutstanding.TASK_ID));
|
|
|
|
|
uuids.add(outstandingWithTitle.get(Task.UUID));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//
|
|
|
|
|
Log.e(ERROR_TAG, "Error reading from cursor", e); //$NON-NLS-1$
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -60,7 +65,10 @@ public class EmptyTitleOutstandingEntryMigration {
|
|
|
|
|
new ConstructOutstandingTableFromMasterTable<TaskAttachment, TaskAttachmentOutstanding>(NameMaps.TABLE_ID_ATTACHMENTS,
|
|
|
|
|
taskAttachmentDao, taskAttachmentOutstandingDao, TaskAttachment.CREATED_AT).execute(TaskAttachment.TASK_UUID.in(uuids.toArray(new String[uuids.size()])));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//
|
|
|
|
|
Log.e(ERROR_TAG, "Unhandled exception", e); //$NON-NLS-1$
|
|
|
|
|
} finally {
|
|
|
|
|
if (outstandingWithTitle != null)
|
|
|
|
|
outstandingWithTitle.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|