method2testcases
stringlengths
118
6.63k
### Question: LocationTagRepository extends BaseRepository { public List<LocationTag> getLocationTagByLocationId(String id) { List<LocationTag> locationsTags = new ArrayList<>(); try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + getLocationTagTableName() + " WHERE " + LOCATION_ID + " =?", new Strin...
### Question: LocationTagRepository extends BaseRepository { public List<LocationTag> getLocationTagsByTagName(String tagName) { List<LocationTag> locationTags = new ArrayList<>(); try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + getLocationTagTableName() + " WHERE " + NAME + " =?", new String[]{t...
### Question: EligibleCoupleRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(EC_SQL); } void add(EligibleCouple eligibleCouple); void updateDetails(String caseId, Map<String, String> details); void mergeDetails(String caseId, Map<String, String> detai...
### Question: EligibleCoupleRepository extends DrishtiRepository { public void updatePhotoPath(String caseId, String imagePath) { SQLiteDatabase database = masterRepository.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(PHOTO_PATH_COLUMN, imagePath); database.update(EC_TABLE_NAME, values,...
### Question: EligibleCoupleRepository extends DrishtiRepository { public void close(String caseId) { ContentValues values = new ContentValues(); values.put(IS_CLOSED_COLUMN, TRUE.toString()); masterRepository.getWritableDatabase() .update(EC_TABLE_NAME, values, ID_COLUMN + " = ?", new String[]{caseId}); } void add(El...
### Question: SyncUtils { public boolean isAppVersionAllowed() throws PackageManager.NameNotFoundException { boolean isAppVersionAllowed = true; AllSettings settingsRepository = opensrpContent.allSettings(); Setting rawMinAllowedAppVersionSetting=null; try { rawMinAllowedAppVersionSetting = settingsRepository.getSettin...
### Question: EligibleCoupleRepository extends DrishtiRepository { public void add(EligibleCouple eligibleCouple) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(EC_TABLE_NAME, null, createValuesFor(eligibleCouple)); } void add(EligibleCouple eligibleCouple); void updateDetails(Stri...
### Question: EligibleCoupleRepository extends DrishtiRepository { public void updateDetails(String caseId, Map<String, String> details) { SQLiteDatabase database = masterRepository.getWritableDatabase(); EligibleCouple couple = findByCaseID(caseId); if (couple == null) { return; } ContentValues valuesToUpdate = new Co...
### Question: EligibleCoupleRepository extends DrishtiRepository { public List<EligibleCouple> allEligibleCouples() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(EC_TABLE_NAME, EC_TABLE_COLUMNS, IS_OUT_OF_AREA_COLUMN + "" + " = ? AND " + IS_CLOSED_COLUMN + " = ?", ne...
### Question: EligibleCoupleRepository extends DrishtiRepository { public List<String> villages() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(true, EC_TABLE_NAME, new String[]{VILLAGE_NAME_COLUMN}, IS_OUT_OF_AREA_COLUMN + " = ? AND " + IS_CLOSED_COLUMN + " = ?", ne...
### Question: EligibleCoupleRepository extends DrishtiRepository { public List<EligibleCouple> findByCaseIDs(String... caseIds) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( String.format("SELECT * FROM %s WHERE %s IN (%s)", EC_TABLE_NAME, ID_COLUMN, insertPlaceh...
### Question: EligibleCoupleRepository extends DrishtiRepository { public void mergeDetails(String caseId, Map<String, String> details) { SQLiteDatabase database = masterRepository.getWritableDatabase(); EligibleCouple couple = findByCaseID(caseId); if (couple == null) { return; } Map<String, String> mergedDetails = ne...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { @Override public void addOrUpdate(ClientFormContract.Model clientForm) { ContentValues contentValues = new ContentValues(); contentValues.put(ID, clientForm.getId()); contentValues.put(VERSION, clientForm.getVersion()); conten...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { public ClientForm getActiveClientFormByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + getClientFormTableName() + " WHERE " + IDENTIFIER + " =? AND " + ACTIVE + " = 1", ne...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { @Override public List<ClientFormContract.Model> getClientFormByIdentifier(String identifier) { List<ClientFormContract.Model> clientForms = new ArrayList<>(); try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM ...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { @Override public ClientForm getLatestFormByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + getClientFormTableName() + " WHERE " + IDENTIFIER + " = ? ORDER BY " + CREATED_A...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { @Override public void setIsNew(boolean isNew, int formId) { ContentValues contentValues = new ContentValues(); contentValues.put(ID, formId); contentValues.put(IS_NEW, isNew); getWritableDatabase().update(getClientFormTableNam...
### Question: ClientFormRepository extends BaseRepository implements ClientFormContract.Dao { protected ClientForm readCursor(Cursor cursor) { ClientForm clientForm = new ClientForm(); clientForm.setId(cursor.getInt(cursor.getColumnIndex(ID))); clientForm.setVersion(cursor.getString(cursor.getColumnIndex(VERSION))); cl...
### Question: ReportRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(REPORT_SQL); database.execSQL(REPORT_INDICATOR_INDEX_SQL); } void update(Report report); List<Report> allFor(String... indicators); List<Report> all(); }### Answer: @Test public voi...
### Question: ReportRepository extends DrishtiRepository { public void update(Report report) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.replace(REPORT_TABLE_NAME, null, createValuesFor(report)); } void update(Report report); List<Report> allFor(String... indicators); List<Report> all(...
### Question: ReportRepository extends DrishtiRepository { public List<Report> allFor(String... indicators) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( String.format("SELECT * FROM %s WHERE %s IN (%s)", REPORT_TABLE_NAME, INDICATOR_COLUMN, insertPlaceholdersFor...
### Question: ReportRepository extends DrishtiRepository { public List<Report> all() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(REPORT_TABLE_NAME, REPORT_TABLE_COLUMNS, null, null, null, null, null); return readAll(cursor); } void update(Report report); List<Rep...
### Question: ImageRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(Image_SQL); database.execSQL(ENTITY_ID_INDEX); } void add(ProfileImage Image); List<ProfileImage> allProfileImages(); @Nullable HashMap<String, Object> getImage(long lastRowId); Profi...
### Question: ImageRepository extends DrishtiRepository { public void add(ProfileImage Image) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(Image_TABLE_NAME, null, createValuesFor(Image, TYPE_ANC)); } void add(ProfileImage Image); List<ProfileImage> allProfileImages(); @Nullable H...
### Question: ImageRepository extends DrishtiRepository { public List<ProfileImage> allProfileImages() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(Image_TABLE_NAME, Image_TABLE_COLUMNS, syncStatus_COLUMN + " = ?", new String[]{TYPE_Unsynced}, null, null, null, nul...
### Question: ImageRepository extends DrishtiRepository { public void close(String caseId) { ContentValues values = new ContentValues(); values.put(syncStatus_COLUMN, TYPE_Synced); masterRepository.getWritableDatabase() .update(Image_TABLE_NAME, values, ID_COLUMN + " = ?", new String[]{caseId}); } void add(ProfileImag...
### Question: ImageRepository extends DrishtiRepository { public List<ProfileImage> findAllUnSynced() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(Image_TABLE_NAME, Image_TABLE_COLUMNS, syncStatus_COLUMN + " = ?", new String[]{TYPE_Unsynced}, null, null, null, null...
### Question: ImageRepository extends DrishtiRepository { public ProfileImage findByEntityId(String entityId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(Image_TABLE_NAME, Image_TABLE_COLUMNS, entityID_COLUMN + " = ? COLLATE NOCASE ", new String[]{entityId}, null, ...
### Question: ImageRepository extends DrishtiRepository { @Nullable public HashMap<String, Object> getImage(long lastRowId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(Image_TABLE_NAME, new String[]{"rowid", filepath_COLUMN, syncStatus_COLUMN, entityID_COLUMN, anm...
### Question: EventRepository extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase database) { database.execSQL(common_SQL); } EventRepository(Context context, String[] columns); EventRepository(Context context, String tableName, String[] columns); @Override void onOpen(SQLiteDatabase db); @Overrid...
### Question: EventRepository extends SQLiteOpenHelper { public ContentValues createValuesFor(Event common) { ContentValues values = new ContentValues(); values.put(Relational_ID, common.getBaseEntityID()); values.put(obsDETAILS_COLUMN, new Gson().toJson(common.getObsDetailsMap())); values.put(attributeDETAILS_COLUMN, ...
### Question: ServiceProvidedRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(SERVICE_PROVIDED_SQL); } void add(ServiceProvided serviceProvided); List<ServiceProvided> findByEntityIdAndServiceNames(String entityId, String... names); List<ServiceProvid...
### Question: ServiceProvidedRepository extends DrishtiRepository { public void add(ServiceProvided serviceProvided) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(SERVICE_PROVIDED_TABLE_NAME, null, createValuesFor(serviceProvided)); } void add(ServiceProvided serviceProvided); Lis...
### Question: ServiceProvidedRepository extends DrishtiRepository { public List<ServiceProvided> findByEntityIdAndServiceNames(String entityId, String... names) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( format("SELECT * FROM %s WHERE %s = ? AND %s IN (%s) " +...
### Question: ServiceProvidedRepository extends DrishtiRepository { public List<ServiceProvided> all() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(SERVICE_PROVIDED_TABLE_NAME, SERVICE_PROVIDED_TABLE_COLUMNS, null, null, null, null, DATE_ID_COLUMN); return readAllS...
### Question: UniqueIdRepository extends BaseRepository { public int close(String openmrsId) { return reserveOrClose(openmrsId, STATUS_USED); } static void createTable(SQLiteDatabase database); void add(UniqueId uniqueId); void bulkInsertOpenmrsIds(List<String> ids); Long countUnUsedIds(); UniqueId getNextUniqueId(); ...
### Question: UniqueIdRepository extends BaseRepository { public void bulkInsertOpenmrsIds(List<String> ids) { if (ids == null || ids.isEmpty()){ return; } SQLiteDatabase database = getWritableDatabase(); try { String userName = CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM(); database.b...
### Question: UniqueIdRepository extends BaseRepository { public Long countUnUsedIds() { long count = 0; Cursor cursor = null; try { cursor = getWritableDatabase().rawQuery("SELECT COUNT (*) FROM " + UniqueIds_TABLE_NAME + " WHERE " + STATUS_COLUMN + "=?", new String[]{STATUS_NOT_USED}); if (null != cursor && cursor.ge...
### Question: UniqueIdRepository extends BaseRepository { public UniqueId getNextUniqueId() { UniqueId uniqueId = null; Cursor cursor = null; try { cursor = getReadableDatabase().query(UniqueIds_TABLE_NAME, UniqueIds_TABLE_COLUMNS, STATUS_COLUMN + " = ?", new String[]{STATUS_NOT_USED}, null, null, CREATED_AT_COLUMN + "...
### Question: UniqueIdRepository extends BaseRepository { private ContentValues createValuesFor(UniqueId uniqueId) { ContentValues values = new ContentValues(); values.put(ID_COLUMN, uniqueId.getId()); values.put(OPENMRS_ID_COLUMN, uniqueId.getOpenmrsId()); values.put(STATUS_COLUMN, uniqueId.getStatus()); values.put(US...
### Question: UniqueIdRepository extends BaseRepository { public int releaseReservedIds() { ContentValues values = new ContentValues(); values.put(STATUS_COLUMN, STATUS_NOT_USED); values.put(USED_BY_COLUMN, ""); values.put(UPDATED_AT_COLUMN, dateFormat.format(new Date())); return getWritableDatabase().update(UniqueIds_...
### Question: UniqueIdRepository extends BaseRepository { public int open(String openmrsId) { try { String openmrsId_ = !openmrsId.contains("-") ? formatId(openmrsId) : openmrsId; ContentValues values = new ContentValues(); values.put(STATUS_COLUMN, STATUS_NOT_USED); values.put(USED_BY_COLUMN, ""); values.put(UPDATED_A...
### Question: P2PSenderTransferDao extends BaseP2PTransferDao implements SenderTransferDao { @Nullable @Override public TreeSet<DataType> getDataTypes() { TreeSet<DataType> dataTypeTreeSet = new TreeSet<>(); if (locationFilterEnabled()) { for (String location : getP2POptions().getLocationsFilter()) { for (DataType data...
### Question: ClientRelationshipRepository extends BaseRepository { public static void createTable(SQLiteDatabase database) { database.execSQL(CREATE_TABLE); database.execSQL(CREATE_BASE_ENTITY_ID_INDEX); } static void createTable(SQLiteDatabase database); void saveRelationship(ClientRelationship... clientRelationship...
### Question: ClientRelationshipRepository extends BaseRepository { public List<Client> findClientByRelationship(String relationShip, String relationalId) { List<Client> clientList = new ArrayList<>(); String query = String.format("SELECT %s FROM %s JOIN %s ON %s=%s WHERE %s=? AND %s =?", client_column.json.name(), CLI...
### Question: PlanDefinitionRepository extends BaseRepository { public static void createTable(SQLiteDatabase database) { database.execSQL(CREATE_PLAN_DEFINITION_TABLE); } PlanDefinitionRepository(); static void createTable(SQLiteDatabase database); void addOrUpdate(PlanDefinition planDefinition); void deletePlans(@Non...
### Question: PlanDefinitionRepository extends BaseRepository { public void addOrUpdate(PlanDefinition planDefinition) { if (DRAFT.equalsIgnoreCase(planDefinition.getStatus().value())) return; try { getWritableDatabase().beginTransaction(); ContentValues contentValues = new ContentValues(); contentValues.put(ID, planDe...
### Question: PlanDefinitionRepository extends BaseRepository { public PlanDefinition findPlanDefinitionById(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT " + JSON + " FROM " + PLAN_DEFINITION_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveTo...
### Question: PlanDefinitionRepository extends BaseRepository { public Set<PlanDefinition> findAllPlanDefinitions() { Cursor cursor = null; Set<PlanDefinition> planDefinitions = new TreeSet<>(); try { String query = String.format("SELECT %s FROM %s WHERE %s =?", JSON, PLAN_DEFINITION_TABLE, STATUS); cursor = getReadabl...
### Question: PlanDefinitionRepository extends BaseRepository { public Set<String> findAllPlanDefinitionIds() { Cursor cursor = null; Set<String> ids = new HashSet<>(); try { String query = String.format("SELECT %s FROM %s WHERE %s =?", ID, PLAN_DEFINITION_TABLE, STATUS); cursor = getReadableDatabase().rawQuery(query, ...
### Question: UrlUtil { public static boolean isValidUrl(String s){ return new UrlValidator(new String[]{"http", "https"}).isValid(s); } static boolean isValidUrl(String s); }### Answer: @Test public void assertValidUrlPasses() { Assert.assertTrue(UrlUtil.isValidUrl("https: Assert.assertTrue(UrlUtil.isValidUrl("http:...
### Question: SettingsRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(SETTINGS_SQL); } static void onUpgrade(SQLiteDatabase database); void updateSetting(String key, String value); void updateSetting(Setting setting); void updateBLOB(String key, byte...
### Question: SettingsRepository extends DrishtiRepository { public static void onUpgrade(SQLiteDatabase database) { database.execSQL(ADD_SETTINGS_VERSION); database.execSQL(ADD_SETTINGS_TYPE); database.execSQL(ADD_SETTINGS_SYNC_STATUS); } static void onUpgrade(SQLiteDatabase database); void updateSetting(String key, ...
### Question: SettingsRepository extends DrishtiRepository { public String querySetting(String key, String defaultValue) { Cursor cursor = null; String value = defaultValue; try { SQLiteDatabase database = masterRepository.getReadableDatabase(); cursor = database.query(SETTINGS_TABLE_NAME, new String[]{SETTINGS_VALUE_C...
### Question: SettingsRepository extends DrishtiRepository { public byte[] queryBLOB(String key) { byte[] value = null; Cursor cursor = null; try { SQLiteDatabase database = masterRepository.getReadableDatabase(); cursor = database.query(SETTINGS_TABLE_NAME, new String[]{SETTINGS_VALUE_COLUMN}, SETTINGS_KEY_COLUMN + " ...
### Question: SettingsRepository extends DrishtiRepository { public void updateSetting(String key, String value) { ContentValues values = new ContentValues(); values.put(SETTINGS_KEY_COLUMN, key); values.put(SETTINGS_VALUE_COLUMN, value); replace(values); } static void onUpgrade(SQLiteDatabase database); void updateSe...
### Question: SettingsRepository extends DrishtiRepository { public List<Setting> querySettingsByType(String type) { Cursor cursor = null; List<Setting> values = new ArrayList<>(); try { SQLiteDatabase database = masterRepository.getReadableDatabase(); cursor = database.query(SETTINGS_TABLE_NAME, SETTINGS_PROJECTION , ...
### Question: SettingsRepository extends DrishtiRepository { public List<Setting> queryUnsyncedSettings() { Cursor cursor = null; List<Setting> values = new ArrayList<>(); try { SQLiteDatabase database = masterRepository.getReadableDatabase(); cursor = database.query(SETTINGS_TABLE_NAME, SETTINGS_PROJECTION, SETTINGS_S...
### Question: SettingsRepository extends DrishtiRepository { protected Setting queryCore(Cursor cursor) { Setting value = new Setting(); value.setKey(cursor.getString(cursor.getColumnIndex(SETTINGS_KEY_COLUMN))); value.setValue(cursor.getString(cursor.getColumnIndex(SETTINGS_VALUE_COLUMN))); value.setType(cursor.getStr...
### Question: ChildRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(CHILD_SQL); } void add(Child child); void update(Child child); List<Child> all(); Child find(String caseId); List<Child> findChildrenByCaseIds(String... caseIds); void updateDetails(S...
### Question: ChildRepository extends DrishtiRepository { public void add(Child child) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(CHILD_TABLE_NAME, null, createValuesFor(child)); } void add(Child child); void update(Child child); List<Child> all(); Child find(String caseId); Li...
### Question: ChildRepository extends DrishtiRepository { public void update(Child child) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.update(CHILD_TABLE_NAME, createValuesFor(child), ID_COLUMN + " = ?", new String[]{child.caseId()}); } void add(Child child); void update(Child child); L...
### Question: ChildRepository extends DrishtiRepository { public List<Child> all() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(CHILD_TABLE_NAME, CHILD_TABLE_COLUMNS, IS_CLOSED_COLUMN + " = ?", new String[]{NOT_CLOSED}, null, null, null, null); return readAll(curso...
### Question: ChildRepository extends DrishtiRepository { public Child find(String caseId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(CHILD_TABLE_NAME, CHILD_TABLE_COLUMNS, ID_COLUMN + " = ?", new String[]{caseId}, null, null, null, null); List<Child> children = r...
### Question: ChildRepository extends DrishtiRepository { public List<Child> findByMotherCaseId(String caseId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database .query(CHILD_TABLE_NAME, CHILD_TABLE_COLUMNS, MOTHER_ID_COLUMN + " = ?", new String[]{caseId}, null, null, null, nul...
### Question: ChildRepository extends DrishtiRepository { public List<Child> findChildrenByCaseIds(String... caseIds) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( String.format("SELECT * FROM %s WHERE %s IN (%s)", CHILD_TABLE_NAME, ID_COLUMN, insertPlaceholdersF...
### Question: ChildRepository extends DrishtiRepository { public List<Child> allChildrenWithMotherAndEC() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( "SELECT " + tableColumnsForQuery(CHILD_TABLE_NAME, CHILD_TABLE_COLUMNS) + ", " + tableColumnsForQuery(MOTHER_TA...
### Question: ChildRepository extends DrishtiRepository { public List<Child> findAllChildrenByECId(String ecId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery( "SELECT " + tableColumnsForQuery(CHILD_TABLE_NAME, CHILD_TABLE_COLUMNS) + " FROM " + CHILD_TABLE_NAME + "...
### Question: ChildRepository extends DrishtiRepository { public void delete(String childId) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.delete(CHILD_TABLE_NAME, ID_COLUMN + "= ?", new String[]{childId}); } void add(Child child); void update(Child child); List<Child> all(); Child find(...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findClientById(String id) { Client client = fetchClientByBaseEntityId(id); return Collections.singletonList(ClientConverter.convertClientToPatientResource(client)); } @Override List<Patient> findClientById(S...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findFamilyByJurisdiction(String jurisdiction) { return fetchClients(String.format("select %s from %s where %s =? and %s =?", client_column.json, clientTable.name(), client_column.locationId, client_column.cli...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findFamilyByResidence(String structureId) { return fetchClients(String.format("select %s from %s where %s =? and %s =?", client_column.json, clientTable.name(), client_column.residence, client_column.clientTy...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findFamilyMemberyByJurisdiction(String jurisdiction) { return fetchClients(String.format("select %s from %s where %s =? and (%s is null or %s !=? )", client_column.json, clientTable.name(), client_column.loca...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findFamilyMemberByResidence(String structureId) { return fetchClients(String.format("select %s from %s where %s =? and (%s is null or %s !=? )", client_column.json, clientTable.name(), client_column.residence...
### Question: ClientDaoImpl extends EventClientRepository implements ClientDao { @Override public List<Patient> findClientByRelationship(String relationship, String id) { return CoreLibrary.getInstance().context().getClientRelationshipRepository().findClientByRelationship(relationship, id) .stream() .map(ClientConverte...
### Question: EventDaoImpl extends EventClientRepository implements EventDao { @Override public List<QuestionnaireResponse> findEventsByEntityIdAndPlan(String resourceId, String planIdentifier) { return fetchEvents(String.format("select %s from %s where %s =? and (%s is null or %s =? )", event_column.json, eventTable.n...
### Question: TaskDaoImpl extends TaskRepository implements TaskDao { @Override public List<Task> findTasksForEntity(String id, String planIdentifier) { return getTasksByPlanAndEntity(planIdentifier, id) .stream() .map(TaskConverter::convertTasktoFihrResource) .collect(Collectors.toList()); } TaskDaoImpl(TaskNotesRepos...
### Question: FormDataRepository extends DrishtiRepository { @JavascriptInterface public String queryUniqueResult(String sql, String[] selectionArgs) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery(sql, selectionArgs); cursor.moveToFirst(); Map<String, String> resul...
### Question: FormDataRepository extends DrishtiRepository { @JavascriptInterface public String queryList(String sql, String[] selectionArgs) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.rawQuery(sql, selectionArgs); List<Map<String, String>> results = new ArrayList<Map<S...
### Question: FormDataRepository extends DrishtiRepository { @JavascriptInterface public String saveFormSubmission(String paramsJSON, String data, String formDataDefinitionVersion) { SQLiteDatabase database = masterRepository.getWritableDatabase(); Map<String, String> params = new Gson() .fromJson(paramsJSON, new TypeT...
### Question: FormDataRepository extends DrishtiRepository { public FormSubmission fetchFromSubmission(String instanceId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_SUBMISSION_TABLE_NAME, FORM_SUBMISSION_TABLE_COLUMNS, INSTANCE_ID_COLUMN + " = ?", new String[...
### Question: FormDataRepository extends DrishtiRepository { public List<FormSubmission> getPendingFormSubmissions() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_SUBMISSION_TABLE_NAME, FORM_SUBMISSION_TABLE_COLUMNS, SYNC_STATUS_COLUMN + " = ?", new String[]{PEN...
### Question: FormDataRepository extends DrishtiRepository { public void markFormSubmissionsAsSynced(List<FormSubmission> formSubmissions) { SQLiteDatabase database = masterRepository.getWritableDatabase(); for (FormSubmission submission : formSubmissions) { FormSubmission updatedSubmission = new FormSubmission(submiss...
### Question: FormDataRepository extends DrishtiRepository { public boolean submissionExists(String instanceId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_SUBMISSION_TABLE_NAME, new String[]{INSTANCE_ID_COLUMN}, INSTANCE_ID_COLUMN + " = ?", new String[]{insta...
### Question: FormDataRepository extends DrishtiRepository { @JavascriptInterface public String saveEntity(String entityType, String fields) { SQLiteDatabase database = masterRepository.getWritableDatabase(); Map<String, String> updatedFieldsMap = new Gson() .fromJson(fields, new TypeToken<Map<String, String>>() { }.ge...
### Question: FormDataRepository extends DrishtiRepository { public Map<String, String> getMapFromSQLQuery(String sql, String[] selectionArgs) { Map<String, String> map = new HashMap<String, String>(); Cursor cursor = null; try { SQLiteDatabase database = masterRepository.getReadableDatabase(); cursor = database.rawQue...
### Question: FormDataRepository extends DrishtiRepository { public void updateServerVersion(String instanceId, String serverVersion) { SQLiteDatabase database = masterRepository.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(SERVER_VERSION_COLUMN, serverVersion); database.update(FORM_SUB...
### Question: FormDataRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(FORM_SUBMISSION_SQL); } FormDataRepository(); void addTableColumnMap(String key, String[] val); @JavascriptInterface String queryUniqueResult(String sql, String[] selectionArgs); @J...
### Question: FormDataRepository extends DrishtiRepository { public Map<String, String> sqliteRowToMap(Cursor cursor) { int totalColumn = cursor.getColumnCount(); Map<String, String> rowObject = new HashMap<String, String>(); if (cursor != null && cursor.moveToFirst()) { for (int i = 0; i < totalColumn; i++) { if (curs...
### Question: P2PReceiverTransferDao extends BaseP2PTransferDao implements ReceiverTransferDao { @Override public long receiveMultimedia(@NonNull DataType dataType, @NonNull File file, @Nullable HashMap<String, Object> multimediaDetails, long fileRecordId) { if (multimediaDetails != null && file.exists()) { final Strin...
### Question: P2PReceiverTransferDao extends BaseP2PTransferDao implements ReceiverTransferDao { @Override public TreeSet<DataType> getDataTypes() { return (TreeSet<DataType>) dataTypes.clone(); } @Override TreeSet<DataType> getDataTypes(); @VisibleForTesting P2PClassifier<JSONObject> getP2PClassifier(); @Override lon...
### Question: P2PReceiverTransferDao extends BaseP2PTransferDao implements ReceiverTransferDao { @VisibleForTesting public P2PClassifier<JSONObject> getP2PClassifier() { return DrishtiApplication.getInstance().getP2PClassifier(); } @Override TreeSet<DataType> getDataTypes(); @VisibleForTesting P2PClassifier<JSONObject...
### Question: AllEligibleCouples { public void close(String entityId) { alertRepository.deleteAllAlertsForEntity(entityId); timelineEventRepository.deleteAllTimelineEventsForEntity(entityId); eligibleCoupleRepository.close(entityId); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepositor...
### Question: AllEligibleCouples { public EligibleCouple findByCaseID(String caseId) { return eligibleCoupleRepository.findByCaseID(caseId); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); List<Eligibl...
### Question: AllEligibleCouples { public List<EligibleCouple> findByCaseIDs(List<String> caseIds) { return eligibleCoupleRepository.findByCaseIDs(caseIds.toArray(new String[caseIds.size()])); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEv...
### Question: AllEligibleCouples { public void updatePhotoPath(String caseId, String imagePath) { eligibleCoupleRepository.updatePhotoPath(caseId, imagePath); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventReposit...
### Question: AllEligibleCouples { public void mergeDetails(String entityId, Map<String, String> details) { eligibleCoupleRepository.mergeDetails(entityId, details); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEvent...
### Question: AllEligibleCouples { public long count() { return eligibleCoupleRepository.count(); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); List<EligibleCouple> all(); EligibleCouple findByCaseID...
### Question: AllEligibleCouples { public long fpCount() { return eligibleCoupleRepository.fpCount(); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); List<EligibleCouple> all(); EligibleCouple findByCa...
### Question: AllEligibleCouples { public List<String> villages() { return eligibleCoupleRepository.villages(); } AllEligibleCouples(EligibleCoupleRepository eligibleCoupleRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); List<EligibleCouple> all(); EligibleCoupl...