Add a few places where google tasks needs the astrid uuid to save

pull/14/head
Sam Bosley 12 years ago
parent 47b8fa96b4
commit 23232c50e6

@ -91,6 +91,7 @@ public final class GtasksMetadataService extends SyncMetadataService<GtasksTaskC
return;
cursor.moveToFirst();
remoteTask.task.setId(cursor.get(Metadata.TASK));
remoteTask.task.setUuid(taskDao.uuidFromLocalId(remoteTask.task.getId()));
remoteTask.gtaskMetadata = new Metadata(cursor);
} finally {
cursor.close();

@ -329,6 +329,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
Task local = PluginServices.getTaskService().fetchById(task.task.getId(), Task.DUE_DATE, Task.COMPLETION_DATE);
if (local == null) {
task.task.clearValue(Task.ID);
task.task.clearValue(Task.UUID);
} else {
mergeDates(task.task, local);
if(task.task.isCompleted() && !local.isCompleted())
@ -347,13 +348,14 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
private void titleMatchWithActFm(Task task) {
String title = task.getValue(Task.TITLE);
TodorooCursor<Task> match = taskService.query(Query.select(Task.ID)
TodorooCursor<Task> match = taskService.query(Query.select(Task.ID, Task.UUID)
.join(Join.left(Metadata.TABLE, Criterion.and(Metadata.KEY.eq(GtasksMetadata.METADATA_KEY), Metadata.TASK.eq(Task.ID))))
.where(Criterion.and(Task.TITLE.eq(title), GtasksMetadata.ID.isNull())));
try {
if (match.getCount() > 0) {
match.moveToFirst();
task.setId(match.get(Task.ID));
task.setUuid(match.get(Task.UUID));
}
} finally {
match.close();

@ -25,7 +25,7 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
@Override
public boolean createNew(RTYPE item) {
if (!item.containsValue(RemoteModel.UUID_PROPERTY)) {
if (!item.containsValue(RemoteModel.UUID_PROPERTY) || RemoteModel.isUuidEmpty(item.getValue(RemoteModel.UUID_PROPERTY))) {
item.setValue(RemoteModel.UUID_PROPERTY, UUIDHelper.newUUID());
}
return super.createNew(item);
@ -78,5 +78,17 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
}
}
public String uuidFromLocalId(long localId) {
TodorooCursor<RTYPE> cursor = query(Query.select(RemoteModel.UUID_PROPERTY).where(AbstractModel.ID_PROPERTY.eq(localId)));
try {
if (cursor.getCount() == 0)
return RemoteModel.NO_UUID;
cursor.moveToFirst();
return cursor.get(RemoteModel.UUID_PROPERTY);
} finally {
cursor.close();
}
}
}

Loading…
Cancel
Save