Add uuid column to remote model database entities

pull/14/head
Sam Bosley 12 years ago
parent def1a55d9d
commit 8120cd22c8

@ -35,4 +35,11 @@ abstract public class RemoteModel extends AbstractModel {
/** user json property */ /** user json property */
public static final StringProperty USER_JSON_PROPERTY = new StringProperty(null, USER_JSON_PROPERTY_NAME); 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);
} }

@ -114,6 +114,10 @@ public final class TagData extends RemoteModel {
public static final StringProperty TAG_DESCRIPTION = new StringProperty( public static final StringProperty TAG_DESCRIPTION = new StringProperty(
TABLE, "tagDescription"); TABLE, "tagDescription");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(TagData.class); public static final Property<?>[] PROPERTIES = generateProperties(TagData.class);

@ -134,6 +134,10 @@ public final class Task extends RemoteModel {
public static final StringProperty CALENDAR_URI = new StringProperty( public static final StringProperty CALENDAR_URI = new StringProperty(
TABLE, "calendarUri"); TABLE, "calendarUri");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
// --- for astrid.com // --- for astrid.com
/** Remote id */ /** Remote id */

@ -101,6 +101,10 @@ 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");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_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);

@ -58,6 +58,10 @@ public final class User extends RemoteModel {
public static final LongProperty REMOTE_ID = new LongProperty( public static final LongProperty REMOTE_ID = new LongProperty(
TABLE, REMOTE_ID_PROPERTY_NAME); TABLE, REMOTE_ID_PROPERTY_NAME);
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(User.class); public static final Property<?>[] PROPERTIES = generateProperties(User.class);

@ -337,6 +337,11 @@ public class Database extends AbstractDatabase {
case 25: try { case 25: try {
database.execSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES)); database.execSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES));
database.execSQL(createTableSql(visitor, TagOutstanding.TABLE.name, TagOutstanding.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) { } catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e); Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
} }
@ -347,6 +352,10 @@ public class Database extends AbstractDatabase {
return false; 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 * Create table generation SQL
* @param sql * @param sql

Loading…
Cancel
Save