Removed a bunch of unused stuff

pull/14/head
Sam Bosley 12 years ago
parent 2999bef8ab
commit bbaee36592

@ -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<Task> 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<Task> taskCursor) {
Task task = new Task(taskCursor);
// read tags, notes, etc
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
TodorooCursor<Metadata> 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<Metadata> getTaskNotesCursor(long taskId) {
TodorooCursor<Metadata> cursor = metadataService.query(Query.select(Metadata.PROPERTIES).
where(MetadataCriteria.byTaskAndwithKey(taskId, NoteMetadata.METADATA_KEY)));
return cursor;
}
/**
* Save / Merge JSON tagData
* @param tagObject

@ -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 <tim@todoroo.com>
*
*/
public class ActFmTaskContainer extends SyncContainer {
public ActFmTaskContainer(Task task, ArrayList<Metadata> metadata) {
this.task = task;
this.metadata = metadata;
}
@SuppressWarnings("nls")
public ActFmTaskContainer(Task task, ArrayList<Metadata> 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;
}
}
Loading…
Cancel
Save