public List<ExpansionInfo> getSetsWithBasicLandsByReleaseDate() { List<ExpansionInfo> sets = new LinkedList<ExpansionInfo>(); try { QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder(); qb.orderBy("releaseDate", false); qb.where().eq("basicLands", new SelectArg(true)); sets = expansionDao.query(qb.prepare()); } catch (SQLException ex) { } return sets; }
public ExpansionInfo[] getWithBoostersSortedByReleaseDate() { ExpansionInfo[] sets = new ExpansionInfo[0]; try { QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder(); qb.orderBy("releaseDate", false); qb.where().eq("boosters", new SelectArg(true)); List<ExpansionInfo> expansions = expansionDao.query(qb.prepare()); sets = expansions.toArray(new ExpansionInfo[0]); } catch (SQLException ex) { } return sets; }
@NonNull public static List getAll(long inquirerId) { try { Dao<Question, Integer> qDao = DbHelper.getDbHelper().getQuestionDao(); final QueryBuilder qb = qDao.queryBuilder(); qb.where().eq(INQUIRER_ID, inquirerId); qb.orderBy(ORDER_NUMBER, true); return qDao.query(qb.prepare()); } catch (SQLException e) { e.printStackTrace(); } return new ArrayList<>(); }
public List<SliderTipSeg> getSliderTipSegById(int idTipSeg) { try { Dao<SliderTipSeg, Integer> dao = getHelper().getSliderTipSegDao(); QueryBuilder<SliderTipSeg, Integer> builder = dao.queryBuilder(); builder.setWhere(builder.where().eq("id_tipseg", idTipSeg)); builder.orderBy("order", true); List<SliderTipSeg> items = dao.query(builder.prepare()); return items; } catch (SQLException e) { e.printStackTrace(); } return null; }
public List<Promotion> getPromotionTicker() { List<Promotion> result = new ArrayList<>(); try { Dao<Promotion, String> dao = this.getController(); QueryBuilder<Promotion, String> builder = dao.queryBuilder(); builder.limit(10); builder.orderBy("createDate", false); result = dao.query(builder.prepare()); // returns list of ten items } catch (SQLException e) { e.printStackTrace(); } return result; }
@Override public CalendarModel obtainTournaments() { CalendarModel model = new CalendarModel(); List<TournamentModel> tournaments = new ArrayList<>(); try { QueryBuilder<TournamentModel, String> builder = daoTournaments.queryBuilder(); builder.orderBy("DATE", false); // true for ascending, false for descending builder.where().ge("DATE", new Date(System.currentTimeMillis())); tournaments = daoTournaments.query(builder.prepare()); } catch (SQLException e) { Log.e(LOGTAG, "Error while obtaining messages from BBDD", e); } model.setTournaments(tournaments); return model; }
/** Returns highest score row from DB. */ public void getHighestScore() { try { Dao<UserScoreData, Integer> usersScoreData = getHelper().getUserScoreData(); QueryBuilder<UserScoreData, Integer> builder = usersScoreData.queryBuilder(); builder.orderBy("score", false); UserScoreData result = usersScoreData.queryForFirst(builder.prepare()); mPresenterNotifier.PostNotification(IPresenterNotifier.NOTIFICATION_HIGHEST_SCORE, result); } catch (SQLException e) { e.printStackTrace(); } if (databaseHelper != null) { OpenHelperManager.releaseHelper(); databaseHelper = null; } }
public static ArrayList<Colleage> queryAll(String userId) { try { QueryBuilder<Colleage, String> queryBuilder = getDao().queryBuilder(); Where<Colleage, String> where = queryBuilder.where(); where.eq(Colleage.USER_ID, userId); queryBuilder.orderBy(Colleage.CREATETIME, false); List<Colleage> resultList = getDao().query(queryBuilder.prepare()); if (TextUtil.isValidate(resultList)) { return (ArrayList<Colleage>) resultList; } } catch (SQLException e) { e.printStackTrace(); } catch (DBNotInitializeException e) { e.printStackTrace(); } return null; }
public static List<TodoItem> getSortedItems() { List<TodoItem> items = new ArrayList<>(); final Dao<TodoItem, Integer> todoDao; try { todoDao = TodoApp.get().getDbHelper().getTodoDao(); QueryBuilder<TodoItem, Integer> todoQb = todoDao.queryBuilder(); PreparedQuery<TodoItem> preparedQuery = todoQb.orderBy(TodoEntry.COLUMN_URGENT, false).prepare(); items = todoDao.query(preparedQuery); } catch (SQLException e) { e.printStackTrace(); } return items; }
private void showFromDb() { Dao<News, String> NewsDao = null; List<News> NewsItems = null; try { NewsDao = getDatabaseHelper().getNewsDao(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { QueryBuilder<News, String> queryBuilder = NewsDao.queryBuilder(); queryBuilder.where().eq("mActive", 1); queryBuilder.orderBy("mId", false); NewsItems = NewsDao.query(queryBuilder.prepare()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } mNewsItems = (ArrayList<News>) NewsItems; mLvNews = new ListView(NewsActivity.this); setContentView(mLvNews); NewsAdapter newsAdapter = new NewsAdapter(this, mNewsItems); mLvNews.setAdapter(newsAdapter); mLvNews.setTextFilterEnabled(true); mLvNews.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { News selectedNews = mNewsItems.get(position); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(selectedNews.getURL())); startActivity(intent); } }); }
/** * Returns all the data from Table in sorted order by score. * * @param isWriting isQuery purpose to write/update data * @return all data list in table */ public List<UserScoreData> getAllUsersData(boolean isWriting) { List<UserScoreData> resultList = null; try { Dao<UserScoreData, Integer> usersScoreData = getHelper().getUserScoreData(); QueryBuilder<UserScoreData, Integer> builder = usersScoreData.queryBuilder(); builder.orderBy("score", false); resultList = usersScoreData.query(builder.prepare()); if (!isWriting && (resultList.size() > 0)) { AllUsersRecord usersList = new AllUsersRecord(); usersList.setUserScoreDataList(resultList); mPresenterNotifier.PostNotification(IPresenterNotifier.NOTIFICATION_ALL_RECORDS, usersList); } } catch (SQLException e) { e.printStackTrace(); } if (databaseHelper != null) { OpenHelperManager.releaseHelper(); databaseHelper = null; } return resultList; }
public List<Company> getCompanies() throws Exception { QueryBuilder<Company, String> builder = dao.queryBuilder(); return builder.orderBy("createdAt", false).query(); }