Remove most properties varargs

pull/618/head
Alex Baker 7 years ago
parent e70686068d
commit 3740e67455

@ -65,7 +65,7 @@ public class MetadataDaoTests extends DatabaseTestCase {
assertEquals(1, metadataDao.toList(Query.select(Metadata.ID)).size());
long happyId = metadata.getId();
assertNotSame(Metadata.NO_ID, happyId);
metadata = metadataDao.fetch(happyId, KEYS);
metadata = metadataDao.fetch(happyId);
assertEquals("happy", metadata.getKey());
// create "sad"
@ -83,9 +83,9 @@ public class MetadataDaoTests extends DatabaseTestCase {
assertEquals(2, metadataDao.toList(Query.select(Metadata.ID)).size());
// check state
metadata = metadataDao.fetch(happyId, KEYS);
metadata = metadataDao.fetch(happyId);
assertEquals("happy", metadata.getKey());
metadata = metadataDao.fetch(sadId, KEYS);
metadata = metadataDao.fetch(sadId);
assertEquals("melancholy", metadata.getKey());
// delete sad

@ -52,7 +52,7 @@ public class TaskDaoTests extends DatabaseTestCase {
assertEquals(1, taskDao.toList(Query.select(IDS)).size());
long happyId = task.getId();
assertNotSame(Task.NO_ID, happyId);
task = taskDao.fetch(happyId, TITLES);
task = taskDao.fetch(happyId);
assertEquals("happy", task.getTitle());
// create task "sad"
@ -69,9 +69,9 @@ public class TaskDaoTests extends DatabaseTestCase {
assertEquals(2, taskDao.toList(Query.select(IDS)).size());
// check state
task = taskDao.fetch(happyId, TITLES);
task = taskDao.fetch(happyId);
assertEquals("happy", task.getTitle());
task = taskDao.fetch(sadId,TITLES);
task = taskDao.fetch(sadId);
assertEquals("melancholy", task.getTitle());
}
@ -166,7 +166,7 @@ public class TaskDaoTests extends DatabaseTestCase {
public void testInvalidIndex() {
assertEquals(0, taskDao.toList(Query.select(IDS)).size());
assertNull(taskDao.fetch(1, IDS));
assertNull(taskDao.fetch(1));
assertFalse(taskDao.delete(1));

@ -48,8 +48,7 @@ public class TaskTest extends InjectingTestCase {
public void testReadTaskFromDb() {
Task task = new Task();
taskDao.save(task);
Property[] properties = asQueryProperties(Task.TABLE, task.getDatabaseValues());
final Task fromDb = taskDao.fetch(task.getId(), properties);
final Task fromDb = taskDao.fetch(task.getId());
compareRemoteModel(task, fromDb);
}

@ -146,7 +146,7 @@ class OrderedMetadataListFragmentHelper {
final ArrayList<Long> chained = new ArrayList<>();
final int parentIndent = item.getValue(GtasksMetadata.INDENT);
updater.applyToChildren(list, itemId, node -> {
Task childTask = taskDao.fetch(node.taskId, Task.RECURRENCE);
Task childTask = taskDao.fetch(node.taskId);
if(!TextUtils.isEmpty(childTask.getRecurrence())) {
Metadata metadata = updater.getTaskMetadata(node.taskId);
metadata.setValue(GtasksMetadata.INDENT, parentIndent);

@ -214,7 +214,7 @@ public class GtasksSyncService {
final AtomicLong parentToMatch = new AtomicLong(gtasksMetadata.getValue(GtasksMetadata.PARENT_TASK));
final AtomicReference<String> sibling = new AtomicReference<>();
GtasksTaskListUpdater.OrderedListIterator iterator = (taskId, metadata) -> {
Task t = taskDao.fetch(taskId, Task.TITLE, Task.DELETION_DATE);
Task t = taskDao.fetch(taskId);
if (t == null || t.isDeleted()) {
return;
}

@ -383,7 +383,7 @@ public class GoogleTaskSyncAdapter extends InjectingAbstractThreadedSyncAdapter
// merge astrid dates with google dates
if(task.task.isSaved()) {
Task local = taskDao.fetch(task.task.getId(), Task.PROPERTIES);
Task local = taskDao.fetch(task.task.getId());
if (local == null) {
task.task.clearValue(Task.ID);
task.task.clearValue(Task.UUID);

@ -64,7 +64,7 @@ public class GeofenceTransitionsIntentService extends InjectingJobIntentService
private void triggerNotification(com.google.android.gms.location.Geofence triggeringGeofence) {
String requestId = triggeringGeofence.getRequestId();
try {
Metadata fetch = metadataDao.fetch(Long.parseLong(requestId), Metadata.TASK, GeofenceFields.PLACE, GeofenceFields.LATITUDE, GeofenceFields.LONGITUDE, GeofenceFields.RADIUS);
Metadata fetch = metadataDao.fetch(Long.parseLong(requestId));
Geofence geofence = new Geofence(fetch);
notifier.triggerTaskNotification(geofence.getTaskId(), ReminderService.TYPE_ALARM);
} catch(Exception e) {

@ -417,7 +417,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
Task model = null;
if (taskId> -1L) {
model = taskDao.fetch(taskId, Task.PROPERTIES);
model = taskDao.fetch(taskId);
}
// not found by id or was never passed an id

@ -265,7 +265,7 @@ public class TasksXmlImporter {
String uuid = metadata.getValue(Metadata.VALUE2);
long deletionDate = metadata.getDeletionDate();
// UUID is uniquely for every TagData, so we don't need to test the name
TagData tagData = tagDataDao.getByUuid(uuid, TagData.ID);
TagData tagData = tagDataDao.getByUuid(uuid);
//If you sync with Google tasks it adds some Google task metadata.
//For this metadata we don't create a list!
if(key.equals(TaskToTagMetadata.KEY) && tagData == null && deletionDate == 0) {

@ -36,10 +36,6 @@ public class MetadataDao {
dao = new DatabaseDao<>(database, Metadata.class);
}
public List<Metadata> query(Query query) {
return dao.toList(query);
}
public Metadata getFirst(Query query) {
return dao.getFirst(query);
}
@ -78,8 +74,8 @@ public class MetadataDao {
dao.saveExisting(metadata);
}
public Metadata fetch(long id, Property<?>... properties) {
return dao.fetch(id, properties);
public Metadata fetch(long id) {
return dao.fetch(id, Metadata.PROPERTIES);
}
// --- SQL clause generators

@ -5,13 +5,10 @@
*/
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Callback;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import org.tasks.injection.ApplicationScope;
@ -35,8 +32,8 @@ public class TagDataDao {
dao = new RemoteModelDao<>(database, TagData.class);
}
public TagData getTagByName(String name, Property<?>... properties) {
return dao.getFirst(Query.select(properties).where(TagData.NAME.eqCaseInsensitive(name)));
public TagData getTagByName(String name) {
return dao.getFirst(Query.select(TagData.PROPERTIES).where(TagData.NAME.eqCaseInsensitive(name)));
}
public List<TagData> allTags() {
@ -47,11 +44,7 @@ public class TagDataDao {
}
public TagData getByUuid(String uuid) {
return getByUuid(uuid, TagData.PROPERTIES);
}
public TagData getByUuid(String uuid, Property<?>... properties) {
return dao.getFirst(Query.select(properties).where(TagData.UUID.eq(uuid)));
return dao.getFirst(Query.select(TagData.PROPERTIES).where(TagData.UUID.eq(uuid)));
}
public List<TagData> tagDataOrderedByName() {

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.TaskAttachment;
@ -24,15 +23,15 @@ public class TaskAttachmentDao {
}
public boolean taskHasAttachments(String taskUuid) {
return dao.count(byUuid(taskUuid, TaskAttachment.TASK_UUID).limit(1)) > 0;
return dao.count(byUuid(taskUuid).limit(1)) > 0;
}
public List<TaskAttachment> getAttachments(String taskUuid) {
return dao.toList(byUuid(taskUuid, TaskAttachment.PROPERTIES));
return dao.toList(byUuid(taskUuid));
}
private static Query byUuid(String taskUuid, Property<?>... properties) {
return Query.select(properties).where(
private static Query byUuid(String taskUuid) {
return Query.select(TaskAttachment.PROPERTIES).where(
Criterion.and(TaskAttachment.TASK_UUID.eq(taskUuid),
TaskAttachment.DELETED_AT.eq(0))
);

@ -83,10 +83,6 @@ public class TaskDao {
return dao.fetch(id, Task.PROPERTIES);
}
public Task fetch(long id, Property<?>... properties) {
return dao.fetch(id, properties);
}
public int count(Filter filter) {
String query = PermaSql.replacePlaceholders(filter.getSqlQuery());
return count(Query.select(Task.ID).withQueryTemplate(query));
@ -397,17 +393,9 @@ public class TaskDao {
}
public TodorooCursor<Task> fetchFiltered(String queryTemplate, Property<?>... properties) {
return query(fetchFilteredQuery(queryTemplate, properties));
}
private Query fetchFilteredQuery(String queryTemplate, Property<?>... properties) {
if (queryTemplate == null) {
return Query.selectDistinct(properties);
}
String sql = PermaSql.replacePlaceholders(queryTemplate);
return Query.select(properties).withQueryTemplate(sql);
return query(queryTemplate == null
? Query.selectDistinct(properties)
: Query.select(properties).withQueryTemplate(PermaSql.replacePlaceholders(queryTemplate)));
}
}

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.TagData;
@ -27,8 +26,8 @@ public class TaskListMetadataDao {
dao = new RemoteModelDao<>(database, TaskListMetadata.class);
}
public TaskListMetadata fetchByTagId(String tagUuid, Property<?>... properties) {
return dao.getFirst(Query.select(properties).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
public TaskListMetadata fetchByTagId(String tagUuid) {
return dao.getFirst(Query.select(TaskListMetadata.PROPERTIES).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
TaskListMetadata.FILTER.eq(tagUuid))));
}

@ -56,7 +56,7 @@ public class GCalHelper {
if (!TextUtils.isEmpty(task.getCalendarURI())) {
uri = task.getCalendarURI();
} else {
task = taskDao.fetch(task.getId(), Task.CALENDAR_URI);
task = taskDao.fetch(task.getId());
if(task == null) {
return null;
}

@ -85,7 +85,7 @@ public final class ReminderService {
if(taskDao != null) {
for(Property<?> property : NOTIFICATION_PROPERTIES) {
if(!task.containsValue(property)) {
task = taskDao.fetch(taskId, NOTIFICATION_PROPERTIES);
task = taskDao.fetch(taskId);
if(task == null) {
return;
}

@ -142,7 +142,7 @@ public class TaskCreator {
}
private void createLink(Task task, String tagName) {
TagData tagData = tagDataDao.getTagByName(tagName, TagData.NAME, TagData.UUID);
TagData tagData = tagDataDao.getTagByName(tagName);
if (tagData == null) {
tagData = new TagData();
tagData.setName(tagName);

@ -38,7 +38,7 @@ public class TaskDuplicator {
public List<Task> duplicate(List<Task> tasks) {
List<Task> result = new ArrayList<>();
for (Task task : tasks) {
result.add(clone(taskDao.fetch(task.getId(), Task.PROPERTIES), true));
result.add(clone(taskDao.fetch(task.getId()), true));
}
localBroadcastManager.broadcastRefresh();
return result;

@ -63,14 +63,14 @@ public class SubtasksHelper {
if (filter instanceof GtasksFilter) {
query = GtasksFilter.toManualOrder(query);
} else {
TagData tagData = tagDataDao.getTagByName(filter.listingTitle, TagData.UUID, TagData.TAG_ORDERING);
TagData tagData = tagDataDao.getTagByName(filter.listingTitle);
TaskListMetadata tlm = null;
if (tagData != null) {
tlm = taskListMetadataDao.fetchByTagId(tagData.getUuid(), TaskListMetadata.TASK_IDS);
tlm = taskListMetadataDao.fetchByTagId(tagData.getUuid());
} else if (BuiltInFilterExposer.isInbox(context, filter)) {
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.TASK_IDS);
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_ALL);
} else if (BuiltInFilterExposer.isTodayFilter(context, filter)) {
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.TASK_IDS);
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY);
}
query = query.replaceAll("ORDER BY .*", "");

@ -75,7 +75,7 @@ public class SubtasksListFragment extends TaskListFragment {
if (TextUtils.isEmpty(filterId)) {
return null;
}
TaskListMetadata taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES);
TaskListMetadata taskListMetadata = taskListMetadataDao.fetchByTagId(filterId);
if (taskListMetadata == null) {
String defaultOrder = preferences.getStringValue(prefId);
if (TextUtils.isEmpty(defaultOrder)) {

@ -49,7 +49,7 @@ public class SubtasksTagListFragment extends TagListFragment {
@Override
public void setTaskAdapter() {
String tdId = tagData.getUuid();
TaskListMetadata taskListMetadata = taskListMetadataDao.fetchByTagId(tagData.getUuid(), TaskListMetadata.PROPERTIES);
TaskListMetadata taskListMetadata = taskListMetadataDao.fetchByTagId(tagData.getUuid());
if (taskListMetadata == null && !RemoteModel.isUuidEmpty(tdId)) {
taskListMetadata = new TaskListMetadata();
taskListMetadata.setTagUUID(tdId);

@ -70,7 +70,7 @@ public final class TagService {
MetadataCriteria.withKey(TaskToTagMetadata.KEY))).
orderBy(order).groupBy(TaskToTagMetadata.TAG_NAME);
final List<TagData> array = new ArrayList<>();
for (Metadata metadata : metadataDao.query(query)) {
for (Metadata metadata : metadataDao.toList(query)) {
TagData tag = tagFromUUID(metadata.getValue(TaskToTagMetadata.TAG_UUID));
if (tag != null) {
array.add(tag);
@ -80,7 +80,7 @@ public final class TagService {
}
public TagData tagFromUUID(String uuid) {
return tagDataDao.getByUuid(uuid, TagData.PROPERTIES);
return tagDataDao.getByUuid(uuid);
}
public List<TagData> getTagDataForTask(String uuid) {
@ -109,7 +109,7 @@ public final class TagService {
MetadataCriteria.byTask(taskId)))
.orderBy(Order.asc(Functions.upper(TaskToTagMetadata.TAG_NAME)));
final ArrayList<String> tagNames = new ArrayList<>();
for (Metadata entry : metadataDao.query(query)) {
for (Metadata entry : metadataDao.toList(query)) {
tagNames.add(entry.getValue(TaskToTagMetadata.TAG_NAME));
}
return tagNames;
@ -142,7 +142,7 @@ public final class TagService {
return tagMetadata.getValue(TaskToTagMetadata.TAG_NAME);
}
TagData tagData = tagDataDao.getTagByName(tag, TagData.NAME);
TagData tagData = tagDataDao.getTagByName(tag);
if (tagData != null) {
return tagData.getName();
}

@ -249,7 +249,7 @@ public final class TagsControlSet extends TaskEditControlFragment {
if (Strings.isNullOrEmpty(text)) {
continue;
}
TagData tagByName = tagDataDao.getTagByName(text, TagData.PROPERTIES);
TagData tagByName = tagDataDao.getTagByName(text);
if (tagByName != null) {
if (!isSelected(tags, text)) {
setTagSelected(tagByName);

@ -71,7 +71,7 @@ public class TimerPlugin {
// if this call comes from tasklist, then we need to fill in the gaps to handle this correctly
// this is needed just for stopping a task
if (!task.containsNonNullValue(Task.TIMER_START)) {
task = taskDao.fetch(task.getId(), Task.ID, Task.TIMER_START, Task.ELAPSED_SECONDS);
task = taskDao.fetch(task.getId());
}
if (task == null) {
return;

@ -170,7 +170,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
}
private boolean clashes(String newName) {
TagData existing = tagDataDao.getTagByName(newName, TagData.PROPERTIES);
TagData existing = tagDataDao.getTagByName(newName);
return existing != null && tagData.getId() != existing.getId();
}

@ -64,7 +64,7 @@ public class CalendarEventProvider {
public boolean deleteEvent(Task task) {
if (!task.containsNonNullValue(Task.CALENDAR_URI)) {
task = taskDao.fetch(task.getId(), Task.CALENDAR_URI);
task = taskDao.fetch(task.getId());
if(task == null) {
return false;
}

@ -27,7 +27,7 @@ public class CompleteTaskReceiver extends InjectingBroadcastReceiver {
long taskId = intent.getLongExtra(TASK_ID, 0);
boolean flipState = intent.getBooleanExtra(TOGGLE_STATE, false);
Timber.i("Completing %s", taskId);
Task task = taskDao.fetch(taskId, Task.ID, Task.COMPLETION_DATE);
Task task = taskDao.fetch(taskId);
if (task != null) {
taskDao.setComplete(task, !flipState || !task.isCompleted());
} else {

@ -353,7 +353,7 @@ class ViewHolder extends MultiSelectorBindingHolder {
}
private void showEditNotesDialog(final Task task) {
Task t = taskDao.fetch(task.getId(), Task.NOTES);
Task t = taskDao.fetch(task.getId());
if (t == null || !t.hasNotes()) {
return;
}

Loading…
Cancel
Save