Updated a ton of references to REMOTE_ID to use UUID instead

pull/14/head
Sam Bosley 12 years ago
parent 17e126f487
commit 5886bbd25b

@ -6,6 +6,7 @@
package com.timsu.astrid;
import java.io.IOException;
import java.math.BigInteger;
import org.json.JSONException;
import org.json.JSONObject;
@ -132,12 +133,12 @@ public class C2DMReceiver extends BroadcastReceiver {
try {
if(intent.hasExtra("tag_id")) {
TodorooCursor<TagData> cursor = tagDataService.query(
Query.select(TagData.PROPERTIES).where(TagData.REMOTE_ID.eq(
Query.select(TagData.PROPERTIES).where(TagData.UUID.eq(
intent.getStringExtra("tag_id"))));
try {
TagData tagData = new TagData();
if(cursor.getCount() == 0) {
tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id")));
tagData.setValue(TagData.UUID, new BigInteger(intent.getStringExtra("tag_id")));
tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData);
} else {
@ -151,12 +152,12 @@ public class C2DMReceiver extends BroadcastReceiver {
}
} else if(intent.hasExtra("task_id")) {
TodorooCursor<Task> cursor = taskService.query(
Query.select(Task.PROPERTIES).where(Task.REMOTE_ID.eq(
Query.select(Task.PROPERTIES).where(Task.UUID.eq(
intent.getStringExtra("task_id"))));
try {
final Task task = new Task();
if(cursor.getCount() == 0) {
task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id")));
task.setValue(Task.UUID, new BigInteger(intent.getStringExtra("task_id")));
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(task);
} else {
@ -297,13 +298,13 @@ public class C2DMReceiver extends BroadcastReceiver {
private Intent createTaskIntent(Intent intent) {
TodorooCursor<Task> cursor = taskService.query(
Query.select(Task.PROPERTIES).where(Task.REMOTE_ID.eq(
Query.select(Task.PROPERTIES).where(Task.UUID.eq(
intent.getStringExtra("task_id"))));
try {
final Task task = new Task();
if(cursor.getCount() == 0) {
task.setValue(Task.TITLE, intent.getStringExtra("title"));
task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id")));
task.setValue(Task.UUID, new BigInteger(intent.getStringExtra("task_id")));
task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED);
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(task);
@ -338,13 +339,13 @@ public class C2DMReceiver extends BroadcastReceiver {
private Intent createTagIntent(final Context context, final Intent intent) {
TodorooCursor<TagData> cursor = tagDataService.query(
Query.select(TagData.PROPERTIES).where(TagData.REMOTE_ID.eq(
Query.select(TagData.PROPERTIES).where(TagData.UUID.eq(
intent.getStringExtra("tag_id"))));
try {
final TagData tagData = new TagData();
if(cursor.getCount() == 0) {
tagData.setValue(TagData.NAME, intent.getStringExtra("title"));
tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id")));
tagData.setValue(TagData.UUID, new BigInteger(intent.getStringExtra("tag_id")));
tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData);
@ -370,7 +371,7 @@ public class C2DMReceiver extends BroadcastReceiver {
if(intent.hasExtra("activity_id")) {
try {
Update update = new Update();
update.setValue(Update.REMOTE_ID, Long.parseLong(intent.getStringExtra("activity_id")));
update.setValue(Update.UUID, new BigInteger(intent.getStringExtra("activity_id")));
update.setValue(Update.USER_ID, Long.parseLong(intent.getStringExtra("user_id")));
JSONObject user = new JSONObject();
user.put("id", update.getValue(Update.USER_ID));

@ -5,6 +5,7 @@
*/
package com.todoroo.astrid.actfm;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -826,8 +827,8 @@ public class EditPeopleControlSet extends PopupControlSet {
protected Object[] buildSharingArgs(JSONArray emails) throws JSONException {
ArrayList<Object> values = new ArrayList<Object>();
if(task.containsNonNullValue(Task.REMOTE_ID)) {
long currentTaskID = task.getValue(Task.REMOTE_ID);
if(task.containsNonNullValue(Task.UUID)) {
BigInteger currentTaskID = task.getValue(Task.UUID);
values.add("id");
values.add(currentTaskID);
}

@ -6,6 +6,7 @@
package com.todoroo.astrid.actfm;
import java.io.IOException;
import java.math.BigInteger;
import org.json.JSONArray;
import org.json.JSONException;
@ -333,7 +334,7 @@ public class TagSettingsActivity extends FragmentActivity {
@Override
public void run() {
actFmSyncService.pushTagDataOnSave(tagData, tagData.getMergedValues());
if(setBitmap != null && tagData.getValue(TagData.REMOTE_ID) > 0)
if(setBitmap != null && BigInteger.ZERO.compareTo(tagData.getValue(TagData.UUID)) != 0)
uploadTagPicture(setBitmap);
runOnUiThread(loadTag);
@ -428,7 +429,7 @@ public class TagSettingsActivity extends FragmentActivity {
@Override
public void run() {
try {
String url = actFmSyncService.setTagPicture(tagData.getValue(TagData.REMOTE_ID), bitmap);
String url = actFmSyncService.setTagPicture(tagData.getValue(TagData.UUID), bitmap);
if (TextUtils.isEmpty(url)) return;
if (imageCache.contains(tagData.getValue(TagData.PICTURE))) {
imageCache.move(tagData.getValue(TagData.PICTURE), url);
@ -459,7 +460,7 @@ public class TagSettingsActivity extends FragmentActivity {
public void handleCameraResult(Bitmap bitmap) {
picture.setImageBitmap(bitmap);
setBitmap = bitmap;
if(tagData.getValue(TagData.REMOTE_ID) > 0)
if(BigInteger.ZERO.compareTo(tagData.getValue(TagData.UUID)) != 0)
uploadTagPicture(bitmap);
saveTagPictureLocally(bitmap);
}

@ -5,6 +5,8 @@
*/
package com.todoroo.astrid.actfm;
import java.math.BigInteger;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
@ -275,8 +277,8 @@ public class TagUpdatesFragment extends ListFragment {
}
public void setLastViewed() {
if(tagData != null && tagData.getValue(TagData.REMOTE_ID) > 0) {
Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), DateUtilities.now());
if(tagData != null && BigInteger.ZERO.compareTo(tagData.getValue(TagData.UUID)) != 0) {
Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.UUID), DateUtilities.now());
Activity activity = getActivity();
if (activity instanceof TaskListActivity)
((TaskListActivity) activity).setCommentsCount(0);
@ -359,7 +361,7 @@ public class TagUpdatesFragment extends ListFragment {
update.setValue(Update.MESSAGE, addCommentField.getText().toString());
update.setValue(Update.ACTION_CODE, "tag_comment");
update.setValue(Update.USER_ID, 0L);
update.setValue(Update.TAGS, "," + tagData.getValue(TagData.REMOTE_ID) + ",");
update.setValue(Update.TAGS, "," + tagData.getValue(TagData.UUID) + ",");
update.setValue(Update.TAGS_LOCAL, "," + tagData.getId() + ",");
update.setValue(Update.CREATION_DATE, DateUtilities.now());
update.setValue(Update.TARGET_NAME, tagData.getValue(TagData.NAME));

@ -5,6 +5,8 @@
*/
package com.todoroo.astrid.actfm;
import java.math.BigInteger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -73,7 +75,11 @@ public class TagViewFragment extends TaskListFragment {
public static final String BROADCAST_TAG_ACTIVITY = AstridApiConstants.PACKAGE + ".TAG_ACTIVITY"; //$NON-NLS-1$
public static final String EXTRA_TAG_NAME = "tag"; //$NON-NLS-1$
public static final String EXTRA_TAG_REMOTE_ID = "remoteId"; //$NON-NLS-1$
@Deprecated
private static final String EXTRA_TAG_REMOTE_ID = "remoteId"; //$NON-NLS-1$
public static final String EXTRA_TAG_UUID = "uuid"; //$NON-NLS-1$
public static final String EXTRA_TAG_DATA = "tagData"; //$NON-NLS-1$
@ -194,18 +200,24 @@ public class TagViewFragment extends TaskListFragment {
TaskListActivity activity = (TaskListActivity) getActivity();
String tag = extras.getString(EXTRA_TAG_NAME);
long remoteId = extras.getLong(EXTRA_TAG_REMOTE_ID, 0);
BigInteger uuid = BigInteger.ZERO;
if (extras.containsKey(EXTRA_TAG_UUID))
uuid = new BigInteger(extras.getString(EXTRA_TAG_UUID));
else if (extras.containsKey(EXTRA_TAG_REMOTE_ID)) // For legacy support with shortcuts, widgets, etc.
uuid = BigInteger.valueOf(extras.getLong(EXTRA_TAG_REMOTE_ID));
if(tag == null && remoteId == 0)
if(tag == null && BigInteger.ZERO.compareTo(uuid) == 0)
return;
TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(Criterion.or(TagData.NAME.eqCaseInsensitive(tag),
Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId)))));
TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(
Criterion.or(TagData.NAME.eqCaseInsensitive(tag),
TagData.UUID.eq(uuid))));
try {
tagData = new TagData();
if(cursor.getCount() == 0) {
tagData.setValue(TagData.NAME, tag);
tagData.setValue(TagData.REMOTE_ID, remoteId);
tagData.setValue(TagData.UUID, uuid);
tagDataService.save(tagData);
} else {
cursor.moveToFirst();

@ -8,6 +8,7 @@ package com.todoroo.astrid.actfm.sync;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -450,7 +451,7 @@ public final class ActFmSyncService {
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
metadata.readFromCursor(cursor);
if(metadata.containsNonNullValue(TagMetadata.TAG_UUID) &&
metadata.getValue(TagMetadata.TAG_UUID) != 0) {
metadata.getValue(TagMetadata.TAG_UUID).compareTo(BigInteger.ZERO) != 0) {
params.add("tag_ids[]");
params.add(metadata.getValue(TagMetadata.TAG_UUID));
} else {
@ -1098,7 +1099,7 @@ public final class ActFmSyncService {
* @throws IOException
* @throws ActFmServiceException
*/
public String setTagPicture(long tagId, Bitmap bitmap) throws ActFmServiceException, IOException {
public String setTagPicture(BigInteger tagId, Bitmap bitmap) throws ActFmServiceException, IOException {
if(!checkForToken())
return null;
@ -1538,12 +1539,12 @@ public final class ActFmSyncService {
*/
public static void taskFromJson(JSONObject json, Task model, ArrayList<Metadata> metadata) throws JSONException {
metadata.clear();
model.clearValue(Task.REMOTE_ID);
long remoteId = json.getLong("id");
if (remoteId == 0)
model.setValue(Task.REMOTE_ID, null);
model.clearValue(Task.UUID);
BigInteger remoteId = new BigInteger(json.getString("id"));
if (remoteId.compareTo(BigInteger.ZERO) == 0)
model.setValue(Task.UUID, null);
else
model.setValue(Task.REMOTE_ID, remoteId);
model.setValue(Task.UUID, remoteId);
readUser(json.getJSONObject("user"), model, Task.USER_ID, Task.USER);
readUser(json.getJSONObject("creator"), model, Task.CREATOR_ID, null);
model.setValue(Task.TITLE, json.getString("title"));
@ -1574,7 +1575,7 @@ public final class ActFmSyncService {
String name = tag.getString("name");
if(TextUtils.isEmpty(name))
continue;
Metadata tagMetadata = TagMetadata.newTagMetadata(model.getId(), remoteId, name, tag.getLong("id"));
Metadata tagMetadata = TagMetadata.newTagMetadata(model.getId(), remoteId, name, new BigInteger(tag.getString("id")));
metadata.add(tagMetadata);
}
}

@ -1,16 +1,18 @@
package com.todoroo.astrid.actfm.sync.messages;
import java.math.BigInteger;
import com.todoroo.astrid.data.RemoteModel;
public class BriefMe<TYPE extends RemoteModel> implements ClientToServerMessage {
private final Class<? extends RemoteModel> modelClass;
private final long uuid;
private final BigInteger uuid;
private long pushedAt; // TODO: Populate and use
public BriefMe(TYPE entity) {
this.modelClass = entity.getClass();
this.uuid = entity.getValue(RemoteModel.REMOTE_ID_PROPERTY);
this.uuid = entity.getValue(RemoteModel.UUID_PROPERTY);
}
public void sendMessage() {

@ -1,6 +1,7 @@
package com.todoroo.astrid.actfm.sync.messages;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@ -22,7 +23,7 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
private final Class<? extends RemoteModel> modelClass;
private final Class<OE> outstandingClass;
private final long id;
private final long uuid;
private final BigInteger uuid;
private final List<OE> changes;
private long pushedAt;
private final OutstandingEntryDao<OE> outstandingDao;
@ -35,15 +36,15 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
this.changes = new ArrayList<OE>();
this.outstandingDao = outstandingDao;
if (!entity.containsValue(RemoteModel.REMOTE_ID_PROPERTY)
if (!entity.containsValue(RemoteModel.UUID_PROPERTY)
|| !entity.containsValue(RemoteModel.PUSHED_AT_PROPERTY)) {
entity = modelDao.fetch(entity.getId(), getModelProperties(modelClass));
}
if (entity == null) {
this.uuid = 0;
this.uuid = BigInteger.ZERO;
this.pushedAt = 0;
} else {
this.uuid = entity.getValue(RemoteModel.REMOTE_ID_PROPERTY);
this.uuid = entity.getValue(RemoteModel.UUID_PROPERTY);
this.pushedAt = entity.getValue(RemoteModel.PUSHED_AT_PROPERTY);
populateChanges();
}

@ -1,15 +1,17 @@
package com.todoroo.astrid.actfm.sync.messages;
import java.math.BigInteger;
import com.todoroo.astrid.data.RemoteModel;
public class RequestDoubleCheck<TYPE extends RemoteModel> implements ClientToServerMessage {
private final Class<? extends RemoteModel> modelClass;
private final long uuid;
private final BigInteger uuid;
public RequestDoubleCheck(TYPE entity) {
this.modelClass = entity.getClass();
this.uuid = entity.getValue(RemoteModel.REMOTE_ID_PROPERTY);
this.uuid = entity.getValue(RemoteModel.UUID_PROPERTY);
}
public void sendMessage() {

@ -481,7 +481,7 @@ public class TasksXmlImporter {
private void saveTags() {
if(currentTask != null && tags.size() > 0) {
TagService.getInstance().synchronizeTags(currentTask.getId(), currentTask.getValue(Task.REMOTE_ID), tags);
TagService.getInstance().synchronizeTags(currentTask.getId(), currentTask.getValue(Task.UUID), tags);
}
tags.clear();
}

@ -104,14 +104,14 @@ public class Astrid44SyncMigrator {
if (Constants.DEBUG)
Log.w(LOG_TAG, "Incomplete linking task " + m.getValue(Metadata.TASK) + " to " + m.getValue(TagMetadata.TAG_NAME));
if (!m.containsNonNullValue(TagMetadata.TASK_UUID) || m.getValue(TagMetadata.TASK_UUID) == 0) {
if (!m.containsNonNullValue(TagMetadata.TASK_UUID) || m.getValue(TagMetadata.TASK_UUID).compareTo(BigInteger.ZERO) == 0) {
if (Constants.DEBUG)
Log.w(LOG_TAG, "No task uuid");
updateTaskUuid(m);
changes = true;
}
if (!m.containsNonNullValue(TagMetadata.TAG_UUID) || m.getValue(TagMetadata.TAG_UUID) == 0) {
if (!m.containsNonNullValue(TagMetadata.TAG_UUID) || m.getValue(TagMetadata.TAG_UUID).compareTo(BigInteger.ZERO) == 0) {
if (Constants.DEBUG)
Log.w(LOG_TAG, "No tag uuid");
updateTagUuid(m);
@ -154,11 +154,11 @@ public class Astrid44SyncMigrator {
private void updateTaskUuid(Metadata m) {
long taskId = m.getValue(Metadata.TASK);
Task task = taskDao.fetch(taskId, Task.REMOTE_ID);
Task task = taskDao.fetch(taskId, Task.UUID);
if (task != null) {
if (Constants.DEBUG)
Log.w(LOG_TAG, "Linking with task uuid " + task.getValue(Task.REMOTE_ID));
m.setValue(TagMetadata.TASK_UUID, task.getValue(Task.REMOTE_ID));
Log.w(LOG_TAG, "Linking with task uuid " + task.getValue(Task.UUID));
m.setValue(TagMetadata.TASK_UUID, task.getValue(Task.UUID));
} else {
if (Constants.DEBUG)
Log.w(LOG_TAG, "Task not found, deleting link");
@ -168,11 +168,11 @@ public class Astrid44SyncMigrator {
private void updateTagUuid(Metadata m) {
String tag = m.getValue(TagMetadata.TAG_NAME);
TagData tagData = tagDataService.getTag(tag, TagData.REMOTE_ID);
TagData tagData = tagDataService.getTag(tag, TagData.UUID);
if (tagData != null) {
if (Constants.DEBUG)
Log.w(LOG_TAG, "Linking with tag uuid " + tagData.getValue(TagData.REMOTE_ID));
m.setValue(TagMetadata.TAG_UUID, tagData.getValue(TagData.REMOTE_ID));
Log.w(LOG_TAG, "Linking with tag uuid " + tagData.getValue(TagData.UUID));
m.setValue(TagMetadata.TAG_UUID, tagData.getValue(TagData.UUID));
} else {
if (Constants.DEBUG)
Log.w(LOG_TAG, "Tag not found, deleting link");

@ -5,6 +5,7 @@
*/
package com.todoroo.astrid.tags;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@ -73,12 +74,12 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
ContentValues contentValues = new ContentValues();
contentValues.put(Metadata.KEY.name, TagMetadata.KEY);
contentValues.put(TagMetadata.TAG_NAME.name, tag.tag);
contentValues.put(TagMetadata.TAG_UUID.name, tag.remoteId);
contentValues.put(TagMetadata.TAG_UUID.name, tag.uuid.toString());
FilterWithUpdate filter = new FilterWithUpdate(tag.tag,
title, tagTemplate,
contentValues);
if(tag.remoteId > 0) {
if(BigInteger.ZERO.compareTo(tag.uuid) != 0) {
filter.listingTitle += " (" + tag.count + ")";
if(tag.count == 0)
filter.color = Color.GRAY;
@ -109,7 +110,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
filter.imageUrl = tag.image;
Bundle extras = new Bundle();
extras.putString(TagViewFragment.EXTRA_TAG_NAME, tag.tag);
extras.putLong(TagViewFragment.EXTRA_TAG_REMOTE_ID, tag.remoteId);
extras.putString(TagViewFragment.EXTRA_TAG_UUID, tag.uuid.toString());
filter.customExtras = extras;
return filter;

@ -1,5 +1,8 @@
package com.todoroo.astrid.tags;
import java.math.BigInteger;
import com.todoroo.andlib.data.Property.BigIntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.astrid.data.Metadata;
@ -14,11 +17,11 @@ public class TagMetadata {
public static final StringProperty TAG_NAME = Metadata.VALUE1;
/** Tag uuid */
public static final LongProperty TAG_UUID = new LongProperty(
public static final BigIntegerProperty TAG_UUID = new BigIntegerProperty(
Metadata.TABLE, Metadata.VALUE2.name);
/** Task uuid */
public static final LongProperty TASK_UUID = new LongProperty(
public static final BigIntegerProperty TASK_UUID = new BigIntegerProperty(
Metadata.TABLE, Metadata.VALUE3.name);
/** Pushed at time */
@ -37,11 +40,11 @@ public class TagMetadata {
* @param tagUuid
* @return
*/
public static Metadata newTagMetadata(Task task, String tagName, long tagUuid) {
return newTagMetadata(task.getId(), task.getValue(Task.REMOTE_ID), tagName, tagUuid);
public static Metadata newTagMetadata(Task task, String tagName, BigInteger tagUuid) {
return newTagMetadata(task.getId(), task.getValue(Task.UUID), tagName, tagUuid);
}
public static Metadata newTagMetadata(long taskId, long taskUuid, String tagName, long tagUuid) {
public static Metadata newTagMetadata(long taskId, BigInteger taskUuid, String tagName, BigInteger tagUuid) {
Metadata link = new Metadata();
link.setValue(Metadata.KEY, KEY);
link.setValue(Metadata.TASK, taskId);

@ -5,6 +5,7 @@
*/
package com.todoroo.astrid.tags;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -104,13 +105,15 @@ public final class TagService {
public String tag;
public int count;
public long id;
public long remoteId;
public BigInteger uuid;
public String image;
public long userId;
public long memberCount;
public static Tag tagFromRemoteId(long remoteId) {
TodorooCursor<TagData> tagData = PluginServices.getTagDataService().query(Query.select(TagData.PROPERTIES).where(TagData.REMOTE_ID.eq(remoteId)));
@Deprecated public long remoteId;
public static Tag tagFromUUID(BigInteger uuid) {
TodorooCursor<TagData> tagData = PluginServices.getTagDataService().query(Query.select(TagData.PROPERTIES).where(TagData.UUID.eq(uuid)));
try {
if (tagData.getCount() > 0) {
tagData.moveToFirst();
@ -129,6 +132,7 @@ public final class TagService {
tag = tagData.getValue(TagData.NAME);
count = tagData.getValue(TagData.TASK_COUNT);
remoteId = tagData.getValue(TagData.REMOTE_ID);
uuid = tagData.getValue(TagData.UUID);
image = tagData.getValue(TagData.PICTURE);
userId = tagData.getValue(TagData.USER_ID);
memberCount = tagData.getValue(TagData.MEMBER_COUNT);
@ -148,10 +152,10 @@ public final class TagService {
public QueryTemplate queryTemplate(Criterion criterion) {
Criterion fullCriterion = Criterion.and(
Field.field("mtags." + Metadata.KEY.name).eq(TagMetadata.KEY),
Field.field("mtags." + TagMetadata.TAG_UUID.name).eq(remoteId),
Field.field("mtags." + TagMetadata.TAG_UUID.name).eq(uuid),
Field.field("mtags." + Metadata.DELETION_DATE.name).eq(0),
criterion);
return new QueryTemplate().join(Join.inner(Metadata.TABLE.as("mtags"), Task.REMOTE_ID.eq(Field.field("mtags." + TagMetadata.TASK_UUID.name))))
return new QueryTemplate().join(Join.inner(Metadata.TABLE.as("mtags"), Task.UUID.eq(Field.field("mtags." + TagMetadata.TASK_UUID.name))))
.where(fullCriterion);
}
@ -208,7 +212,7 @@ public final class TagService {
ArrayList<Tag> array = new ArrayList<Tag>();
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToNext();
Tag tag = Tag.tagFromRemoteId(cursor.get(TagMetadata.TAG_UUID));
Tag tag = Tag.tagFromUUID(cursor.get(TagMetadata.TAG_UUID));
if (tag != null)
array.add(tag);
}
@ -236,7 +240,7 @@ public final class TagService {
}
public void createLink(Task task, String tagName) {
TodorooCursor<TagData> existingTag = tagDataService.query(Query.select(TagData.NAME, TagData.REMOTE_ID)
TodorooCursor<TagData> existingTag = tagDataService.query(Query.select(TagData.NAME, TagData.UUID)
.where(TagData.NAME.eqCaseInsensitive(tagName)));
try {
TagData tagData;
@ -247,16 +251,16 @@ public final class TagService {
} else {
tagData = new TagData(existingTag);
}
createLink(task, tagData.getValue(TagData.NAME), tagData.getValue(TagData.REMOTE_ID));
createLink(task, tagData.getValue(TagData.NAME), tagData.getValue(TagData.UUID));
} finally {
existingTag.close();
}
}
public void createLink(Task task, String tagName, long tagUuid) {
public void createLink(Task task, String tagName, BigInteger tagUuid) {
TodorooCursor<Metadata> existing = metadataDao.query(Query.select(Metadata.PROPERTIES)
.where(Criterion.and(MetadataCriteria.withKey(TagMetadata.KEY),
TagMetadata.TASK_UUID.eq(task.getValue(Task.REMOTE_ID)),
TagMetadata.TASK_UUID.eq(task.getValue(Task.UUID)),
TagMetadata.TAG_UUID.eq(tagUuid),
Metadata.DELETION_DATE.eq(0))));
try {
@ -416,8 +420,8 @@ public final class TagService {
* @param taskId
* @param tags
*/
public boolean synchronizeTags(long taskId, long taskUuid, Set<String> tags) {
HashSet<Long> existingLinks = new HashSet<Long>();
public boolean synchronizeTags(long taskId, BigInteger taskUuid, Set<String> tags) {
HashSet<BigInteger> existingLinks = new HashSet<BigInteger>();
TodorooCursor<Metadata> links = metadataDao.query(Query.select(Metadata.PROPERTIES)
.where(Criterion.and(TagMetadata.TASK_UUID.eq(taskUuid), Metadata.DELETION_DATE.eq(0))));
try {
@ -430,16 +434,16 @@ public final class TagService {
}
for (String tag : tags) {
TagData tagData = getTagDataWithCase(tag, TagData.NAME, TagData.REMOTE_ID);
TagData tagData = getTagDataWithCase(tag, TagData.NAME, TagData.UUID);
if (tagData == null) {
tagData = new TagData();
tagData.setValue(TagData.NAME, tag);
tagDataService.save(tagData);
}
if (existingLinks.contains(tagData.getValue(TagData.REMOTE_ID))) {
existingLinks.remove(tagData.getValue(TagData.REMOTE_ID));
if (existingLinks.contains(tagData.getValue(TagData.UUID))) {
existingLinks.remove(tagData.getValue(TagData.UUID));
} else {
Metadata newLink = TagMetadata.newTagMetadata(taskId, taskUuid, tag, tagData.getValue(TagData.REMOTE_ID));
Metadata newLink = TagMetadata.newTagMetadata(taskId, taskUuid, tag, tagData.getValue(TagData.UUID));
metadataDao.createNew(newLink);
}
}

@ -289,7 +289,7 @@ public final class TagsControlSet extends PopupControlSet {
LinkedHashSet<String> tags = getTagSet();
if(TagService.getInstance().synchronizeTags(task.getId(), task.getValue(Task.REMOTE_ID), tags)) {
if(TagService.getInstance().synchronizeTags(task.getId(), task.getValue(Task.UUID), tags)) {
Flags.set(Flags.TAGS_CHANGED);
task.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
}

@ -48,7 +48,7 @@ public class FeaturedListFilterExposer extends TagFilterExposer {
ContentValues contentValues = new ContentValues();
contentValues.put(Metadata.KEY.name, TagMetadata.KEY);
contentValues.put(TagMetadata.TAG_NAME.name, tag.tag);
contentValues.put(TagMetadata.TAG_UUID.name, tag.remoteId);
contentValues.put(TagMetadata.TAG_UUID.name, tag.uuid.toString());
FilterWithUpdate filter = new FilterWithUpdate(tag.tag,
title, tagTemplate,
@ -61,7 +61,7 @@ public class FeaturedListFilterExposer extends TagFilterExposer {
Bundle extras = new Bundle();
extras.putString(TagViewFragment.EXTRA_TAG_NAME, tag.tag);
extras.putLong(TagViewFragment.EXTRA_TAG_REMOTE_ID, tag.remoteId);
extras.putString(TagViewFragment.EXTRA_TAG_UUID, tag.uuid.toString());
filter.customExtras = extras;
return filter;

@ -146,7 +146,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
Task t = new Task();
for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) {
t.readFromCursor(tasks);
taskService.cloneReusableTask(t, localName, finalTagData.getValue(TagData.REMOTE_ID));
taskService.cloneReusableTask(t, localName, finalTagData.getValue(TagData.UUID));
}
final Activity activity = getActivity();
if (activity != null) {

@ -1,5 +1,6 @@
package com.todoroo.astrid.tags.reusable;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicReference;
import android.content.Context;
@ -49,7 +50,7 @@ public class ReusableTaskAdapter extends TaskAdapter {
@Override
public void onClick(View v) {
ReusableTaskViewHolder holder = (ReusableTaskViewHolder) v.getTag();
taskService.cloneReusableTask(holder.task, null, 0L);
taskService.cloneReusableTask(holder.task, null, BigInteger.ZERO);
Toast.makeText(fragment.getActivity(), R.string.actfm_feat_list_task_clone_success, Toast.LENGTH_LONG).show();
Flags.set(Flags.REFRESH);
}

@ -1163,7 +1163,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
@Override
public void onPrepareOptionsMenu (Menu menu) {
if(actFmPreferenceService.isLoggedIn() && remoteId.compareTo(BigInteger.ZERO) != 0 && menu.findItem(MENU_COMMENTS_REFRESH_ID) == null) {
if(actFmPreferenceService.isLoggedIn() && BigInteger.ZERO.compareTo(remoteId) != 0 && menu.findItem(MENU_COMMENTS_REFRESH_ID) == null) {
MenuItem item = menu.add(Menu.NONE, MENU_COMMENTS_REFRESH_ID, Menu.NONE,
R.string.ENA_refresh_comments);
item.setIcon(R.drawable.icn_menu_refresh_dark);

@ -147,7 +147,7 @@ public class TagDataService {
return updateDao.query(Query.select(Update.PROPERTIES).where(
criterion).
orderBy(Order.desc(Update.CREATION_DATE)));
if(tagData.getValue(TagData.UUID).equals(BigInteger.ZERO))
if(BigInteger.ZERO.compareTo(tagData.getValue(TagData.UUID)) == 0)
return updateDao.query(Query.select(Update.PROPERTIES).where(Update.TAGS_LOCAL.like("%," + tagData.getId() + ",%")));
return updateDao.query(Query.select(Update.PROPERTIES).where(Criterion.and(criterion,
Criterion.or(Update.TAGS.like("%," + tagData.getValue(TagData.UUID) + ",%"),
@ -161,7 +161,7 @@ public class TagDataService {
* @return
*/
public Update getLatestUpdate(TagData tagData) {
if(tagData.getValue(TagData.UUID).equals(BigInteger.ZERO))
if(BigInteger.ZERO.compareTo(tagData.getValue(TagData.UUID)) == 0)
return null;
@SuppressWarnings("nls")

@ -193,7 +193,7 @@ public class TaskService {
return newTask;
}
public Task cloneReusableTask(Task task, String tagName, long tagUuid) {
public Task cloneReusableTask(Task task, String tagName, BigInteger tagUuid) {
Task newTask = fetchById(task.getId(), Task.PROPERTIES);
if (newTask == null)
return new Task();
@ -205,7 +205,7 @@ public class TaskService {
taskDao.save(newTask);
if (tagUuid > 0) {
if (BigInteger.ZERO.compareTo(tagUuid) != 0) {
TagService.getInstance().createLink(task, tagName, tagUuid);
}
return newTask;
@ -535,7 +535,7 @@ public class TaskService {
metadata.setValue(Metadata.TASK, task.getId());
metadata.mergeWith(forMetadata);
if (TagMetadata.KEY.equals(metadata.getValue(Metadata.KEY))) {
if (metadata.containsNonNullValue(TagMetadata.TAG_UUID) && metadata.getValue(TagMetadata.TAG_UUID) != 0) {
if (metadata.containsNonNullValue(TagMetadata.TAG_UUID) && BigInteger.ZERO.compareTo(metadata.getValue(TagMetadata.TAG_UUID)) != 0) {
// This is more efficient
TagService.getInstance().createLink(task, metadata.getValue(TagMetadata.TAG_NAME), metadata.getValue(TagMetadata.TAG_UUID));
} else {

Loading…
Cancel
Save