public static Filter getAssignedByMeFilter(Resources r) { int themeFlags = ThemeService.getFilterThemeFlags(); Filter f = new Filter( r.getString(R.string.BFE_Assigned), r.getString(R.string.BFE_Assigned), new QueryTemplate() .join( Join.left( Metadata.TABLE, Criterion.and( Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY), Task.ID.eq(Metadata.TASK)))) .where( Criterion.and( TaskCriteria.isActive(), Criterion.or( Task.CREATOR_ID.eq(0), Task.CREATOR_ID.eq(ActFmPreferenceService.userId())), Criterion.or(Task.USER_ID.neq(0), TaskRabbitMetadata.ID.gt(0)))), null); f.listingIcon = ((BitmapDrawable) r.getDrawable(ThemeService.getDrawable(R.drawable.filter_assigned, themeFlags))) .getBitmap(); return f; }
public TaskListMetadata fetchByTagId(String tagUuid, Property<?>... properties) { return getFirst( Query.select(properties) .where( Criterion.or( TaskListMetadata.TAG_UUID.eq(tagUuid), TaskListMetadata.FILTER.eq(tagUuid)))); }
public boolean memberOfTagData(String email, String tagId, String memberId) { Criterion criterion; if (!RemoteModel.isUuidEmpty(memberId) && !TextUtils.isEmpty(email)) { criterion = Criterion.or( TagMemberMetadata.USER_UUID.eq(email), TagMemberMetadata.USER_UUID.eq(memberId)); } else if (!RemoteModel.isUuidEmpty(memberId)) { criterion = TagMemberMetadata.USER_UUID.eq(memberId); } else if (!TextUtils.isEmpty(email)) { criterion = TagMemberMetadata.USER_UUID.eq(email); } else { return false; } TodorooCursor<TagMetadata> count = query( Query.select(TagMetadata.ID) .where( Criterion.and( TagMetadataCriteria.withKey(TagMemberMetadata.KEY), TagMetadata.TAG_UUID.eq(tagId), criterion))); try { return count.getCount() > 0; } finally { // } }
private synchronized void pushUpdated(GtasksInvoker invoker, SyncResultCallback callback) { TodorooCursor<Task> queued = taskService.query( Query.select(Task.PROPERTIES) .join( Join.left( Metadata.TABLE, Criterion.and( MetadataCriteria.withKey(GtasksMetadata.METADATA_KEY), Task.ID.eq(Metadata.TASK)))) .where( Criterion.or( Task.MODIFICATION_DATE.gt(GtasksMetadata.LAST_SYNC), Criterion.and( Task.USER_ID.neq(Task.USER_ID_SELF), GtasksMetadata.ID.isNotNull()), Metadata.KEY.isNull()))); callback.incrementMax(queued.getCount() * 10); try { Task task = new Task(); for (queued.moveToFirst(); !queued.isAfterLast(); queued.moveToNext()) { task.readFromCursor(queued); try { gtasksSyncService.pushTaskOnSave(task, task.getMergedValues(), invoker, false); } catch (GoogleTasksException e) { handler.handleException("gtasks-sync-io", e, e.getType()); // $NON-NLS-1$ } catch (IOException e) { handler.handleException("gtasks-sync-io", e, e.toString()); // $NON-NLS-1$ } finally { callback.incrementProgress(10); } } } finally { queued.close(); } }
/** * Gets a listing of all tasks that are active & * * @param properties * @return todoroo cursor. PLEASE CLOSE THIS CURSOR! */ private TodorooCursor<Task> getTasksWithReminders(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))))); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); synchronized (this) { if (dataLoaded) return; dataLoaded = true; } String tag = getIntent().getStringExtra(EXTRA_TAG_NAME); long remoteId = getIntent().getLongExtra(EXTRA_TAG_REMOTE_ID, 0); if (tag == null && remoteId == 0) return; TodorooCursor<TagData> cursor = tagDataService.query( Query.select(TagData.PROPERTIES) .where( Criterion.or( TagData.NAME.eq(tag), Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId))))); try { tagData = new TagData(); if (cursor.getCount() == 0) { tagData.setValue(TagData.NAME, tag); tagData.setValue(TagData.REMOTE_ID, remoteId); tagDataService.save(tagData); } else { cursor.moveToFirst(); tagData.readFromCursor(cursor); } } finally { cursor.close(); } String fetchKey = LAST_FETCH_KEY + tagData.getId(); long lastFetchDate = Preferences.getLong(fetchKey, 0); if (DateUtilities.now() > lastFetchDate + 300000L) { refreshData(false, false); Preferences.setLong(fetchKey, DateUtilities.now()); } setUpUpdateList(); setUpMemberPage(); }
/** @param context */ public static Filter filterFromList( Context context, ProducteevDashboard dashboard, long currentUserId) { String dashboardTitle = dashboard.getName(); String title = dashboard.getName(); ContentValues values = new ContentValues(); values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY); values.put(ProducteevTask.DASHBOARD_ID.name, dashboard.getId()); values.put(ProducteevTask.ID.name, 0); values.put(ProducteevTask.CREATOR_ID.name, 0); values.put(ProducteevTask.RESPONSIBLE_ID.name, 0); Filter filter; if (currentUserId != -1) filter = new Filter( dashboardTitle, title, new QueryTemplate() .join(ProducteevDataService.METADATA_JOIN) .where( Criterion.and( MetadataCriteria.withKey(ProducteevTask.METADATA_KEY), TaskCriteria.isActive(), TaskCriteria.isVisible(), Criterion.or( ProducteevTask.CREATOR_ID.eq(currentUserId), ProducteevTask.RESPONSIBLE_ID.eq(currentUserId)), ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))), values); else filter = new Filter( dashboardTitle, title, new QueryTemplate() .join(ProducteevDataService.METADATA_JOIN) .where( Criterion.and( MetadataCriteria.withKey(ProducteevTask.METADATA_KEY), TaskCriteria.isActive(), TaskCriteria.isVisible(), ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))), values); return filter; }
/** Fixes task filter missing tasks bug, migrate PDV/RTM notes */ @SuppressWarnings("nls") private void upgrade3To3_7() { TodorooCursor<Task> t = taskService.query(Query.select(Task.ID, Task.DUE_DATE).where(Task.DUE_DATE.gt(0))); Task task = new Task(); for (t.moveToFirst(); !t.isAfterLast(); t.moveToNext()) { task.readFromCursor(t); if (task.hasDueDate()) { task.setValue(Task.DUE_DATE, task.getValue(Task.DUE_DATE) / 1000L * 1000L); taskService.save(task); } } t.close(); TodorooCursor<Metadata> m = metadataService.query( Query.select(Metadata.PROPERTIES) .where( Criterion.or( Metadata.KEY.eq("producteev-note"), Metadata.KEY.eq("rmilk-note")))); StringProperty PDV_NOTE_ID = Metadata.VALUE1; StringProperty PDV_NOTE_MESSAGE = Metadata.VALUE2; LongProperty PDV_NOTE_CREATED = new LongProperty(Metadata.TABLE, Metadata.VALUE3.name); StringProperty RTM_NOTE_ID = Metadata.VALUE1; StringProperty RTM_NOTE_TITLE = Metadata.VALUE2; StringProperty RTM_NOTE_TEXT = Metadata.VALUE3; LongProperty RTM_NOTE_CREATED = new LongProperty(Metadata.TABLE, Metadata.VALUE4.name); Metadata metadata = new Metadata(); for (m.moveToFirst(); !m.isAfterLast(); m.moveToNext()) { metadata.readFromCursor(m); String id, body, title, provider; long created; if ("rmilk-note".equals(metadata.getValue(Metadata.KEY))) { id = metadata.getValue(RTM_NOTE_ID); body = metadata.getValue(RTM_NOTE_TEXT); title = metadata.getValue(RTM_NOTE_TITLE); created = metadata.getValue(RTM_NOTE_CREATED); provider = MilkNoteHelper.PROVIDER; } else { id = metadata.getValue(PDV_NOTE_ID); body = metadata.getValue(PDV_NOTE_MESSAGE); created = metadata.getValue(PDV_NOTE_CREATED); title = DateUtilities.getDateStringWithWeekday(ContextManager.getContext(), new Date(created)); provider = ProducteevDataService.NOTE_PROVIDER; } metadata.setValue(Metadata.KEY, NoteMetadata.METADATA_KEY); metadata.setValue(Metadata.CREATION_DATE, created); metadata.setValue(NoteMetadata.BODY, body); metadata.setValue(NoteMetadata.TITLE, title); metadata.setValue(NoteMetadata.THUMBNAIL, null); metadata.setValue(NoteMetadata.EXT_PROVIDER, provider); metadata.setValue(NoteMetadata.EXT_ID, id); metadata.clearValue(Metadata.ID); metadataService.save(metadata); } m.close(); }
/** @return tasks that have a blank or null title */ @SuppressWarnings("nls") public static Criterion hasNoTitle() { return Criterion.or(Task.TITLE.isNull(), Task.TITLE.eq("")); }