From 004f1dd83e92e83b3cc9cf135c8c298a4333406e Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 15 Jul 2014 12:01:55 -0500 Subject: [PATCH] Move methods out of RemoteModelDao --- .../todoroo/astrid/dao/RemoteModelDao.java | 40 ------------------- .../com/todoroo/astrid/dao/TagDataDao.java | 25 ++++++++++++ .../java/com/todoroo/astrid/dao/TaskDao.java | 15 +++++++ 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/astrid/src/main/java/com/todoroo/astrid/dao/RemoteModelDao.java b/astrid/src/main/java/com/todoroo/astrid/dao/RemoteModelDao.java index adfc18876..12cf53fe1 100644 --- a/astrid/src/main/java/com/todoroo/astrid/dao/RemoteModelDao.java +++ b/astrid/src/main/java/com/todoroo/astrid/dao/RemoteModelDao.java @@ -1,10 +1,6 @@ package com.todoroo.astrid.dao; -import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.DatabaseDao; -import com.todoroo.andlib.data.Property; -import com.todoroo.andlib.data.TodorooCursor; -import com.todoroo.andlib.sql.Query; import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.helper.UUIDHelper; @@ -30,40 +26,4 @@ public class RemoteModelDao extends DatabaseDao... properties) { - TodorooCursor cursor = fetchItem(uuid, properties); - return returnFetchResult(cursor); - } - - /** - * Returns cursor to object corresponding to the given identifier - * - * @param properties - * properties to read - */ - protected TodorooCursor fetchItem(String uuid, Property... properties) { - TodorooCursor cursor = query( - Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid))); - cursor.moveToFirst(); - return new TodorooCursor<>(cursor, properties); - } - - public String uuidFromLocalId(long localId) { - TodorooCursor 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(); - } - } - - } diff --git a/astrid/src/main/java/com/todoroo/astrid/dao/TagDataDao.java b/astrid/src/main/java/com/todoroo/astrid/dao/TagDataDao.java index 6e94f07f4..9ef375fae 100644 --- a/astrid/src/main/java/com/todoroo/astrid/dao/TagDataDao.java +++ b/astrid/src/main/java/com/todoroo/astrid/dao/TagDataDao.java @@ -5,6 +5,10 @@ */ package com.todoroo.astrid.dao; +import com.todoroo.andlib.data.Property; +import com.todoroo.andlib.data.TodorooCursor; +import com.todoroo.andlib.sql.Query; +import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.TagData; import javax.inject.Inject; @@ -23,5 +27,26 @@ public class TagDataDao extends RemoteModelDao { super(TagData.class); setDatabase(database); } + + /** + * Fetch a model object by UUID + */ + public TagData fetch(String uuid, Property... properties) { + TodorooCursor cursor = fetchItem(uuid, properties); + return returnFetchResult(cursor); + } + + /** + * Returns cursor to object corresponding to the given identifier + * + * @param properties + * properties to read + */ + private TodorooCursor fetchItem(String uuid, Property... properties) { + TodorooCursor cursor = query( + Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid))); + cursor.moveToFirst(); + return new TodorooCursor<>(cursor, properties); + } } diff --git a/astrid/src/main/java/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/main/java/com/todoroo/astrid/dao/TaskDao.java index f3a950b06..95c06d767 100644 --- a/astrid/src/main/java/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/main/java/com/todoroo/astrid/dao/TaskDao.java @@ -8,6 +8,7 @@ package com.todoroo.astrid.dao; import android.content.ContentValues; import android.database.sqlite.SQLiteConstraintException; +import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.sql.Criterion; @@ -15,6 +16,7 @@ import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; +import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.TaskApiDao; import com.todoroo.astrid.reminders.ReminderService; @@ -107,6 +109,19 @@ public class TaskDao extends RemoteModelDao { } } + public String uuidFromLocalId(long localId) { + TodorooCursor 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(); + } + } + // --- delete /**