Remove user ids

pull/189/head
Alex Baker 10 years ago
parent 3ceaabdd82
commit 387f871f86

@ -43,8 +43,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
public static final int PROP_FLAG_NULLABLE = 1;
/** Is this field a date? */
public static final int PROP_FLAG_DATE = 1 << 1;
/** Is this field a user id? */
public static final int PROP_FLAG_USER_ID = 1 << 2;
/** Is this field a boolean? */
public static final int PROP_FLAG_BOOLEAN = 1 << 3;
/** Is this field a serialized JSON object? */

@ -35,12 +35,6 @@ abstract public class RemoteModel extends AbstractModel {
/** remote id property */
public static final StringProperty UUID_PROPERTY = new StringProperty(null, UUID_PROPERTY_NAME);
/** user id property common to all remote models */
protected static final String USER_ID_PROPERTY_NAME = "userId"; //$NON-NLS-1$
/** user json property common to all remote models */
protected static final String USER_JSON_PROPERTY_NAME = "user"; //$NON-NLS-1$
/** pushed at date property name */
public static final String PUSHED_AT_PROPERTY_NAME = "pushedAt"; //$NON-NLS-1$

@ -34,14 +34,6 @@ public final class TagData extends RemoteModel {
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
/** User id */
public static final StringProperty USER_ID = new StringProperty(
TABLE, USER_ID_PROPERTY_NAME, Property.PROP_FLAG_USER_ID);
/** User Object (JSON) */
@Deprecated public static final StringProperty USER = new StringProperty(
TABLE, USER_JSON_PROPERTY_NAME);
/** Remote goal id */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
@ -136,8 +128,6 @@ public final class TagData extends RemoteModel {
private static final ContentValues defaultValues = new ContentValues();
static {
defaultValues.put(USER_ID.name, "0");
defaultValues.put(USER.name, "");
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(NAME.name, "");
defaultValues.put(IS_TEAM.name, 1);

@ -152,14 +152,6 @@ public class Task extends RemoteModel {
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME, Property.PROP_FLAG_NULLABLE);
/** Assigned user id */
public static final StringProperty USER_ID = new StringProperty(
TABLE, USER_ID_PROPERTY_NAME, Property.PROP_FLAG_USER_ID);
/** Creator user id */
public static final StringProperty CREATOR_ID = new StringProperty(
TABLE, "creatorId", Property.PROP_FLAG_USER_ID);
/** Last Sync date */
@Deprecated
public static final LongProperty LAST_SYNC = new LongProperty(
@ -180,11 +172,6 @@ public class Task extends RemoteModel {
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Task.class);
// --- user id special values
/** user id = myself */
public static final String USER_ID_SELF = "0";
// --- notification flags
/** whether to send a reminder at deadline */
@ -261,8 +248,6 @@ public class Task extends RemoteModel {
defaultValues.put(LAST_SYNC.name, 0);
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(USER_ID.name, "0");
defaultValues.put(CREATOR_ID.name, 0);
defaultValues.put(PUSHED_AT.name, 0L);
defaultValues.put(ATTACHMENTS_PUSHED_AT.name, 0L);
defaultValues.put(USER_ACTIVITIES_PUSHED_AT.name, 0L);
@ -590,10 +575,6 @@ public class Task extends RemoteModel {
return getValue(CALENDAR_URI);
}
public String getUserID() {
return getValue(USER_ID);
}
public Integer getImportance() {
return getValue(IMPORTANCE);
}

@ -43,10 +43,6 @@ public final class TaskAttachment extends RemoteModel {
public static final LongProperty PUSHED_AT = new LongProperty(
TABLE, PUSHED_AT_PROPERTY_NAME);
/** Creator user id */
public static final StringProperty USER_UUID = new StringProperty(
TABLE, "user_id");
/** Task uuid */
public static final StringProperty TASK_UUID = new StringProperty(
TABLE, "task_id");
@ -90,7 +86,6 @@ public final class TaskAttachment extends RemoteModel {
static {
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(PUSHED_AT.name, 0);
defaultValues.put(USER_UUID.name, NO_UUID);
defaultValues.put(TASK_UUID.name, NO_UUID);
defaultValues.put(NAME.name, "");
defaultValues.put(URL.name, "");
@ -137,7 +132,6 @@ public final class TaskAttachment extends RemoteModel {
TaskAttachment attachment = new TaskAttachment();
attachment.setTaskUUID(taskUuid);
attachment.setName(fileName);
attachment.setUserUUID(Task.USER_ID_SELF);
attachment.setFilePath(filePath);
attachment.setContentType(fileType);
attachment.setCreatedAt(DateUtilities.now());
@ -177,10 +171,6 @@ public final class TaskAttachment extends RemoteModel {
setValue(CREATED_AT, createdAt);
}
public void setUserUUID(String userUuid) {
setValue(USER_UUID, userUuid);
}
public void setTaskUUID(String taskUuid) {
setValue(TASK_UUID, taskUuid);
}

@ -31,10 +31,6 @@ public class UserActivity extends RemoteModel {
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** User ID (activity initiator) */
public static final StringProperty USER_UUID = new StringProperty(
TABLE, "user_uuid", Property.PROP_FLAG_USER_ID);
/** Action */
public static final StringProperty ACTION = new StringProperty(
TABLE, "action");
@ -87,7 +83,6 @@ public class UserActivity extends RemoteModel {
static {
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(USER_UUID.name, NO_UUID);
defaultValues.put(ACTION.name, "");
defaultValues.put(MESSAGE.name, "");
defaultValues.put(PICTURE.name, "");
@ -123,10 +118,6 @@ public class UserActivity extends RemoteModel {
setValue(MESSAGE, message);
}
public void setUserUUID(String userUuid) {
setValue(USER_UUID, userUuid);
}
public void setTargetName(String targetName) {
setValue(TARGET_NAME, targetName);
}

@ -67,8 +67,6 @@ public class NameMaps {
putTaskPropertyToServerName(Task.DELETION_DATE, "deleted_at", true);
putTaskPropertyToServerName(Task.NOTES, "notes", true);
putTaskPropertyToServerName(Task.RECURRENCE, "repeat", true);
putTaskPropertyToServerName(Task.USER_ID, "user_id", true);
putTaskPropertyToServerName(Task.CREATOR_ID, "creator_id", false);
putTaskPropertyToServerName(Task.UUID, "uuid", false);
putTaskPropertyToServerName(Task.CLASSIFICATION, "classification", false);
}
@ -93,7 +91,6 @@ public class NameMaps {
TAG_DATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
TAG_PROPERTIES_EXCLUDED = new HashSet<>();
putTagPropertyToServerName(TagData.USER_ID, "user_id", true);
putTagPropertyToServerName(TagData.NAME, "name", true);
putTagPropertyToServerName(TagData.CREATION_DATE, "created_at", true);
putTagPropertyToServerName(TagData.DELETION_DATE, "deleted_at", true);
@ -123,7 +120,6 @@ public class NameMaps {
USER_ACTIVITY_PROPERTIES_EXCLUDED = new HashSet<>();
putUserActivityPropertyToServerName(UserActivity.UUID, "uuid", false);
putUserActivityPropertyToServerName(UserActivity.USER_UUID, "user_id", false);
putUserActivityPropertyToServerName(UserActivity.ACTION, "action", true);
putUserActivityPropertyToServerName(UserActivity.MESSAGE, "message", true);
putUserActivityPropertyToServerName(UserActivity.PICTURE, "picture", true);
@ -153,7 +149,6 @@ public class NameMaps {
TASK_ATTACHMENT_PROPERTIES_EXCLUDED = new HashSet<>();
putTaskAttachmentPropertyToServerName(TaskAttachment.UUID, "uuid", false);
putTaskAttachmentPropertyToServerName(TaskAttachment.USER_UUID, "user_id", false);
putTaskAttachmentPropertyToServerName(TaskAttachment.TASK_UUID, "task_id", true);
putTaskAttachmentPropertyToServerName(TaskAttachment.NAME, "name", false);
putTaskAttachmentPropertyToServerName(TaskAttachment.URL, "url", false);

@ -115,7 +115,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Task.ELAPSED_SECONDS,
Task.TIMER_START,
Task.RECURRENCE,
Task.USER_ID,
Task.REMINDER_LAST,
Task.SOCIAL_REMINDER,
HAS_NOTES_PROPERTY, // Whether or not the task has notes

@ -12,6 +12,7 @@ import android.content.res.Resources;
import android.os.Bundle;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
@ -22,7 +23,6 @@ import com.todoroo.astrid.api.AstridFilterExposer;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
@ -81,7 +81,7 @@ public final class CustomFilterExposer extends InjectingBroadcastReceiver implem
Filter recent = new Filter(r.getString(R.string.BFE_Recent),
r.getString(R.string.BFE_Recent),
new QueryTemplate().where(
TaskCriteria.ownedByMe()).orderBy(
Criterion.all).orderBy(
Order.desc(Task.MODIFICATION_DATE)).limit(15),
null);
list.add(recent);

@ -86,9 +86,8 @@ public class TaskDao extends RemoteModelDao<Task> {
/** @return tasks that have not yet been completed or deleted and are assigned to me */
public static Criterion activeVisibleMine() {
return Criterion.and(Task.COMPLETION_DATE.eq(0),
Task.DELETION_DATE.eq(0),
Task.HIDE_UNTIL.lt(Functions.now()),
Task.USER_ID.eq(0));
Task.DELETION_DATE.eq(0),
Task.HIDE_UNTIL.lt(Functions.now()));
}
/** @return tasks that have not yet been completed or deleted */
@ -106,12 +105,6 @@ public class TaskDao extends RemoteModelDao<Task> {
public static Criterion hasNoTitle() {
return Criterion.or(Task.TITLE.isNull(), Task.TITLE.eq(""));
}
/** Check if a given task belongs to someone else & is read-only */
public static Criterion ownedByMe() {
return Task.USER_ID.eq(0);
}
}
// --- delete

@ -183,7 +183,7 @@ public class GtasksSyncService {
}
private static final Property<?>[] TASK_PROPERTIES = { Task.ID, Task.TITLE,
Task.NOTES, Task.DUE_DATE, Task.COMPLETION_DATE, Task.DELETION_DATE, Task.USER_ID };
Task.NOTES, Task.DUE_DATE, Task.COMPLETION_DATE, Task.DELETION_DATE };
/**
* Checks to see if any of the values changed are among the properties we sync
@ -229,18 +229,6 @@ public class GtasksSyncService {
com.google.api.services.tasks.model.Task remoteModel;
boolean newlyCreated = false;
if (values.containsKey(Task.USER_ID.name) && !Task.USER_ID_SELF.equals(values.getAsString(Task.USER_ID.name))) {
if (gtasksMetadata != null && !TextUtils.isEmpty(gtasksMetadata.getValue(GtasksMetadata.ID))) {
try {
invoker.deleteGtask(gtasksMetadata.getValue(GtasksMetadata.LIST_ID), gtasksMetadata.getValue(GtasksMetadata.ID));
metadataDao.delete(gtasksMetadata.getId());
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
return;
}
String remoteId;
String listId = gtasksPreferenceService.getDefaultList();
if (listId == null) {

@ -81,7 +81,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
UserActivity.TARGET_ID,
UserActivity.TARGET_NAME,
UserActivity.PICTURE,
UserActivity.USER_UUID,
UserActivity.ID,
ACTIVITY_TYPE_PROPERTY,
};
@ -370,7 +369,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
activity.setTargetId(unionCursor.getString(4));
activity.setTargetName(unionCursor.getString(5));
activity.setPicture(unionCursor.getString(6));
activity.setUserUUID(unionCursor.getString(7));
}
public View getUpdateNotes(NoteOrUpdate note, ViewGroup parent) {
@ -434,7 +432,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
UserActivity userActivity = new UserActivity();
userActivity.setMessage(message);
userActivity.setAction(actionCode);
userActivity.setUserUUID(Task.USER_ID_SELF);
userActivity.setTargetId(uuid);
userActivity.setTargetName(title);
userActivity.setCreatedAt(DateUtilities.now());

@ -106,7 +106,7 @@ public class Notifications extends InjectingBroadcastReceiver {
Task task;
try {
task = taskDao.fetch(id, Task.ID, Task.TITLE, Task.HIDE_UNTIL, Task.COMPLETION_DATE,
Task.DUE_DATE, Task.DELETION_DATE, Task.REMINDER_FLAGS, Task.USER_ID);
Task.DUE_DATE, Task.DELETION_DATE, Task.REMINDER_FLAGS);
if (task == null) {
throw new IllegalArgumentException("cound not find item with id"); //$NON-NLS-1$
}
@ -120,7 +120,7 @@ public class Notifications extends InjectingBroadcastReceiver {
return false;
}
// you're done, or not yours - don't sound, do delete
if (task.isCompleted() || task.isDeleted() || !Task.USER_ID_SELF.equals(task.getUserID())) {
if (task.isCompleted() || task.isDeleted()) {
return false;
}

@ -180,7 +180,7 @@ public final class ReminderService {
// Make sure no alarms are scheduled other than the next one. When that one is shown, it
// will schedule the next one after it, and so on and so forth.
clearAllAlarms(task);
if(task.isCompleted() || task.isDeleted() || !Task.USER_ID_SELF.equals(task.getUserID())) {
if(task.isCompleted() || task.isDeleted()) {
return;
}
@ -471,7 +471,6 @@ public final class ReminderService {
private TodorooCursor<Task> getTasksWithReminders(TaskDao taskDao, Property<?>... properties) {
return taskDao.query(Query.select(properties).where(Criterion.and(
TaskCriteria.isActive(),
TaskCriteria.ownedByMe(),
Criterion.or(Task.REMINDER_FLAGS.gt(0), Task.REMINDER_PERIOD.gt(0)))));
}
}

@ -235,7 +235,7 @@ public class StartupService {
// For some reason these properties are missing for some users.
// Make them exist!
try {
TodorooCursor<Task> tasks = taskService.query(Query.select(Task.UUID, Task.USER_ID).limit(1));
TodorooCursor<Task> tasks = taskService.query(Query.select(Task.UUID).limit(1));
try {
System.err.println(tasks.getCount());
} finally {
@ -244,7 +244,6 @@ public class StartupService {
} catch (SQLiteException e) {
log.error(e.getMessage(), e);
database.tryAddColumn(Task.TABLE, Task.UUID, "'0'"); //$NON-NLS-1$
database.tryAddColumn(Task.TABLE, Task.USER_ID, "0"); //$NON-NLS-1$
}
}

@ -32,7 +32,7 @@ public class DeleteTagActivity extends TagActivity {
@Override
protected Intent ok() {
int deleted = deleteTagMetadata(uuid);
TagData tagData = tagDataDao.fetch(uuid, TagData.ID, TagData.UUID, TagData.DELETION_DATE, TagData.MEMBER_COUNT, TagData.USER_ID);
TagData tagData = tagDataDao.fetch(uuid, TagData.ID, TagData.UUID, TagData.DELETION_DATE, TagData.MEMBER_COUNT);
Intent tagDeleted = new Intent(AstridApiConstants.BROADCAST_EVENT_TAG_DELETED);
if (tagData != null) {
tagData.setDeletionDate(DateUtilities.now());

@ -121,7 +121,6 @@ public final class TagService {
Criterion.not(Task.UUID.in(Query.select(TaskToTagMetadata.TASK_UUID).from(Metadata.TABLE)
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), Metadata.DELETION_DATE.eq(0))))),
TaskCriteria.isActive(),
TaskCriteria.ownedByMe(),
TaskCriteria.isVisible()));
}

@ -80,7 +80,6 @@ public class RefreshScheduler {
long now = currentTimeMillis();
return taskDao.query(Query.select(REFRESH_PROPERTIES).where(Criterion.and(
TaskDao.TaskCriteria.isActive(),
TaskDao.TaskCriteria.ownedByMe(),
Criterion.or(Task.HIDE_UNTIL.gt(now), Task.DUE_DATE.gt(now)))));
}
}

@ -211,7 +211,7 @@ public class WidgetHelper {
long id = preferences.getLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, 0);
TagData tagData;
if (id > 0) {
tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.USER_ID, TagData.MEMBER_COUNT);
tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.MEMBER_COUNT);
if (tagData != null && !tagData.getName().equals(filter.title)) { // Tag has been renamed; rebuild filter
filter = TagFilterExposer.filterFromTagData(context, tagData);
preferences.setString(WidgetConfigActivity.PREF_SQL + widgetId, filter.getSqlQuery());

Loading…
Cancel
Save