|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.todoroo.astrid.dao;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
@ -27,5 +30,29 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
|
|
|
|
|
return super.createNew(item);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public RTYPE fetch(String uuid, Property<?>... properties) {
|
|
|
|
|
TodorooCursor<RTYPE> cursor = fetchItem(uuid, properties);
|
|
|
|
|
return returnFetchResult(cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns cursor to object corresponding to the given identifier
|
|
|
|
|
*
|
|
|
|
|
* @param database
|
|
|
|
|
* @param table
|
|
|
|
|
* name of table
|
|
|
|
|
* @param properties
|
|
|
|
|
* properties to read
|
|
|
|
|
* @param id
|
|
|
|
|
* id of item
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
protected TodorooCursor<RTYPE> fetchItem(String uuid, Property<?>... properties) {
|
|
|
|
|
TodorooCursor<RTYPE> cursor = query(
|
|
|
|
|
Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid)));
|
|
|
|
|
cursor.moveToFirst();
|
|
|
|
|
return new TodorooCursor<RTYPE>(cursor, properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|