From 8120cd22c80c1a87519e59d26af4fa797e326412 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 10 Sep 2012 13:00:14 -0700 Subject: [PATCH] Add uuid column to remote model database entities --- api/src/com/todoroo/astrid/data/RemoteModel.java | 7 +++++++ api/src/com/todoroo/astrid/data/TagData.java | 4 ++++ api/src/com/todoroo/astrid/data/Task.java | 4 ++++ api/src/com/todoroo/astrid/data/Update.java | 4 ++++ api/src/com/todoroo/astrid/data/User.java | 4 ++++ astrid/src/com/todoroo/astrid/dao/Database.java | 9 +++++++++ 6 files changed, 32 insertions(+) diff --git a/api/src/com/todoroo/astrid/data/RemoteModel.java b/api/src/com/todoroo/astrid/data/RemoteModel.java index b2d039dc7..efafb0d54 100644 --- a/api/src/com/todoroo/astrid/data/RemoteModel.java +++ b/api/src/com/todoroo/astrid/data/RemoteModel.java @@ -35,4 +35,11 @@ abstract public class RemoteModel extends AbstractModel { /** user json property */ public static final StringProperty USER_JSON_PROPERTY = new StringProperty(null, USER_JSON_PROPERTY_NAME); + /** uuid property name */ + public static final String UUID_PROPERTY_NAME = "uuid"; //$NON-NLS-1$ + + /** uuid property */ + public static final StringProperty UUID_PROPERTY = new StringProperty(null, UUID_PROPERTY_NAME); + + } diff --git a/api/src/com/todoroo/astrid/data/TagData.java b/api/src/com/todoroo/astrid/data/TagData.java index bdd8bab79..150e99bce 100644 --- a/api/src/com/todoroo/astrid/data/TagData.java +++ b/api/src/com/todoroo/astrid/data/TagData.java @@ -114,6 +114,10 @@ public final class TagData extends RemoteModel { public static final StringProperty TAG_DESCRIPTION = new StringProperty( TABLE, "tagDescription"); + /** uuid */ + public static final StringProperty UUID = new StringProperty( + TABLE, UUID_PROPERTY_NAME); + /** List of all properties for this model */ public static final Property[] PROPERTIES = generateProperties(TagData.class); diff --git a/api/src/com/todoroo/astrid/data/Task.java b/api/src/com/todoroo/astrid/data/Task.java index cf0e4518d..51de6e8cc 100644 --- a/api/src/com/todoroo/astrid/data/Task.java +++ b/api/src/com/todoroo/astrid/data/Task.java @@ -134,6 +134,10 @@ public final class Task extends RemoteModel { public static final StringProperty CALENDAR_URI = new StringProperty( TABLE, "calendarUri"); + /** uuid */ + public static final StringProperty UUID = new StringProperty( + TABLE, UUID_PROPERTY_NAME); + // --- for astrid.com /** Remote id */ diff --git a/api/src/com/todoroo/astrid/data/Update.java b/api/src/com/todoroo/astrid/data/Update.java index 9a13fbfe0..ada77579e 100644 --- a/api/src/com/todoroo/astrid/data/Update.java +++ b/api/src/com/todoroo/astrid/data/Update.java @@ -101,6 +101,10 @@ public class Update extends RemoteModel { public static final LongProperty CREATION_DATE = new LongProperty( TABLE, "created"); + /** uuid */ + public static final StringProperty UUID = new StringProperty( + TABLE, UUID_PROPERTY_NAME); + /** List of all properties for this model */ public static final Property[] PROPERTIES = generateProperties(Update.class); diff --git a/api/src/com/todoroo/astrid/data/User.java b/api/src/com/todoroo/astrid/data/User.java index f5641badf..bcf31797c 100644 --- a/api/src/com/todoroo/astrid/data/User.java +++ b/api/src/com/todoroo/astrid/data/User.java @@ -58,6 +58,10 @@ public final class User extends RemoteModel { public static final LongProperty REMOTE_ID = new LongProperty( TABLE, REMOTE_ID_PROPERTY_NAME); + /** uuid */ + public static final StringProperty UUID = new StringProperty( + TABLE, UUID_PROPERTY_NAME); + /** List of all properties for this model */ public static final Property[] PROPERTIES = generateProperties(User.class); diff --git a/astrid/src/com/todoroo/astrid/dao/Database.java b/astrid/src/com/todoroo/astrid/dao/Database.java index 9d21c3b02..c478010b8 100644 --- a/astrid/src/com/todoroo/astrid/dao/Database.java +++ b/astrid/src/com/todoroo/astrid/dao/Database.java @@ -337,6 +337,11 @@ public class Database extends AbstractDatabase { case 25: try { database.execSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES)); database.execSQL(createTableSql(visitor, TagOutstanding.TABLE.name, TagOutstanding.PROPERTIES)); + + database.execSQL(addColumnSql(TagData.TABLE, TagData.UUID, visitor)); + database.execSQL(addColumnSql(Task.TABLE, Task.UUID, visitor)); + database.execSQL(addColumnSql(Update.TABLE, Update.UUID, visitor)); + database.execSQL(addColumnSql(User.TABLE, User.UUID, visitor)); } catch (SQLiteException e) { Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e); } @@ -347,6 +352,10 @@ public class Database extends AbstractDatabase { return false; } + private String addColumnSql(Table table, Property column, SqlConstructorVisitor visitor) { + return "ALTER TABLE " + table.name + " ADD " + column.accept(visitor, null); + } + /** * Create table generation SQL * @param sql