Fixed several bugs that were throwing exceptions in attachments migration

pull/14/head
Sam Bosley 12 years ago
parent 0e898a2607
commit fdb6ddc62f

@ -108,10 +108,6 @@ public class Update extends RemoteModel {
public static final LongProperty CREATION_DATE = new LongProperty( public static final LongProperty CREATION_DATE = new LongProperty(
TABLE, "created"); TABLE, "created");
/** Pushed at date */
public static final LongProperty PUSHED_AT = new LongProperty(
TABLE, PUSHED_AT_PROPERTY_NAME);
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Update.class); public static final Property<?>[] PROPERTIES = generateProperties(Update.class);
@ -145,7 +141,6 @@ public class Update extends RemoteModel {
defaultValues.put(MESSAGE.name, ""); defaultValues.put(MESSAGE.name, "");
defaultValues.put(TARGET_NAME.name, ""); defaultValues.put(TARGET_NAME.name, "");
defaultValues.put(PICTURE.name, ""); defaultValues.put(PICTURE.name, "");
defaultValues.put(PUSHED_AT.name, 0L);
} }
// --- data access boilerplate // --- data access boilerplate

@ -248,6 +248,7 @@ public class AstridNewSyncMigrator {
TodorooCursor<Metadata> fmCursor = metadataService.query(Query.select(Metadata.PROPERTIES) TodorooCursor<Metadata> fmCursor = metadataService.query(Query.select(Metadata.PROPERTIES)
.where(MetadataCriteria.withKey(FileMetadata.METADATA_KEY))); .where(MetadataCriteria.withKey(FileMetadata.METADATA_KEY)));
try { try {
System.err.println("FILES COUNT: " + fmCursor.getCount());
Metadata m = new Metadata(); Metadata m = new Metadata();
for (fmCursor.moveToFirst(); !fmCursor.isAfterLast(); fmCursor.moveToNext()) { for (fmCursor.moveToFirst(); !fmCursor.isAfterLast(); fmCursor.moveToNext()) {
m.clear(); m.clear();
@ -255,6 +256,7 @@ public class AstridNewSyncMigrator {
TaskAttachment attachment = new TaskAttachment(); TaskAttachment attachment = new TaskAttachment();
Task task = taskDao.fetch(m.getValue(Metadata.TASK), Task.UUID); Task task = taskDao.fetch(m.getValue(Metadata.TASK), Task.UUID);
System.err.println("TASK UUID: " + task.getUuid());
if (task == null || !RemoteModel.isValidUuid(task.getUuid())) if (task == null || !RemoteModel.isValidUuid(task.getUuid()))
continue; continue;
@ -264,15 +266,23 @@ public class AstridNewSyncMigrator {
synced = true; synced = true;
attachment.setValue(TaskAttachment.UUID, Long.toString(oldRemoteId)); attachment.setValue(TaskAttachment.UUID, Long.toString(oldRemoteId));
} }
System.err.println("ALREADY SYNCED: " + synced);
attachment.setValue(TaskAttachment.TASK_UUID, task.getUuid()); attachment.setValue(TaskAttachment.TASK_UUID, task.getUuid());
if (m.containsNonNullValue(FileMetadata.NAME))
attachment.setValue(TaskAttachment.NAME, m.getValue(FileMetadata.NAME)); attachment.setValue(TaskAttachment.NAME, m.getValue(FileMetadata.NAME));
if (m.containsNonNullValue(FileMetadata.URL))
attachment.setValue(TaskAttachment.URL, m.getValue(FileMetadata.URL)); attachment.setValue(TaskAttachment.URL, m.getValue(FileMetadata.URL));
if (m.containsNonNullValue(FileMetadata.FILE_PATH))
attachment.setValue(TaskAttachment.FILE_PATH, m.getValue(FileMetadata.FILE_PATH)); attachment.setValue(TaskAttachment.FILE_PATH, m.getValue(FileMetadata.FILE_PATH));
if (m.containsNonNullValue(FileMetadata.FILE_TYPE))
attachment.setValue(TaskAttachment.CONTENT_TYPE, m.getValue(FileMetadata.FILE_TYPE)); attachment.setValue(TaskAttachment.CONTENT_TYPE, m.getValue(FileMetadata.FILE_TYPE));
if (m.containsNonNullValue(FileMetadata.DELETION_DATE))
attachment.setValue(TaskAttachment.DELETED_AT, m.getValue(FileMetadata.DELETION_DATE)); attachment.setValue(TaskAttachment.DELETED_AT, m.getValue(FileMetadata.DELETION_DATE));
if (synced) if (synced) {
System.err.println("ATTACHMENT UUID: " + attachment.getValue(TaskAttachment.UUID));
attachment.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); attachment.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
}
taskAttachmentDao.createNew(attachment); taskAttachmentDao.createNew(attachment);

Loading…
Cancel
Save