diff --git a/api/src/com/todoroo/astrid/data/WaitingOnMe.java b/api/src/com/todoroo/astrid/data/WaitingOnMe.java new file mode 100644 index 000000000..27ee5b599 --- /dev/null +++ b/api/src/com/todoroo/astrid/data/WaitingOnMe.java @@ -0,0 +1,107 @@ +package com.todoroo.astrid.data; + +import android.content.ContentValues; +import android.net.Uri; + +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; +import com.todoroo.andlib.data.TodorooCursor; +import com.todoroo.astrid.api.AstridApiConstants; + +@SuppressWarnings("nls") +public class WaitingOnMe extends RemoteModel { + + /** table for this model */ + public static final Table TABLE = new Table("waitingOnMe", WaitingOnMe.class); + + /** model class for entries in the outstanding table */ + public static final Class> OUTSTANDING_MODEL = WaitingOnMeOutstanding.class; + + /** content uri for this model */ + public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" + + TABLE.name); + + /** ID */ + public static final LongProperty ID = new LongProperty( + TABLE, ID_PROPERTY_NAME); + + /** Remote ID */ + public static final StringProperty UUID = new StringProperty( + TABLE, RemoteModel.UUID_PROPERTY_NAME); + + public static final StringProperty WAITING_USER_ID = new StringProperty( + TABLE, "waiting_user_id", Property.PROP_FLAG_USER_ID); + + public static final StringProperty TASK_UUID = new StringProperty( + TABLE, "task_uuid"); + + public static final StringProperty WAIT_TYPE = new StringProperty( + TABLE, "wait_type"); + + public static final LongProperty CREATED_AT = new LongProperty( + TABLE, "created_at", Property.PROP_FLAG_DATE); + + public static final LongProperty DELETED_AT = new LongProperty( + TABLE, "deleted_at", Property.PROP_FLAG_DATE); + + public static final LongProperty READ_AT = new LongProperty( + TABLE, "read_at", Property.PROP_FLAG_DATE); + + @Override + public String getUuid() { + return getUuidHelper(UUID); + } + + public WaitingOnMe() { + super(); + } + + public WaitingOnMe(TodorooCursor cursor) { + this(); + readPropertiesFromCursor(cursor); + } + + public void readFromCursor(TodorooCursor cursor) { + super.readPropertiesFromCursor(cursor); + } + + private static final ContentValues defaultValues = new ContentValues(); + + static { + defaultValues.put(UUID.name, RemoteModel.NO_UUID); + defaultValues.put(WAITING_USER_ID.name, RemoteModel.NO_UUID); + defaultValues.put(TASK_UUID.name, RemoteModel.NO_UUID); + defaultValues.put(CREATED_AT.name, 0L); + defaultValues.put(DELETED_AT.name, 0L); + defaultValues.put(READ_AT.name, 0L); + } + + public static final String WAIT_TYPE_COMMENTED = "commented"; + public static final String WAIT_TYPE_ASSIGNED = "assigned"; + public static final String WAIT_TYPE_MENTIONED = "mentioned"; + public static final String WAIT_TYPE_RAISED_PRI = "raised_pri"; + public static final String WAIT_TYPE_CHANGED_DUE = "changed_due"; + + @Override + public ContentValues getDefaultValues() { + return defaultValues; + } + + @Override + public long getId() { + return getIdHelper(ID); + } + + public static final Property[] PROPERTIES = generateProperties(WaitingOnMe.class); + + private static final Creator CREATOR = new ModelCreator(WaitingOnMe.class); + + @Override + protected Creator getCreator() { + return CREATOR; + } + +} diff --git a/api/src/com/todoroo/astrid/data/WaitingOnMeOutstanding.java b/api/src/com/todoroo/astrid/data/WaitingOnMeOutstanding.java new file mode 100644 index 000000000..2e8479983 --- /dev/null +++ b/api/src/com/todoroo/astrid/data/WaitingOnMeOutstanding.java @@ -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 WaitingOnMeOutstanding extends OutstandingEntry { + + /** table for this model */ + public static final Table TABLE = new Table("waiting_on_me_outstanding", WaitingOnMeOutstanding.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(WaitingOnMeOutstanding.class); + + @Override + public ContentValues getDefaultValues() { + return defaultValues; + } + + @Override + public long getId() { + return getIdHelper(ID); + } + + public static final Creator CREATOR = new ModelCreator(WaitingOnMeOutstanding.class); + + @Override + protected Creator getCreator() { + return CREATOR; + } + +} diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java index ba9b89e97..902b51d7f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -58,6 +58,8 @@ import com.todoroo.astrid.dao.TaskListMetadataOutstandingDao; import com.todoroo.astrid.dao.TaskOutstandingDao; import com.todoroo.astrid.dao.UserActivityDao; import com.todoroo.astrid.dao.UserActivityOutstandingDao; +import com.todoroo.astrid.dao.WaitingOnMeDao; +import com.todoroo.astrid.dao.WaitingOnMeOutstandingDao; import com.todoroo.astrid.data.OutstandingEntry; import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.TagData; @@ -69,6 +71,7 @@ import com.todoroo.astrid.data.TaskListMetadataOutstanding; import com.todoroo.astrid.data.TaskOutstanding; import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.UserActivity; +import com.todoroo.astrid.data.WaitingOnMe; import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.widget.TasksWidget; @@ -111,6 +114,12 @@ public class ActFmSyncThread { @Autowired private TaskListMetadataOutstandingDao taskListMetadataOutstandingDao; + @Autowired + private WaitingOnMeDao waitingOnMeDao; + + @Autowired + private WaitingOnMeOutstandingDao waitingOnMeOutstandingDao; + private String token; private boolean syncMigration = false; @@ -131,7 +140,8 @@ public class ActFmSyncThread { TYPE_TAG, TYPE_ACTIVITY, TYPE_ATTACHMENT, - TYPE_TASK_LIST_METADATA + TYPE_TASK_LIST_METADATA, + TYPE_WAITING_ON_ME } private static volatile ActFmSyncThread instance; @@ -141,14 +151,15 @@ public class ActFmSyncThread { synchronized(ActFmSyncThread.class) { if (instance == null) { initializeSyncComponents(PluginServices.getTaskDao(), PluginServices.getTagDataDao(), PluginServices.getUserActivityDao(), - PluginServices.getTaskAttachmentDao(), PluginServices.getTaskListMetadataDao()); + PluginServices.getTaskAttachmentDao(), PluginServices.getTaskListMetadataDao(), PluginServices.getWaitingOnMeDao()); } } } return instance; } - public static ActFmSyncThread initializeSyncComponents(TaskDao taskDao, TagDataDao tagDataDao, UserActivityDao userActivityDao, TaskAttachmentDao taskAttachmentDao, TaskListMetadataDao taskListMetadataDao) { + public static ActFmSyncThread initializeSyncComponents(TaskDao taskDao, TagDataDao tagDataDao, UserActivityDao userActivityDao, + TaskAttachmentDao taskAttachmentDao, TaskListMetadataDao taskListMetadataDao, WaitingOnMeDao waitingOnMeDao) { if (instance == null) { synchronized(ActFmSyncThread.class) { if (instance == null) { @@ -163,6 +174,7 @@ public class ActFmSyncThread { userActivityDao.addListener(new SyncDatabaseListener(instance, ModelType.TYPE_ACTIVITY)); taskAttachmentDao.addListener(new SyncDatabaseListener(instance, ModelType.TYPE_ATTACHMENT)); taskListMetadataDao.addListener(new TaskListMetadataSyncDatabaseListener(instance, waitingPool, ModelType.TYPE_TASK_LIST_METADATA)); + waitingOnMeDao.addListener(new SyncDatabaseListener(instance, ModelType.TYPE_WAITING_ON_ME)); instance.startSyncThread(); } @@ -262,6 +274,7 @@ public class ActFmSyncThread { enqueueMessage(BriefMe.instantiateBriefMeForClass(Task.class, NameMaps.PUSHED_AT_TASKS), DEFAULT_REFRESH_RUNNABLE); enqueueMessage(BriefMe.instantiateBriefMeForClass(TagData.class, NameMaps.PUSHED_AT_TAGS), DEFAULT_REFRESH_RUNNABLE); enqueueMessage(BriefMe.instantiateBriefMeForClass(User.class, NameMaps.PUSHED_AT_USERS), DEFAULT_REFRESH_RUNNABLE); + enqueueMessage(BriefMe.instantiateBriefMeForClass(WaitingOnMe.class, NameMaps.PUSHED_AT_WAITING_ON_ME), DEFAULT_REFRESH_RUNNABLE); setTimeForBackgroundSync(false); } @@ -435,6 +448,7 @@ public class ActFmSyncThread { constructChangesHappenedFromOutstandingTable(Task.class, taskDao, taskOutstandingDao); constructChangesHappenedFromOutstandingTable(TagData.class, tagDataDao, tagOutstandingDao); constructChangesHappenedFromOutstandingTable(UserActivity.class, userActivityDao, userActivityOutstandingDao); + constructChangesHappenedFromOutstandingTable(WaitingOnMe.class, waitingOnMeDao, waitingOnMeOutstandingDao); constructChangesHappenedForTaskListMetadata(taskListMetadataDao, taskListMetadataOutstandingDao); } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/AcknowledgeChange.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/AcknowledgeChange.java index 49d3d2716..dab4c17db 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/AcknowledgeChange.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/AcknowledgeChange.java @@ -31,6 +31,8 @@ public class AcknowledgeChange extends ServerToClientMessage { dao = PluginServices.getTaskAttachmentOutstandingDao(); else if (NameMaps.TABLE_ID_TASK_LIST_METADATA.equals(table)) dao = PluginServices.getTaskListMetadataOutstandingDao(); + else if (NameMaps.TABLE_ID_WAITING_ON_ME.equals(table)) + dao = PluginServices.getWaitingOnMeOutstandingDao(); else dao = null; } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java index fc0219665..6cd08b7f4 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java @@ -15,6 +15,7 @@ import com.todoroo.astrid.data.TaskAttachment; import com.todoroo.astrid.data.TaskListMetadata; import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.UserActivity; +import com.todoroo.astrid.data.WaitingOnMe; @SuppressWarnings("nls") public class NameMaps { @@ -33,6 +34,7 @@ public class NameMaps { public static final String TABLE_ID_HISTORY = "history"; public static final String TABLE_ID_ATTACHMENTS = "task_attachments"; public static final String TABLE_ID_TASK_LIST_METADATA = "task_list_metadata"; + public static final String TABLE_ID_WAITING_ON_ME = "waiting_on_mes"; private static final String PUSHED_AT_PREFIX = "pushed_at"; public static final String PUSHED_AT_TASKS = PUSHED_AT_PREFIX + "_" + TABLE_ID_TASKS; @@ -40,6 +42,7 @@ public class NameMaps { public static final String PUSHED_AT_USERS = PUSHED_AT_PREFIX + "_" + TABLE_ID_USERS; public static final String PUSHED_AT_ACTIVITY = PUSHED_AT_PREFIX + "_" + TABLE_ID_USER_ACTIVITY; public static final String PUSHED_AT_TASK_LIST_METADATA = PUSHED_AT_PREFIX + "_" + TABLE_ID_TASK_LIST_METADATA; + public static final String PUSHED_AT_WAITING_ON_ME = PUSHED_AT_PREFIX + "_" + TABLE_ID_WAITING_ON_ME; static { // Hardcoded local tables mapped to corresponding server names @@ -51,6 +54,7 @@ public class NameMaps { TABLE_LOCAL_TO_SERVER.put(UserActivity.TABLE, TABLE_ID_USER_ACTIVITY); TABLE_LOCAL_TO_SERVER.put(TaskAttachment.TABLE, TABLE_ID_ATTACHMENTS); TABLE_LOCAL_TO_SERVER.put(TaskListMetadata.TABLE, TABLE_ID_TASK_LIST_METADATA); + TABLE_LOCAL_TO_SERVER.put(WaitingOnMe.TABLE, TABLE_ID_WAITING_ON_ME); // Reverse the mapping to construct the server to local map TABLE_SERVER_TO_LOCAL = AndroidUtilities.reverseMap(TABLE_LOCAL_TO_SERVER); @@ -89,6 +93,8 @@ public class NameMaps { return computeSyncableProperties(TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER.keySet(), TASK_ATTACHMENT_PROPERTIES_EXCLUDED); else if (TABLE_ID_TASK_LIST_METADATA.equals(table)) return computeSyncableProperties(TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER.keySet(), TASK_LIST_METADATA_PROPERTIES_EXCLUDED); + else if (TABLE_ID_WAITING_ON_ME.equals(table)) + return computeSyncableProperties(WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER.keySet(), WAITING_ON_ME_PROPERTIES_EXCLUDED); return null; } @@ -323,13 +329,45 @@ public class NameMaps { TASK_LIST_METADATA_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities.reverseMap(TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER); } + // ---------- + // WaitingOnMe + // ---------- + private static final Map, String> WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER; + private static final Map> WAITING_ON_ME_COLUMN_NAMES_TO_PROPERTIES; + private static final Map WAITING_ON_ME_COLUMNS_LOCAL_TO_SERVER; + private static final Map> WAITING_ON_ME_PROPERTIES_SERVER_TO_LOCAL; + private static final Set WAITING_ON_ME_PROPERTIES_EXCLUDED; + + private static void putWaitingOnMePropertyToServerName(Property property, String serverName, boolean writeable) { + putPropertyToServerName(property, serverName, WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER, WAITING_ON_ME_COLUMN_NAMES_TO_PROPERTIES, + WAITING_ON_ME_COLUMNS_LOCAL_TO_SERVER, WAITING_ON_ME_PROPERTIES_EXCLUDED, writeable); + } + + static { + WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER = new HashMap, String>(); + WAITING_ON_ME_COLUMN_NAMES_TO_PROPERTIES = new HashMap>(); + WAITING_ON_ME_COLUMNS_LOCAL_TO_SERVER = new HashMap(); + WAITING_ON_ME_PROPERTIES_EXCLUDED = new HashSet(); + + putWaitingOnMePropertyToServerName(WaitingOnMe.UUID, "uuid", false); + putWaitingOnMePropertyToServerName(WaitingOnMe.WAITING_USER_ID, "waiting_user_id", false); + putWaitingOnMePropertyToServerName(WaitingOnMe.TASK_UUID, "task_id", false); + putWaitingOnMePropertyToServerName(WaitingOnMe.WAIT_TYPE, "wait_type", false); + putWaitingOnMePropertyToServerName(WaitingOnMe.CREATED_AT, "created_at", false); + putWaitingOnMePropertyToServerName(WaitingOnMe.DELETED_AT, "deleted_at", true); + putWaitingOnMePropertyToServerName(WaitingOnMe.READ_AT, "read_at", true); + + // Reverse the mapping to construct the server to local map + WAITING_ON_ME_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities.reverseMap(WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER); + } + // ---------- // Mapping helpers // ---------- private static B mapColumnName(String table, A col, Map taskMap, Map tagMap, Map userMap, - Map userActivityMap, Map taskAttachmentMap, Map taskListMetadataMap) { + Map userActivityMap, Map taskAttachmentMap, Map taskListMetadataMap, Map waitingOnMeMap) { Map map = null; if (TABLE_ID_TASKS.equals(table)) map = taskMap; @@ -343,6 +381,8 @@ public class NameMaps { map = taskAttachmentMap; else if (TABLE_ID_TASK_LIST_METADATA.equals(table)) map = taskListMetadataMap; + else if (TABLE_ID_WAITING_ON_ME.equals(table)) + map = waitingOnMeMap; if (map == null) return null; @@ -369,28 +409,39 @@ public class NameMaps { } else if (TABLE_ID_TASK_LIST_METADATA.equals(table)) { if (TASK_LIST_METADATA_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) return !TASK_LIST_METADATA_PROPERTIES_EXCLUDED.contains(column); + } else if (TABLE_ID_WAITING_ON_ME.equals(table)) { + if (WAITING_ON_ME_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) + return !WAITING_ON_ME_PROPERTIES_EXCLUDED.contains(column); } return false; } public static String localPropertyToServerColumnName(String table, Property localProperty) { - return mapColumnName(table, localProperty, TASK_PROPERTIES_LOCAL_TO_SERVER, TAG_DATA_PROPERTIES_LOCAL_TO_SERVER, USER_PROPERTIES_LOCAL_TO_SERVER, - USER_ACTIVITY_PROPERTIES_LOCAL_TO_SERVER, TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER, TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER); + return mapColumnName(table, localProperty, TASK_PROPERTIES_LOCAL_TO_SERVER, TAG_DATA_PROPERTIES_LOCAL_TO_SERVER, + USER_PROPERTIES_LOCAL_TO_SERVER, USER_ACTIVITY_PROPERTIES_LOCAL_TO_SERVER, + TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER, TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER, + WAITING_ON_ME_PROPERTIES_LOCAL_TO_SERVER); } public static String localColumnNameToServerColumnName(String table, String localColumn) { - return mapColumnName(table, localColumn, TASK_COLUMNS_LOCAL_TO_SERVER, TAG_DATA_COLUMNS_LOCAL_TO_SERVER, USER_COLUMNS_LOCAL_TO_SERVER, - USER_ACTIVITY_COLUMNS_LOCAL_TO_SERVER, TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER, TASK_LIST_METADATA_COLUMNS_LOCAL_TO_SERVER); + return mapColumnName(table, localColumn, TASK_COLUMNS_LOCAL_TO_SERVER, TAG_DATA_COLUMNS_LOCAL_TO_SERVER, + USER_COLUMNS_LOCAL_TO_SERVER, USER_ACTIVITY_COLUMNS_LOCAL_TO_SERVER, + TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER, TASK_LIST_METADATA_COLUMNS_LOCAL_TO_SERVER, + WAITING_ON_ME_COLUMNS_LOCAL_TO_SERVER); } public static Property localColumnNameToProperty(String table, String localColumn) { - return mapColumnName(table, localColumn, TASK_COLUMN_NAMES_TO_PROPERTIES, TAG_DATA_COLUMN_NAMES_TO_PROPERTIES, USER_COLUMN_NAMES_TO_PROPERTIES, - USER_ACTIVITY_COLUMN_NAMES_TO_PROPERTIES, TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES, TASK_LIST_METADATA_COLUMN_NAMES_TO_PROPERTIES); + return mapColumnName(table, localColumn, TASK_COLUMN_NAMES_TO_PROPERTIES, TAG_DATA_COLUMN_NAMES_TO_PROPERTIES, + USER_COLUMN_NAMES_TO_PROPERTIES, USER_ACTIVITY_COLUMN_NAMES_TO_PROPERTIES, + TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES, TASK_LIST_METADATA_COLUMN_NAMES_TO_PROPERTIES, + WAITING_ON_ME_COLUMN_NAMES_TO_PROPERTIES); } public static Property serverColumnNameToLocalProperty(String table, String serverColumn) { - return mapColumnName(table, serverColumn, TASK_PROPERTIES_SERVER_TO_LOCAL, TAG_DATA_PROPERTIES_SERVER_TO_LOCAL, USER_PROPERTIES_SERVER_TO_LOCAL, - USER_ACTIVITY_PROPERTIES_SERVER_TO_LOCAL, TASK_ATTACHMENT_PROPERTIES_SERVER_TO_LOCAL, TASK_LIST_METADATA_PROPERTIES_SERVER_TO_LOCAL); + return mapColumnName(table, serverColumn, TASK_PROPERTIES_SERVER_TO_LOCAL, TAG_DATA_PROPERTIES_SERVER_TO_LOCAL, + USER_PROPERTIES_SERVER_TO_LOCAL, USER_ACTIVITY_PROPERTIES_SERVER_TO_LOCAL, + TASK_ATTACHMENT_PROPERTIES_SERVER_TO_LOCAL, TASK_LIST_METADATA_PROPERTIES_SERVER_TO_LOCAL, + WAITING_ON_ME_PROPERTIES_SERVER_TO_LOCAL); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ServerToClientMessage.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ServerToClientMessage.java index d4a51febb..6203737e2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ServerToClientMessage.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ServerToClientMessage.java @@ -9,6 +9,7 @@ import com.todoroo.astrid.data.TaskAttachment; import com.todoroo.astrid.data.TaskListMetadata; import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.UserActivity; +import com.todoroo.astrid.data.WaitingOnMe; @SuppressWarnings("nls") public abstract class ServerToClientMessage { @@ -60,6 +61,8 @@ public abstract class ServerToClientMessage { return new MakeChanges(json, PluginServices.getTaskAttachmentDao()); else if (NameMaps.TABLE_ID_TASK_LIST_METADATA.equals(table)) return new MakeChanges(json, PluginServices.getTaskListMetadataDao()); + else if (NameMaps.TABLE_ID_WAITING_ON_ME.equals(table)) + return new MakeChanges(json, PluginServices.getWaitingOnMeDao()); else return null; } @@ -78,6 +81,8 @@ public abstract class ServerToClientMessage { return new NowBriefed(json, PluginServices.getTaskAttachmentDao()); else if (NameMaps.TABLE_ID_TASK_LIST_METADATA.equals(table)) return new NowBriefed(json, PluginServices.getTaskListMetadataDao()); + else if (NameMaps.TABLE_ID_WAITING_ON_ME.equals(table)) + return new NowBriefed(json, PluginServices.getWaitingOnMeDao()); else return null; } diff --git a/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java b/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java index 23896cdb6..59f612b49 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/PluginServices.java @@ -27,6 +27,8 @@ import com.todoroo.astrid.dao.TaskOutstandingDao; import com.todoroo.astrid.dao.UserActivityDao; import com.todoroo.astrid.dao.UserActivityOutstandingDao; import com.todoroo.astrid.dao.UserDao; +import com.todoroo.astrid.dao.WaitingOnMeDao; +import com.todoroo.astrid.dao.WaitingOnMeOutstandingDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.service.AddOnService; @@ -103,6 +105,12 @@ public final class PluginServices { @Autowired TaskListMetadataOutstandingDao taskListMetadataOutstandingDao; + @Autowired + WaitingOnMeDao waitingOnMeDao; + + @Autowired + WaitingOnMeOutstandingDao waitingOnMeOutstandingDao; + @Autowired ActFmPreferenceService actFmPreferenceService; @@ -212,6 +220,14 @@ public final class PluginServices { return getInstance().taskListMetadataOutstandingDao; } + public static WaitingOnMeDao getWaitingOnMeDao() { + return getInstance().waitingOnMeDao; + } + + public static WaitingOnMeOutstandingDao getWaitingOnMeOutstandingDao() { + return getInstance().waitingOnMeOutstandingDao; + } + public static ActFmPreferenceService getActFmPreferenceService() { return getInstance().actFmPreferenceService; } diff --git a/astrid/src/com/todoroo/astrid/dao/Database.java b/astrid/src/com/todoroo/astrid/dao/Database.java index c77ac3482..a51b76807 100644 --- a/astrid/src/com/todoroo/astrid/dao/Database.java +++ b/astrid/src/com/todoroo/astrid/dao/Database.java @@ -32,6 +32,8 @@ import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.UserActivity; import com.todoroo.astrid.data.UserActivityOutstanding; +import com.todoroo.astrid.data.WaitingOnMe; +import com.todoroo.astrid.data.WaitingOnMeOutstanding; import com.todoroo.astrid.provider.Astrid2TaskProvider; import com.todoroo.astrid.provider.Astrid3ContentProvider; import com.todoroo.astrid.widget.TasksWidget; @@ -51,7 +53,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 = 30; + public static final int VERSION = 31; /** * Database name (must be unique) @@ -375,6 +377,10 @@ public class Database extends AbstractDatabase { tryExecSQL(addColumnSql(User.TABLE, User.FIRST_NAME, visitor, null)); tryExecSQL(addColumnSql(User.TABLE, User.LAST_NAME, visitor, null)); + case 30: + tryExecSQL(createTableSql(visitor, WaitingOnMe.TABLE.name, WaitingOnMe.PROPERTIES)); + tryExecSQL(createTableSql(visitor, WaitingOnMeOutstanding.TABLE.name, WaitingOnMeOutstanding.PROPERTIES)); + return true; } diff --git a/astrid/src/com/todoroo/astrid/dao/WaitingOnMeDao.java b/astrid/src/com/todoroo/astrid/dao/WaitingOnMeDao.java new file mode 100644 index 000000000..91fe2d922 --- /dev/null +++ b/astrid/src/com/todoroo/astrid/dao/WaitingOnMeDao.java @@ -0,0 +1,23 @@ +package com.todoroo.astrid.dao; + +import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.astrid.actfm.sync.messages.NameMaps; +import com.todoroo.astrid.data.WaitingOnMe; + +public class WaitingOnMeDao extends RemoteModelDao { + + @Autowired + private Database database; + + public WaitingOnMeDao() { + super(WaitingOnMe.class); + DependencyInjectionService.getInstance().inject(this); + setDatabase(database); + } + + @Override + protected boolean shouldRecordOutstandingEntry(String columnName, Object value) { + return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_WAITING_ON_ME, columnName); + } +} diff --git a/astrid/src/com/todoroo/astrid/dao/WaitingOnMeOutstandingDao.java b/astrid/src/com/todoroo/astrid/dao/WaitingOnMeOutstandingDao.java new file mode 100644 index 000000000..0edb6783d --- /dev/null +++ b/astrid/src/com/todoroo/astrid/dao/WaitingOnMeOutstandingDao.java @@ -0,0 +1,11 @@ +package com.todoroo.astrid.dao; + +import com.todoroo.astrid.data.WaitingOnMeOutstanding; + +public class WaitingOnMeOutstandingDao extends OutstandingEntryDao { + + public WaitingOnMeOutstandingDao() { + super(WaitingOnMeOutstanding.class); + } + +} diff --git a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java index 79819d9a5..b4375d29f 100644 --- a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java +++ b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java @@ -31,6 +31,8 @@ import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UserActivityDao; import com.todoroo.astrid.dao.UserActivityOutstandingDao; import com.todoroo.astrid.dao.UserDao; +import com.todoroo.astrid.dao.WaitingOnMeDao; +import com.todoroo.astrid.dao.WaitingOnMeOutstandingDao; import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksMetadataService; import com.todoroo.astrid.gtasks.GtasksPreferenceService; @@ -91,6 +93,8 @@ public class AstridDependencyInjector extends AbstractDependencyInjector { injectables.put("taskAttachmentOutstandingDao", TaskAttachmentOutstandingDao.class); injectables.put("taskListMetadataDao", TaskListMetadataDao.class); injectables.put("taskListMetadataOutstandingDao", TaskListMetadataOutstandingDao.class); + injectables.put("waitingOnMeDao", WaitingOnMeDao.class); + injectables.put("waitingOnMeOutstandingDao", WaitingOnMeOutstandingDao.class); // com.todoroo.astrid.service injectables.put("taskService", TaskService.class); diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 42d293061..df55492f5 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -54,6 +54,7 @@ import com.todoroo.astrid.dao.TaskAttachmentDao; import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskListMetadataDao; import com.todoroo.astrid.dao.UserActivityDao; +import com.todoroo.astrid.dao.WaitingOnMeDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; @@ -109,6 +110,8 @@ public class StartupService { @Autowired TaskListMetadataDao taskListMetadataDao; + @Autowired WaitingOnMeDao waitingOnMeDao; + @Autowired MetadataService metadataService; @Autowired Database database; @@ -222,7 +225,7 @@ public class StartupService { abTestInvoker.reportAcquisition(); initializeDatabaseListeners(); - ActFmSyncThread.initializeSyncComponents(taskDao, tagDataDao, userActivityDao, taskAttachmentDao, taskListMetadataDao); + ActFmSyncThread.initializeSyncComponents(taskDao, tagDataDao, userActivityDao, taskAttachmentDao, taskListMetadataDao, waitingOnMeDao); // perform startup activities in a background thread new Thread(new Runnable() {