Remove outstanding table

pull/46/head
Alex Baker 11 years ago
parent ea695ead9c
commit 283423cd27

@ -21,7 +21,6 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import java.lang.reflect.Field;
import java.util.ArrayList;
/**
@ -128,22 +127,6 @@ abstract public class AbstractDatabase {
throw new UnsupportedOperationException("Unknown model class " + modelType); //$NON-NLS-1$
}
public final Table getOutstandingTable(Class<? extends AbstractModel> modelType) {
try {
Field f = modelType.getDeclaredField("OUTSTANDING_MODEL");
Class<? extends AbstractModel> outstandingModelType = (Class<? extends AbstractModel>) f.get(null);
return getTable(outstandingModelType);
} catch (NoSuchFieldException n) {
//
} catch (IllegalAccessException i) {
//
} catch (ClassCastException c) {
throw new RuntimeException("Outstanding model class for type " + modelType + " could not be cast");
}
return null;
}
protected synchronized final void initializeHelper() {
if(helper == null) {
if(ContextManager.getContext() == null) {
@ -247,7 +230,7 @@ abstract public class AbstractDatabase {
* @see android.database.sqlite.SQLiteDatabase#insert(String table, String nullColumnHack, ContentValues values)
*/
public synchronized long insert(String table, String nullColumnHack, ContentValues values) {
long result = -1;
long result;
try {
result = getDatabase().insertOrThrow(table, nullColumnHack, values);
} catch (SQLiteConstraintException e) { // Throw these exceptions

@ -7,24 +7,17 @@ package com.todoroo.andlib.data;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteTransactionListener;
import android.util.Log;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.OutstandingEntry;
import com.todoroo.astrid.data.SyncFlags;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@ -44,8 +37,6 @@ public class DatabaseDao<TYPE extends AbstractModel> {
private Table table;
protected Table outstandingTable;
private AbstractDatabase database;
@Autowired
@ -83,7 +74,6 @@ public class DatabaseDao<TYPE extends AbstractModel> {
}
this.database = database;
table = database.getTable(modelClass);
outstandingTable = database.getOutstandingTable(modelClass);
}
// --- listeners
@ -203,57 +193,8 @@ public class DatabaseDao<TYPE extends AbstractModel> {
* @return # of updated items
*/
public int update(Criterion where, TYPE template) {
boolean recordOutstanding = shouldRecordOutstanding(template);
final AtomicInteger result = new AtomicInteger(0);
if (recordOutstanding) {
TodorooCursor<TYPE> toUpdate = query(Query.select(AbstractModel.ID_PROPERTY).where(where));
Long[] ids = null;
try {
ids = new Long[toUpdate.getCount()];
for (int i = 0; i < toUpdate.getCount(); i++) {
toUpdate.moveToNext();
ids[i] = toUpdate.get(AbstractModel.ID_PROPERTY);
}
} finally {
toUpdate.close();
}
if (toUpdate.getCount() == 0) {
return 0;
}
synchronized (database) {
database.getDatabase().beginTransactionWithListener(new SQLiteTransactionListener() {
@Override
public void onRollback() {
Log.e(ERROR_TAG, "Error updating rows", new Throwable()); //$NON-NLS-1$
result.set(0);
}
@Override
public void onCommit() {/**/}
@Override
public void onBegin() {/**/}
});
try {
result.set(database.update(table.name, template.getSetValues(),
where.toString(), null));
if (result.get() > 0) {
for (Long id : ids) {
createOutstandingEntries(id, template.getSetValues());
}
}
database.getDatabase().setTransactionSuccessful();
} finally {
database.getDatabase().endTransaction();
}
}
return result.get();
} else {
return database.update(table.name, template.getSetValues(),
where.toString(), null);
}
return database.update(table.name, template.getSetValues(),
where.toString(), null);
}
/**
@ -281,44 +222,10 @@ public class DatabaseDao<TYPE extends AbstractModel> {
public boolean makeChange();
}
protected boolean shouldRecordOutstanding(TYPE item) {
return (outstandingTable != null) &&
!item.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES);
}
private boolean insertOrUpdateAndRecordChanges(TYPE item, ContentValues values, DatabaseChangeOp op) {
boolean recordOutstanding = shouldRecordOutstanding(item);
private boolean insertOrUpdateAndRecordChanges(TYPE item, DatabaseChangeOp op) {
final AtomicBoolean result = new AtomicBoolean(false);
synchronized(database) {
if (recordOutstanding) { // begin transaction
database.getDatabase().beginTransactionWithListener(new SQLiteTransactionListener() {
@Override
public void onRollback() {
Log.e(ERROR_TAG, "Error inserting or updating rows", new Throwable()); //$NON-NLS-1$
result.set(false);
}
@Override
public void onCommit() {/**/}
@Override
public void onBegin() {/**/}
});
}
int numOutstanding = 0;
try {
result.set(op.makeChange());
if(result.get()) {
if (recordOutstanding && ((numOutstanding = createOutstandingEntries(item.getId(), values)) != -1)) // Create entries for setValues in outstanding table
{
database.getDatabase().setTransactionSuccessful();
}
}
} finally {
if (recordOutstanding) // commit transaction
{
database.getDatabase().endTransaction();
}
}
result.set(op.makeChange());
if (result.get()) {
onModelUpdated(item);
item.markSaved();
@ -348,7 +255,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
return result;
}
};
return insertOrUpdateAndRecordChanges(item, item.getMergedValues(), insert);
return insertOrUpdateAndRecordChanges(item, insert);
}
/**
@ -370,46 +277,11 @@ public class DatabaseDao<TYPE extends AbstractModel> {
AbstractModel.ID_PROPERTY.eq(item.getId()).toString(), null) > 0;
}
};
return insertOrUpdateAndRecordChanges(item, values, update);
}
protected int createOutstandingEntries(long modelId, ContentValues modelSetValues) {
Set<Entry<String, Object>> entries = modelSetValues.valueSet();
long now = DateUtilities.now();
int count = 0;
for (Entry<String, Object> entry : entries) {
if (entry.getValue() != null && shouldRecordOutstandingEntry(entry.getKey(), entry.getValue())) {
AbstractModel m;
try {
m = outstandingTable.modelClass.newInstance();
} catch (IllegalAccessException e) {
return -1;
} catch (InstantiationException e2) {
return -1;
}
m.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, modelId);
m.setValue(OutstandingEntry.COLUMN_STRING_PROPERTY, entry.getKey());
m.setValue(OutstandingEntry.VALUE_STRING_PROPERTY, entry.getValue().toString());
m.setValue(OutstandingEntry.CREATED_AT_PROPERTY, now);
database.insert(outstandingTable.name, null, m.getSetValues());
count++;
}
}
return count;
}
/**
* Returns true if an entry in the outstanding table should be recorded for this
* column. Subclasses can override to return false for insignificant columns
* (e.g. Task.DETAILS, last modified, etc.)
*/
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return true;
return insertOrUpdateAndRecordChanges(item, update);
}
// --- helper methods
/**
* Returns cursor to object corresponding to the given identifier
* @param properties

@ -30,9 +30,6 @@ public class Metadata extends AbstractModel {
/** table for this model */
public static final Table TABLE = new Table("metadata", Metadata.class);
/** changes to metadata (specifically tags) are recorded in the task outstanding table */
public static final Class<? extends OutstandingEntry<Task>> OUTSTANDING_MODEL = TaskOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -1,25 +0,0 @@
package com.todoroo.astrid.data;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
public abstract class OutstandingEntry<TYPE extends RemoteModel> extends AbstractModel {
public static final String ENTITY_ID_PROPERTY_NAME = "entityId";
public static final LongProperty ENTITY_ID_PROPERTY = new LongProperty(null, ENTITY_ID_PROPERTY_NAME);
public static final String COLUMN_STRING_PROPERTY_NAME = "columnString";
public static final StringProperty COLUMN_STRING_PROPERTY = new StringProperty(null, COLUMN_STRING_PROPERTY_NAME);
public static final String VALUE_STRING_PROPERTY_NAME = "valueString";
public static final StringProperty VALUE_STRING_PROPERTY = new StringProperty(null, VALUE_STRING_PROPERTY_NAME);
public static final String CREATED_AT_PROPERTY_NAME = "createdAt";
public static final LongProperty CREATED_AT_PROPERTY = new LongProperty(null, CREATED_AT_PROPERTY_NAME);
}

@ -31,9 +31,6 @@ public final class TagData extends RemoteModel {
/** table for this model */
public static final Table TABLE = new Table("tagdata", TagData.class);
/** model class for entries in the outstanding table */
public static final Class<? extends OutstandingEntry<TagData>> OUTSTANDING_MODEL = TagOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -15,9 +15,6 @@ public class TagMetadata extends AbstractModel {
public static final Table TABLE = new Table("tag_metadata", TagMetadata.class);
/** changes to metadata (specifically members) are recorded in the tag outstanding table */
public static final Class<? extends OutstandingEntry<TagData>> OUTSTANDING_MODEL = TagOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -1,62 +0,0 @@
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;
public class TagOutstanding extends OutstandingEntry<TagData> {
/** 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;
}
}

@ -32,9 +32,6 @@ public final class TaskAttachment extends RemoteModel {
/** table for this model */
public static final Table TABLE = new Table("task_attachments", TaskAttachment.class);
/** model class for entries in the outstanding table */
public static final Class<? extends OutstandingEntry<TaskAttachment>> OUTSTANDING_MODEL = TaskAttachmentOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -1,62 +0,0 @@
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;
public class TaskAttachmentOutstanding extends OutstandingEntry<TaskAttachment> {
/** table for this model */
public static final Table TABLE = new Table("task_attachment_outstanding", TaskAttachmentOutstanding.class);
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
public static final LongProperty TASK_ATTACHMENT_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_ATTACHMENT_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(TaskAttachmentOutstanding.class);
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
public static final Creator<TaskAttachmentOutstanding> CREATOR = new ModelCreator<TaskAttachmentOutstanding>(TaskAttachmentOutstanding.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}

@ -32,9 +32,6 @@ public final class TaskListMetadata extends RemoteModel {
/** table for this model */
public static final Table TABLE = new Table("task_list_metadata", TaskListMetadata.class);
/** model class for entries in the outstanding table */
public static final Class<? extends OutstandingEntry<TaskListMetadata>> OUTSTANDING_MODEL = TaskListMetadataOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -1,62 +0,0 @@
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;
public class TaskListMetadataOutstanding extends OutstandingEntry<TaskListMetadata> {
/** table for this model */
public static final Table TABLE = new Table("task_list_metadata_outstanding", TaskListMetadataOutstanding.class);
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
public static final LongProperty TASK_LIST_METADATA_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_LIST_METADATA_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(TaskListMetadataOutstanding.class);
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
public static final Creator<TaskListMetadataOutstanding> CREATOR = new ModelCreator<TaskListMetadataOutstanding>(TaskListMetadataOutstanding.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}

@ -1,62 +0,0 @@
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;
public class TaskOutstanding extends OutstandingEntry<Task> {
/** 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;
}
}

@ -18,9 +18,6 @@ public class UserActivity extends RemoteModel {
/** table for this model */
public static final Table TABLE = new Table("userActivity", UserActivity.class);
/** model class for entries in the outstanding table */
public static final Class<? extends OutstandingEntry<UserActivity>> OUTSTANDING_MODEL = UserActivityOutstanding.class;
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
TABLE.name);

@ -1,62 +0,0 @@
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;
public class UserActivityOutstanding extends OutstandingEntry<UserActivity> {
/** table for this model */
public static final Table TABLE = new Table("user_activity_outstanding", UserActivityOutstanding.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(UserActivityOutstanding.class);
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
public static final Creator<UserActivityOutstanding> CREATOR = new ModelCreator<UserActivityOutstanding>(UserActivityOutstanding.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}

@ -1,17 +1,13 @@
package com.todoroo.astrid.dao;
import android.content.ContentValues;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.test.DatabaseTestCase;
public class DatabaseDaoTests extends DatabaseTestCase {
private TaskDao dao;
private TaskOutstandingDao outstandingDao;
@Override
protected void setUp() throws Exception {
@ -20,18 +16,9 @@ public class DatabaseDaoTests extends DatabaseTestCase {
}
public void testFailedTransactionCreatesNoRows() {
dao = new TaskDao() {
@Override
protected int createOutstandingEntries(long modelId, ContentValues modelSetValues) {
super.createOutstandingEntries(modelId, modelSetValues);
return -1;
}
};
dao = new TaskDao();
dao.setDatabase(database);
outstandingDao = new TaskOutstandingDao();
outstandingDao.setDatabase(database);
Task t = new Task();
t.setValue(Task.TITLE, "Should not appear");
dao.createNew(t);
@ -42,13 +29,6 @@ public class DatabaseDaoTests extends DatabaseTestCase {
} finally {
tasks.close();
}
TodorooCursor<TaskOutstanding> outstanding = outstandingDao.query(Query.select(TaskOutstanding.ID));
try {
assertEquals(0, outstanding.getCount());
} finally {
outstanding.close();
}
}
}

@ -125,11 +125,11 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
// --- helpers
private void whenIncreaseIndent() {
gtasksTaskListUpdater.indent(null, storeList, task.getId(), 1);
gtasksTaskListUpdater.indent(storeList, task.getId(), 1);
}
private void whenDecreaseIndent() {
gtasksTaskListUpdater.indent(null, storeList, task.getId(), -1);
gtasksTaskListUpdater.indent(storeList, task.getId(), -1);
}
@Override

@ -226,8 +226,7 @@ public class GtasksTaskMovingTest extends DatabaseTestCase {
/** moveTo = null => move to end */
private void whenTriggerMove(Task target, Task moveTo) {
gtasksTaskListUpdater.moveTo(null, list, target.getId(), moveTo == null ? -1 : moveTo.getId());
gtasksTaskListUpdater.debugPrint(null, list);
gtasksTaskListUpdater.moveTo(list, target.getId(), moveTo == null ? -1 : moveTo.getId());
}
private void thenExpectMetadataOrderAndIndent(Task task, long order, int indent) {

@ -4,7 +4,6 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskOutstandingDao;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
@ -16,9 +15,6 @@ public class NewSyncTestCase extends DatabaseTestCase {
@Autowired
protected TagDataDao tagDataDao;
@Autowired
protected TaskOutstandingDao taskOutstandingDao;
@Override
protected void setUp() throws Exception {
super.setUp();

@ -1,12 +1,8 @@
package com.todoroo.astrid.sync;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding;
public class SyncModelTest extends NewSyncTestCase {
@ -19,46 +15,5 @@ public class SyncModelTest extends NewSyncTestCase {
TagData tag = createTagData();
assertFalse(RemoteModel.NO_UUID.equals(tag.getValue(TagData.UUID)));
}
public void testChangeTaskMakesOutstandingEntries() {
Task task = createTask();
String newTitle = "changing task title";
task.setValue(Task.TITLE, newTitle);
taskDao.save(task);
TodorooCursor<TaskOutstanding> cursor = taskOutstandingDao.query(Query.select(TaskOutstanding.PROPERTIES)
.where(Criterion.and(TaskOutstanding.TASK_ID.eq(task.getId()),
TaskOutstanding.COLUMN_STRING.eq(Task.TITLE.name),
TaskOutstanding.VALUE_STRING.eq(newTitle))));
try {
assertTrue(cursor.getCount() > 0);
} finally {
cursor.close();
}
}
public void testUpdateMakesAllOutstandingEntries() {
String title = "Task Important";
createTask(title, true);
createTask("Task Not Important", true);
createTask(title, true);
Task template = new Task();
template.setValue(Task.IMPORTANCE, Task.IMPORTANCE_DO_OR_DIE);
taskDao.update(Task.TITLE.eq(title), template);
TodorooCursor<TaskOutstanding> cursor = taskOutstandingDao.query(Query.select(TaskOutstanding.PROPERTIES));
try {
assertEquals(2, cursor.getCount());
TaskOutstanding to = new TaskOutstanding();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
to.readPropertiesFromCursor(cursor);
assertEquals(Task.IMPORTANCE.name, to.getValue(TaskOutstanding.COLUMN_STRING));
assertEquals(Task.IMPORTANCE_DO_OR_DIE, Integer.parseInt(to.getValue(TaskOutstanding.VALUE_STRING)));
}
} finally {
cursor.close();
}
}
}

@ -19,11 +19,7 @@ public class NameMaps {
// --------------------------------
// Universal table identifiers
public static final String TABLE_ID_TASKS = "tasks";
public static final String TABLE_ID_TAGS = "tags";
public static final String TABLE_ID_USER_ACTIVITY = "user_activities";
public static final String TABLE_ID_ATTACHMENTS = "task_attachments";
public static final String TABLE_ID_TASK_LIST_METADATA = "task_list_metadata";
// --------------------------------
// ---- Column name mappings -------
@ -79,10 +75,6 @@ public class NameMaps {
putTaskPropertyToServerName(Task.CLASSIFICATION, "classification", false);
}
public static final String TAG_ADDED_COLUMN = "tag_added";
public static final String TAG_REMOVED_COLUMN = "tag_removed";
// ----------
// TagData
// ----------
@ -114,9 +106,6 @@ public class NameMaps {
putTagPropertyToServerName(TagData.IS_FOLDER, "is_folder", false);
}
public static final String MEMBER_ADDED_COLUMN = "member_added";
public static final String MEMBER_REMOVED_COLUMN = "member_removed";
// ----------
// User Activity
// ----------
@ -155,8 +144,6 @@ public class NameMaps {
private static final Map<String, String> TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER;
private static final Set<String> TASK_ATTACHMENT_PROPERTIES_EXCLUDED;
public static final String ATTACHMENT_ADDED_COLUMN = "file";
private static void putTaskAttachmentPropertyToServerName(Property<?> property, String serverName, boolean writeable) {
putPropertyToServerName(property, serverName, TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER, TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES,
TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER, TASK_ATTACHMENT_PROPERTIES_EXCLUDED, writeable);
@ -207,33 +194,4 @@ public class NameMaps {
putTaskListMetadataPropertyToServerName(TaskListMetadata.CHILD_TAG_IDS, "child_tag_ids", false);
putTaskListMetadataPropertyToServerName(TaskListMetadata.IS_COLLAPSED, "is_collapsed", false);
}
// ----------
// Mapping helpers
// ----------
public static boolean shouldRecordOutstandingColumnForTable(String table, String column) {
if (TABLE_ID_TASKS.equals(table)) {
if (TASK_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) {
return !TASK_PROPERTIES_EXCLUDED.contains(column);
}
} else if (TABLE_ID_TAGS.equals(table)) {
if (TAG_DATA_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) {
return !TAG_PROPERTIES_EXCLUDED.contains(column);
}
} else if (TABLE_ID_USER_ACTIVITY.equals(table)) {
if (USER_ACTIVITY_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) {
return !USER_ACTIVITY_PROPERTIES_EXCLUDED.contains(column);
}
} else if (TABLE_ID_ATTACHMENTS.equals(table)) {
if (TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES.containsKey(column)) {
return !TASK_ATTACHMENT_PROPERTIES_EXCLUDED.contains(column);
}
} 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);
}
}
return false;
}
}

@ -45,7 +45,6 @@ import com.actionbarsherlock.view.MenuItem;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
@ -55,11 +54,9 @@ import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback;
import com.todoroo.astrid.actfm.CommentsActivity;
import com.todoroo.astrid.actfm.TaskCommentsFragment;
import com.todoroo.astrid.dao.TaskAttachmentDao;
import com.todoroo.astrid.dao.TaskOutstandingDao;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskAttachment;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.files.AACRecordingActivity;
import com.todoroo.astrid.files.FileExplore;
import com.todoroo.astrid.files.FileUtilities;
@ -177,9 +174,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
@Autowired
private TaskService taskService;
@Autowired
private TaskOutstandingDao taskOutstandingDao;
@Autowired
private TaskAttachmentDao taskAttachmentDao;
@ -708,12 +702,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
return;
}
if (isNewTask) {
taskOutstandingDao.deleteWhere(Criterion.and(TaskOutstanding.TASK_ID.eq(model.getId()),
TaskOutstanding.COLUMN_STRING.eq(Task.TITLE.name),
Criterion.or(TaskOutstanding.VALUE_STRING.isNull(), TaskOutstanding.VALUE_STRING.eq("")))); //$NON-NLS-1$
}
StringBuilder toast = new StringBuilder();
synchronized (controls) {
for (TaskEditControlSet controlSet : controls) {

@ -18,16 +18,11 @@ import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TagMetadata;
import com.todoroo.astrid.data.TagOutstanding;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskAttachment;
import com.todoroo.astrid.data.TaskAttachmentOutstanding;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.data.TaskListMetadataOutstanding;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.data.UserActivityOutstanding;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.provider.Astrid3ContentProvider;
import com.todoroo.astrid.widget.TasksWidget;
@ -67,11 +62,6 @@ public class Database extends AbstractDatabase {
TagMetadata.TABLE,
TaskAttachment.TABLE,
TaskListMetadata.TABLE,
TaskOutstanding.TABLE,
TagOutstanding.TABLE,
UserActivityOutstanding.TABLE,
TaskAttachmentOutstanding.TABLE,
TaskListMetadataOutstanding.TABLE
};
// --- listeners
@ -317,15 +307,10 @@ public class Database extends AbstractDatabase {
}
case 28:
case 29:
tryExecSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES));
tryExecSQL(createTableSql(visitor, TagOutstanding.TABLE.name, TagOutstanding.PROPERTIES));
tryExecSQL(createTableSql(visitor, TaskAttachmentOutstanding.TABLE.name, TagOutstanding.PROPERTIES));
tryExecSQL(createTableSql(visitor, TagMetadata.TABLE.name, TagMetadata.PROPERTIES));
tryExecSQL(createTableSql(visitor, UserActivity.TABLE.name, UserActivity.PROPERTIES));
tryExecSQL(createTableSql(visitor, UserActivityOutstanding.TABLE.name, UserActivityOutstanding.PROPERTIES));
tryExecSQL(createTableSql(visitor, TaskAttachment.TABLE.name, TaskAttachment.PROPERTIES));
tryExecSQL(createTableSql(visitor, TaskListMetadata.TABLE.name, TaskListMetadata.PROPERTIES));
tryExecSQL(createTableSql(visitor, TaskListMetadataOutstanding.TABLE.name, TaskListMetadataOutstanding.PROPERTIES));
tryExecSQL(addColumnSql(Task.TABLE, Task.PUSHED_AT, visitor, null));
tryExecSQL(addColumnSql(Task.TABLE, Task.IS_PUBLIC, visitor, "0"));

@ -8,7 +8,6 @@ package com.todoroo.astrid.dao;
import android.content.ContentValues;
import android.database.Cursor;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor;
@ -19,12 +18,8 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.OutstandingEntry;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.utility.AstridPreferences;
@ -73,41 +68,6 @@ public class MetadataDao extends DatabaseDao<Metadata> {
}
@Override
protected boolean shouldRecordOutstanding(Metadata item) {
ContentValues cv = item.getSetValues();
return super.shouldRecordOutstanding(item) && cv != null &&
((cv.containsKey(Metadata.KEY.name) &&
TaskToTagMetadata.KEY.equals(item.getValue(Metadata.KEY))) ||
(cv.containsKey(Metadata.DELETION_DATE.name) &&
item.getValue(Metadata.DELETION_DATE) > 0)) &&
RemoteModelDao.getOutstandingEntryFlag(RemoteModelDao.OUTSTANDING_ENTRY_FLAG_RECORD_OUTSTANDING);
}
@Override
protected int createOutstandingEntries(long modelId, ContentValues modelSetValues) {
Long taskId = modelSetValues.getAsLong(Metadata.TASK.name);
String tagUuid = modelSetValues.getAsString(TaskToTagMetadata.TAG_UUID.name);
Long deletionDate = modelSetValues.getAsLong(Metadata.DELETION_DATE.name);
if (taskId == null || taskId == AbstractModel.NO_ID || RemoteModel.isUuidEmpty(tagUuid)) {
return -1;
}
TaskOutstanding to = new TaskOutstanding();
to.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, taskId);
to.setValue(OutstandingEntry.CREATED_AT_PROPERTY, DateUtilities.now());
String addedOrRemoved = NameMaps.TAG_ADDED_COLUMN;
if (deletionDate != null && deletionDate > 0) {
addedOrRemoved = NameMaps.TAG_REMOVED_COLUMN;
}
to.setValue(OutstandingEntry.COLUMN_STRING_PROPERTY, addedOrRemoved);
to.setValue(OutstandingEntry.VALUE_STRING_PROPERTY, tagUuid);
database.insert(outstandingTable.name, null, to.getSetValues());
return 1;
}
/**
* Synchronize metadata for given task id. Deletes rows in database that
* are not identical to those in the metadata list, creates rows that

@ -1,19 +0,0 @@
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.data.OutstandingEntry;
public class OutstandingEntryDao<TYPE extends OutstandingEntry<?>> extends DatabaseDao<TYPE> {
@Autowired
private Database database;
public OutstandingEntryDao(Class<TYPE> modelClass) {
super(modelClass);
DependencyInjectionService.getInstance().inject(this);
setDatabase(database);
}
}

@ -54,11 +54,6 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
return (outstandingEntryFlag & flag) > 0;
}
@Override
protected boolean shouldRecordOutstanding(RTYPE item) {
return super.shouldRecordOutstanding(item) && getOutstandingEntryFlag(OUTSTANDING_ENTRY_FLAG_RECORD_OUTSTANDING);
}
/**
* Fetch a model object by UUID
*/

@ -27,11 +27,6 @@ public class TagDataDao extends RemoteModelDao<TagData> {
setDatabase(database);
}
@Override
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TAGS, columnName);
}
// --- SQL clause generators
/**

@ -5,10 +5,8 @@
*/
package com.todoroo.astrid.dao;
import android.content.ContentValues;
import android.text.TextUtils;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
@ -16,15 +14,12 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.OutstandingEntry;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TagMetadata;
import com.todoroo.astrid.data.TagOutstanding;
import com.todoroo.astrid.tags.TagMemberMetadata;
import org.json.JSONArray;
@ -69,41 +64,6 @@ public class TagMetadataDao extends DatabaseDao<TagMetadata> {
}
}
@Override
protected boolean shouldRecordOutstanding(TagMetadata item) {
ContentValues cv = item.getSetValues();
return super.shouldRecordOutstanding(item) && cv != null &&
((cv.containsKey(TagMetadata.KEY.name) &&
TagMemberMetadata.KEY.equals(item.getValue(TagMetadata.KEY))) ||
(cv.containsKey(TagMetadata.DELETION_DATE.name) &&
item.getValue(TagMetadata.DELETION_DATE) > 0)) &&
RemoteModelDao.getOutstandingEntryFlag(RemoteModelDao.OUTSTANDING_ENTRY_FLAG_RECORD_OUTSTANDING);
}
@Override
protected int createOutstandingEntries(long modelId, ContentValues modelSetValues) {
Long tagDataId = modelSetValues.getAsLong(TagMetadata.TAG_ID.name);
String memberId = modelSetValues.getAsString(TagMemberMetadata.USER_UUID.name);
Long deletionDate = modelSetValues.getAsLong(TagMetadata.DELETION_DATE.name);
if (tagDataId == null || tagDataId == AbstractModel.NO_ID || RemoteModel.isUuidEmpty(memberId)) {
return -1;
}
TagOutstanding to = new TagOutstanding();
to.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, tagDataId);
to.setValue(OutstandingEntry.CREATED_AT_PROPERTY, DateUtilities.now());
String addedOrRemoved = NameMaps.MEMBER_ADDED_COLUMN;
if (deletionDate != null && deletionDate > 0) {
addedOrRemoved = NameMaps.MEMBER_REMOVED_COLUMN;
}
to.setValue(OutstandingEntry.COLUMN_STRING_PROPERTY, addedOrRemoved);
to.setValue(OutstandingEntry.VALUE_STRING_PROPERTY, memberId);
database.insert(outstandingTable.name, null, to.getSetValues());
return 1;
}
public void createMemberLink(long tagId, String tagUuid, String memberId, boolean suppressOutstanding) {
createMemberLink(tagId, tagUuid, memberId, false, suppressOutstanding);
}

@ -5,23 +5,13 @@
*/
package com.todoroo.astrid.dao;
import android.content.ContentValues;
import android.text.TextUtils;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
import com.todoroo.astrid.data.OutstandingEntry;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TaskAttachment;
import com.todoroo.astrid.data.TaskAttachmentOutstanding;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Data Access layer for {@link TagData}-related operations.
@ -39,43 +29,6 @@ public class TaskAttachmentDao extends RemoteModelDao<TaskAttachment> {
setDatabase(database);
}
@Override
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_ATTACHMENTS, columnName);
}
@Override
protected int createOutstandingEntries(long modelId, ContentValues modelSetValues) {
// new attachment case -- only set by us when creating new attachments; when setting during sync outstanding entries suppressed
if (modelSetValues.containsKey(TaskAttachment.CONTENT_TYPE.name)) {
TaskAttachmentOutstanding m = new TaskAttachmentOutstanding();
String path = modelSetValues.getAsString(TaskAttachment.FILE_PATH.name);
if (TextUtils.isEmpty(path)) {
return -1;
}
try {
JSONObject newFileHash = new JSONObject();
newFileHash.put("name", modelSetValues.getAsString(TaskAttachment.NAME.name)); //$NON-NLS-1$
newFileHash.put("type", modelSetValues.getAsString(TaskAttachment.CONTENT_TYPE.name)); //$NON-NLS-1$
newFileHash.put("path", path); //$NON-NLS-1$
m.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, modelId);
m.setValue(OutstandingEntry.COLUMN_STRING_PROPERTY, NameMaps.ATTACHMENT_ADDED_COLUMN);
m.setValue(OutstandingEntry.VALUE_STRING_PROPERTY, newFileHash.toString());
m.setValue(OutstandingEntry.CREATED_AT_PROPERTY, DateUtilities.now());
database.insert(outstandingTable.name, null, m.getSetValues());
} catch (JSONException e) {
return -1;
}
}
int result = super.createOutstandingEntries(modelId, modelSetValues);
if (result < 0) // Error
{
return result;
}
return 1 + result;
}
public boolean taskHasAttachments(String taskUuid) {
TodorooCursor<TaskAttachment> files = query(Query.select(TaskAttachment.TASK_UUID).where(
Criterion.and(TaskAttachment.TASK_UUID.eq(taskUuid),

@ -293,11 +293,6 @@ public class TaskDao extends RemoteModelDao<Task> {
Task.RECURRENCE
};
@Override
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TASKS, columnName);
}
public void saveExistingWithSqlConstraintCheck(Task item) {
try {
saveExisting(item);

@ -32,19 +32,6 @@ public class TaskListMetadataDao extends RemoteModelDao<TaskListMetadata> {
setDatabase(database);
}
@Override
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
if (TaskListMetadata.FILTER.name.equals(columnName) || TaskListMetadata.TAG_UUID.name.equals(columnName)) {
return !RemoteModel.isUuidEmpty(value.toString());
}
if (TaskListMetadata.TASK_IDS.name.equals(columnName)) {
return !TaskListMetadata.taskIdsIsEmpty(value.toString());
}
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TASK_LIST_METADATA, columnName);
}
public TaskListMetadata fetchByTagId(String tagUuid, Property<?>...properties) {
TodorooCursor<TaskListMetadata> taskListMetadata = query(Query.select(properties).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
TaskListMetadata.FILTER.eq(tagUuid))));

@ -1,11 +0,0 @@
package com.todoroo.astrid.dao;
import com.todoroo.astrid.data.TaskOutstanding;
public class TaskOutstandingDao extends OutstandingEntryDao<TaskOutstanding> {
public TaskOutstandingDao() {
super(TaskOutstanding.class);
}
}

@ -35,9 +35,4 @@ public class UserActivityDao extends RemoteModelDao<UserActivity> {
}
return super.saveExisting(item);
}
@Override
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_USER_ACTIVITY, columnName);
}
}

@ -17,7 +17,6 @@ import com.todoroo.astrid.dao.TagMetadataDao;
import com.todoroo.astrid.dao.TaskAttachmentDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskListMetadataDao;
import com.todoroo.astrid.dao.TaskOutstandingDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.gtasks.GtasksMetadataService;
@ -63,7 +62,6 @@ public class AstridDependencyInjector extends AbstractDependencyInjector {
injectables.put("tagDataDao", TagDataDao.class);
injectables.put("storeObjectDao", StoreObjectDao.class);
injectables.put("userActivityDao", UserActivityDao.class);
injectables.put("taskOutstandingDao", TaskOutstandingDao.class);
injectables.put("taskAttachmentDao", TaskAttachmentDao.class);
injectables.put("taskListMetadataDao", TaskListMetadataDao.class);

@ -27,13 +27,11 @@ import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.dao.TaskOutstandingDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.gtasks.GtasksMetadata;
@ -74,9 +72,6 @@ public class TaskService {
@Autowired
private TaskDao taskDao;
@Autowired
private TaskOutstandingDao taskOutstandingDao;
@Autowired
private MetadataDao metadataDao;
@ -206,7 +201,6 @@ public class TaskService {
return;
} else if(item.containsValue(Task.TITLE) && item.getValue(Task.TITLE).length() == 0) {
taskDao.delete(item.getId());
taskOutstandingDao.deleteWhere(TaskOutstanding.ENTITY_ID_PROPERTY.eq(item.getId()));
item.setId(Task.NO_ID);
} else {
long id = item.getId();

@ -33,7 +33,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
if(field.getName().equals("foo"))
return "bar";
return null;
@ -110,7 +110,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
return "malarkey";
}
}
@ -119,7 +119,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
if(field.getName().equals("foo"))
return "bar";
return null;
@ -158,7 +158,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
if(field.getName().equals("wozzle"))
return "bar";
return null;
@ -193,7 +193,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
if(field.getName().equals("foo"))
return "bar";
return null;
@ -242,7 +242,7 @@ public class DependencyInjectionTest {
new AbstractDependencyInjector() {
@Override
public Object getInjection(Object object, Field field) {
public Object getInjection(Field field) {
if(field.getName().equals("foo"))
return "gotfoo";
else if(field.getName().equals("bar"))

@ -55,7 +55,7 @@ public class DateUtilitiesTest extends TodorooRobolectricTestCase {
for(int i = 0; i < 12; i++) {
d.setMonth(i);
DateUtilities.getDateString(getContext(), d);
DateUtilities.getDateString(d);
}
}
});
@ -69,7 +69,7 @@ public class DateUtilitiesTest extends TodorooRobolectricTestCase {
for(int i = 0; i < 7; i++) {
d.setDate(i);
DateUtilities.getDateStringWithWeekday(getContext(), d);
DateUtilities.getDateStringWithWeekday(d);
}
}
});

@ -245,8 +245,8 @@ public class AdvancedRepeatTest extends TodorooRobolectricTestCase {
}
private void assertDateEquals(long actual, long expected) {
assertEquals("Due Date is '" + DateUtilities.getDateStringWithWeekday(getContext(), new Date(actual))
+ "', expected '" + DateUtilities.getDateStringWithWeekday(getContext(), new Date(expected)) + "'",
assertEquals("Due Date is '" + DateUtilities.getDateStringWithWeekday(new Date(actual))
+ "', expected '" + DateUtilities.getDateStringWithWeekday(new Date(expected)) + "'",
expected, actual);
}

@ -129,8 +129,8 @@ public class RepeatAfterCompleteTest extends TodorooRobolectricTestCase {
private void assertDateEquals(String message, long expected, long actual) {
expected = Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, expected);
actual = Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, actual);
assertEquals(message + ": Due Date is '" + DateUtilities.getDateStringWithWeekday(getContext(), new Date(actual))
+ "', expected '" + DateUtilities.getDateStringWithWeekday(getContext(), new Date(expected)) + "'",
assertEquals(message + ": Due Date is '" + DateUtilities.getDateStringWithWeekday(new Date(actual))
+ "', expected '" + DateUtilities.getDateStringWithWeekday(new Date(expected)) + "'",
expected, actual);
}

Loading…
Cancel
Save