Boilerplate for the task and tag outstanding tables

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

@ -0,0 +1,16 @@
package com.todoroo.astrid.data;
import com.todoroo.andlib.data.AbstractModel;
@SuppressWarnings("nls")
public abstract class OutstandingEntry extends AbstractModel {
public static final String ENTITY_ID_PROPERTY_NAME = "entityId";
public static final String COLUMN_STRING_PROPERTY_NAME = "columnString";
public static final String VALUE_STRING_PROPERTY_NAME = "valueString";
public static final String CREATED_AT_PROPERTY_NAME = "createdAt";
}

@ -0,0 +1,63 @@
package com.todoroo.astrid.data;
import android.content.ContentValues;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
@SuppressWarnings("nls")
public class TagOutstanding extends OutstandingEntry {
/** table for this model */
public static final Table TABLE = new Table("tags_outstanding", TagOutstanding.class);
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
public static final LongProperty TAG_DATA_ID = new LongProperty(
TABLE, ENTITY_ID_PROPERTY_NAME);
public static final StringProperty COLUMN_STRING = new StringProperty(
TABLE, COLUMN_STRING_PROPERTY_NAME);
public static final StringProperty VALUE_STRING = new StringProperty(
TABLE, VALUE_STRING_PROPERTY_NAME);
public static final LongProperty CREATED_AT = new LongProperty(
TABLE, CREATED_AT_PROPERTY_NAME);
private static final ContentValues defaultValues = new ContentValues();
static {
defaultValues.put(TAG_DATA_ID.name, 0);
defaultValues.put(COLUMN_STRING.name, "");
defaultValues.put(VALUE_STRING.name, "");
}
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(TagOutstanding.class);
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
public static final Creator<TagOutstanding> CREATOR = new ModelCreator<TagOutstanding>(TagOutstanding.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}

@ -0,0 +1,63 @@
package com.todoroo.astrid.data;
import android.content.ContentValues;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
@SuppressWarnings("nls")
public class TaskOutstanding extends OutstandingEntry {
/** table for this model */
public static final Table TABLE = new Table("tasks_outstanding", TaskOutstanding.class);
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
public static final LongProperty TASK_ID = new LongProperty(
TABLE, ENTITY_ID_PROPERTY_NAME);
public static final StringProperty COLUMN_STRING = new StringProperty(
TABLE, COLUMN_STRING_PROPERTY_NAME);
public static final StringProperty VALUE_STRING = new StringProperty(
TABLE, VALUE_STRING_PROPERTY_NAME);
public static final LongProperty CREATED_AT = new LongProperty(
TABLE, CREATED_AT_PROPERTY_NAME);
private static final ContentValues defaultValues = new ContentValues();
static {
defaultValues.put(TASK_ID.name, 0);
defaultValues.put(COLUMN_STRING.name, "");
defaultValues.put(VALUE_STRING.name, "");
}
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(TaskOutstanding.class);
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
public static final Creator<TaskOutstanding> CREATOR = new ModelCreator<TaskOutstanding>(TaskOutstanding.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}

@ -17,7 +17,9 @@ import com.todoroo.astrid.data.ABTestEvent;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TagOutstanding;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
@ -39,7 +41,7 @@ public class Database extends AbstractDatabase {
* Database version number. This variable must be updated when database
* tables are updated, as it determines whether a database needs updating.
*/
public static final int VERSION = 25;
public static final int VERSION = 26;
/**
* Database name (must be unique)
@ -58,6 +60,9 @@ public class Database extends AbstractDatabase {
Update.TABLE,
User.TABLE,
ABTestEvent.TABLE,
TaskOutstanding.TABLE,
TagOutstanding.TABLE
};
// --- listeners
@ -329,6 +334,13 @@ public class Database extends AbstractDatabase {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
case 25: try {
database.execSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES));
database.execSQL(createTableSql(visitor, TagOutstanding.TABLE.name, TagOutstanding.PROPERTIES));
} catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
return true;
}

Loading…
Cancel
Save