From bbaee365929d6a3a401c592d5caadcf688c02a71 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 23 Oct 2012 11:24:15 -0700 Subject: [PATCH] Removed a bunch of unused stuff --- .../astrid/actfm/sync/ActFmDataService.java | 75 ------------------- .../astrid/actfm/sync/ActFmTaskContainer.java | 62 --------------- 2 files changed, 137 deletions(-) delete mode 100644 astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmTaskContainer.java diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmDataService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmDataService.java index c57b88aea..9128bbfb9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmDataService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmDataService.java @@ -5,8 +5,6 @@ */ package com.todoroo.astrid.actfm.sync; -import java.util.ArrayList; - import org.json.JSONException; import org.json.JSONObject; @@ -22,7 +20,6 @@ import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Query; -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.UserDao; @@ -30,7 +27,6 @@ import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.User; -import com.todoroo.astrid.notes.NoteMetadata; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.tags.TagService; @@ -42,9 +38,6 @@ public final class ActFmDataService { /** Utility for joining tasks with metadata */ public static final Join METADATA_JOIN = Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK)); - /** NoteMetadata provider string */ - public static final String NOTE_PROVIDER = "actfm-comment"; //$NON-NLS-1$ - // --- instance variables protected final Context context; @@ -101,74 +94,6 @@ public final class ActFmDataService { Task.MODIFICATION_DATE.gt(Task.LAST_SYNC))).groupBy(Task.ID)); } - /** - * Searches for a local task with same remote id, updates this task's id - * @param remoteTask - * @return true if found local match - */ - public boolean findLocalMatch(ActFmTaskContainer remoteTask) { - if(remoteTask.task.getId() != Task.NO_ID) - return true; - TodorooCursor cursor = taskDao.query(Query.select(Task.ID). - where(Task.REMOTE_ID.eq(remoteTask.task.getValue(Task.REMOTE_ID)))); - try { - if(cursor.getCount() == 0) - return false; - cursor.moveToFirst(); - remoteTask.task.setId(cursor.get(Task.ID)); - return true; - } finally { - cursor.close(); - } - } - - /** - * Saves a task and its metadata - * @param task - */ - public void saveTaskAndMetadata(ActFmTaskContainer task) { - taskDao.save(task.task); - - metadataService.synchronizeMetadata(task.task.getId(), task.metadata, - Criterion.or(Criterion.and(MetadataCriteria.withKey(NoteMetadata.METADATA_KEY), - NoteMetadata.EXT_PROVIDER.eq(NOTE_PROVIDER)), - MetadataCriteria.withKey(TagService.KEY))); - } - - /** - * Reads a task and its metadata - * @param task - * @return - */ - public ActFmTaskContainer readTaskAndMetadata(TodorooCursor taskCursor) { - Task task = new Task(taskCursor); - - // read tags, notes, etc - ArrayList metadata = new ArrayList(); - TodorooCursor metadataCursor = metadataService.query(Query.select(Metadata.PROPERTIES). - where(Criterion.and(MetadataCriteria.byTask(task.getId()), - Criterion.or(MetadataCriteria.withKey(TagService.KEY), - MetadataCriteria.withKey(NoteMetadata.METADATA_KEY))))); - try { - for(metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) { - metadata.add(new Metadata(metadataCursor)); - } - } finally { - metadataCursor.close(); - } - - return new ActFmTaskContainer(task, metadata); - } - - /** - * Reads task notes out of a task - */ - public TodorooCursor getTaskNotesCursor(long taskId) { - TodorooCursor cursor = metadataService.query(Query.select(Metadata.PROPERTIES). - where(MetadataCriteria.byTaskAndwithKey(taskId, NoteMetadata.METADATA_KEY))); - return cursor; - } - /** * Save / Merge JSON tagData * @param tagObject diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmTaskContainer.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmTaskContainer.java deleted file mode 100644 index 437a8b445..000000000 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmTaskContainer.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.actfm.sync; - -import java.util.ArrayList; -import java.util.Date; - -import org.json.JSONObject; - -import com.todoroo.andlib.service.ContextManager; -import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.astrid.data.Metadata; -import com.todoroo.astrid.data.Task; -import com.todoroo.astrid.notes.NoteMetadata; -import com.todoroo.astrid.sync.SyncContainer; - -/** - * RTM Task Container - * - * @author Tim Su - * - */ -public class ActFmTaskContainer extends SyncContainer { - - public ActFmTaskContainer(Task task, ArrayList metadata) { - this.task = task; - this.metadata = metadata; - } - - @SuppressWarnings("nls") - public ActFmTaskContainer(Task task, ArrayList metadata, JSONObject remoteTask) { - this(task, metadata); - task.setValue(Task.REMOTE_ID, remoteTask.optLong("id")); - } - - /** create note metadata from comment json object */ - @SuppressWarnings("nls") - public static Metadata newNoteMetadata(JSONObject comment) { - Metadata metadata = new Metadata(); - metadata.setValue(Metadata.KEY, NoteMetadata.METADATA_KEY); - metadata.setValue(NoteMetadata.EXT_ID, comment.optString("id")); - metadata.setValue(NoteMetadata.EXT_PROVIDER, - ActFmDataService.NOTE_PROVIDER); - - Date creationDate = new Date(comment.optInt("date") * 1000L); - metadata.setValue(Metadata.CREATION_DATE, creationDate.getTime()); - metadata.setValue(NoteMetadata.BODY, comment.optString("message")); - - JSONObject owner = comment.optJSONObject("owner"); - metadata.setValue(NoteMetadata.THUMBNAIL, owner.optString("picture")); - String title = String.format("%s on %s", - owner.optString("name"), - DateUtilities.getDateString(ContextManager.getContext(), creationDate)); - metadata.setValue(NoteMetadata.TITLE, title); - - return metadata; - } - -}