From 74f451bffd51abf14d49e4ca29c17b8fcf4a61a7 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 22 Jan 2013 13:25:22 -0800 Subject: [PATCH] Improvements and fixes to synchronizing tag metadata and deleting links --- .../plugin-src/com/todoroo/astrid/tags/TagService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java index aa792456c..4db00e77f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java @@ -299,7 +299,8 @@ public final class TagService { public void deleteLink(String taskUuid, String tagUuid) { Metadata deleteTemplate = new Metadata(); deleteTemplate.setValue(Metadata.DELETION_DATE, DateUtilities.now()); - metadataDao.update(Criterion.and(TagMetadata.TASK_UUID.eq(taskUuid), TagMetadata.TAG_UUID.eq(tagUuid)), deleteTemplate); + metadataDao.update(Criterion.and(MetadataCriteria.withKey(TagMetadata.KEY), Metadata.DELETION_DATE.eq(0), + TagMetadata.TASK_UUID.eq(taskUuid), TagMetadata.TAG_UUID.eq(tagUuid)), deleteTemplate); } /** @@ -310,7 +311,8 @@ public final class TagService { public void deleteLinks(String taskUuid, String[] tagUuids) { Metadata deleteTemplate = new Metadata(); deleteTemplate.setValue(Metadata.DELETION_DATE, DateUtilities.now()); - metadataDao.update(Criterion.and(TagMetadata.TASK_UUID.eq(taskUuid), TagMetadata.TAG_UUID.in(tagUuids)), deleteTemplate); + metadataDao.update(Criterion.and(MetadataCriteria.withKey(TagMetadata.KEY), Metadata.DELETION_DATE.eq(0), + TagMetadata.TASK_UUID.eq(taskUuid), TagMetadata.TAG_UUID.in(tagUuids)), deleteTemplate); } /** @@ -498,8 +500,7 @@ public final class TagService { // Mark as deleted links that don't exist anymore Metadata deletedLinkTemplate = new Metadata(); deletedLinkTemplate.setValue(Metadata.DELETION_DATE, DateUtilities.now()); - metadataDao.update(Criterion.and(MetadataCriteria.withKey(TagMetadata.KEY), TagMetadata.TASK_UUID.eq(taskUuid), - TagMetadata.TAG_UUID.in(existingLinks.toArray(new Long[existingLinks.size()]))), deletedLinkTemplate); + deleteLinks(taskUuid, existingLinks.toArray(new String[existingLinks.size()])); return true; }