@Test public void testGetTeamAtEventAwards() { mTable.add(ImmutableList.copyOf(mAwards), null); List<Award> awards = mTable.getTeamAtEventAwards("125", "2015necmp"); assertNotNull(awards); assertEquals(2, awards.size()); awards = mTable.getTeamAtEventAwards("254", "2015necmp"); assertNotNull(awards); assertEquals(0, awards.size()); }
public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) { Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[]{eventKey}); List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount()); if (cursor == null || !cursor.moveToFirst()) { return models; } do { models.add(inflate(cursor)); } while (cursor.moveToNext()); return models; }
AwardsTable extends ModelTable<Award> { public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) { Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[]{eventKey}); List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount()); if (cursor == null || !cursor.moveToFirst()) { return models; } do { models.add(inflate(cursor)); } while (cursor.moveToNext()); return models; } }
AwardsTable extends ModelTable<Award> { public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) { Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[]{eventKey}); List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount()); if (cursor == null || !cursor.moveToFirst()) { return models; } do { models.add(inflate(cursor)); } while (cursor.moveToNext()); return models; } AwardsTable(SQLiteDatabase db, Gson gson); }
AwardsTable extends ModelTable<Award> { public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) { Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[]{eventKey}); List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount()); if (cursor == null || !cursor.moveToFirst()) { return models; } do { models.add(inflate(cursor)); } while (cursor.moveToNext()); return models; } AwardsTable(SQLiteDatabase db, Gson gson); @Override String getTableName(); @Override String getKeyColumn(); @Override String getLastModifiedColumn(); @Override Award inflate(Cursor cursor); List<Award> getTeamAtEventAwards(String teamNumber, String eventKey); }
AwardsTable extends ModelTable<Award> { public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) { Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[]{eventKey}); List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount()); if (cursor == null || !cursor.moveToFirst()) { return models; } do { models.add(inflate(cursor)); } while (cursor.moveToNext()); return models; } AwardsTable(SQLiteDatabase db, Gson gson); @Override String getTableName(); @Override String getKeyColumn(); @Override String getLastModifiedColumn(); @Override Award inflate(Cursor cursor); List<Award> getTeamAtEventAwards(String teamNumber, String eventKey); static final String KEY; }