From 6adbd88998e9eaa8d79b772ba6dfbc9b004ac472 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 15 Mar 2013 16:37:31 -0700 Subject: [PATCH] Enhanced legacy tag members migration to create deleted member links for removed members --- .../src/com/todoroo/astrid/dao/TagMetadataDao.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/dao/TagMetadataDao.java b/astrid/src/com/todoroo/astrid/dao/TagMetadataDao.java index 0edbf1877..69779ac98 100644 --- a/astrid/src/com/todoroo/astrid/dao/TagMetadataDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TagMetadataDao.java @@ -107,7 +107,13 @@ public class TagMetadataDao extends DatabaseDao { } public void createMemberLink(long tagId, String tagUuid, String memberId, boolean suppressOutstanding) { + createMemberLink(tagId, tagUuid, memberId, false, suppressOutstanding); + } + + public void createMemberLink(long tagId, String tagUuid, String memberId, boolean removedMember, boolean suppressOutstanding) { TagMetadata newMetadata = TagMemberMetadata.newMemberMetadata(tagId, tagUuid, memberId); + if (removedMember) + newMetadata.setValue(TagMetadata.DELETION_DATE, DateUtilities.now()); if (suppressOutstanding) newMetadata.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); if (update(Criterion.and(TagMetadataCriteria.byTagAndWithKey(tagUuid, TagMemberMetadata.KEY), @@ -174,10 +180,10 @@ public class TagMetadataDao extends DatabaseDao { String id = user.optString("id"); //$NON-NLS-1$ String email = user.optString("email"); //$NON-NLS-1$ - if (!TextUtils.isEmpty(id) && ids.contains(id)) { - createMemberLink(tagId, tagUuid, id, false); - } else if (!TextUtils.isEmpty(email) && emails.contains(email)) { - createMemberLink(tagId, tagUuid, email, false); + if (!TextUtils.isEmpty(id)) { + createMemberLink(tagId, tagUuid, id, !ids.contains(id), false); + } else if (!TextUtils.isEmpty(email)) { + createMemberLink(tagId, tagUuid, email, !emails.contains(email), false); } }