MetadataDao should fail transaction if information for the outstanding tables is missing and log the error

pull/14/head
Sam Bosley 12 years ago
parent b9e54bdb23
commit 16a9f53311

@ -38,6 +38,8 @@ import com.todoroo.astrid.data.SyncFlags;
*/
public class DatabaseDao<TYPE extends AbstractModel> {
private static final String ERROR_TAG = "database-dao"; //$NON-NLS-1$
private final Class<TYPE> modelClass;
private Table table;
@ -235,6 +237,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
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
@ -298,6 +301,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
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

@ -92,7 +92,7 @@ public class MetadataDao extends DatabaseDao<Metadata> {
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 true;
return false;
TaskOutstanding to = new TaskOutstanding();
to.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, taskId);

@ -17,6 +17,7 @@ import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.tags.TaskToTagMetadata;
@ -54,41 +55,48 @@ public class AstridNewSyncMigrationTest extends NewSyncTestCase {
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 1L);
m.setValue(TaskToTagMetadata.TAG_NAME, "Tag 1");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.clear();
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 2L);
m.setValue(TaskToTagMetadata.TAG_NAME, "New tag");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.clear();
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 3L);
m.setValue(TaskToTagMetadata.TAG_NAME, "Tag 3");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.clear();
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 3L);
m.setValue(TaskToTagMetadata.TAG_NAME, "Tag 4");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.clear();
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 5L);
m.setValue(TaskToTagMetadata.TAG_NAME, "Tag 1");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.clear();
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 5L);
m.setValue(TaskToTagMetadata.TAG_NAME, "Tag 5");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
m.setValue(Metadata.KEY, TaskToTagMetadata.KEY);
m.setValue(Metadata.TASK, 5L);
m.setValue(TaskToTagMetadata.TAG_NAME, "New tag 2");
m.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataDao.createNew(m);
// State (task: tags)

Loading…
Cancel
Save