コード例 #1
0
 public Interest get() {
   Interest result = new Interest();
   try {
     Dao<Interest, String> dao = this.getController();
     QueryBuilder<Interest, String> queryBuilder = dao.queryBuilder();
     PreparedQuery<Interest> pq = queryBuilder.prepare();
     result = dao.queryForFirst(pq);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return result;
 }
コード例 #2
0
 public RedmineRole fetchById(int connection, int statusId) throws SQLException {
   PreparedQuery<RedmineRole> query =
       dao.queryBuilder()
           .where()
           .eq(RedmineRole.CONNECTION, connection)
           .and()
           .eq(RedmineRole.ROLE_ID, statusId)
           .prepare();
   Log.d(TAG, query.getStatement());
   RedmineRole item = dao.queryForFirst(query);
   if (item == null) item = new RedmineRole();
   return item;
 }
コード例 #3
0
 public RedmineAttachment fetchById(int connection, int journalId) throws SQLException {
   PreparedQuery<RedmineAttachment> query =
       dao.queryBuilder()
           .where()
           .eq(RedmineAttachment.CONNECTION, connection)
           .and()
           .eq(RedmineAttachment.ATTACHMENT_ID, journalId)
           .prepare();
   Log.d(TAG, query.getStatement());
   RedmineAttachment item = dao.queryForFirst(query);
   if (item == null) item = new RedmineAttachment();
   return item;
 }
コード例 #4
0
 public Promotion get(int id) {
   Promotion result = new Promotion();
   try {
     Dao<Promotion, String> dao = this.getController();
     QueryBuilder<Promotion, String> ordersQB = dao.queryBuilder();
     ordersQB.where().eq("id", id);
     PreparedQuery<Promotion> pq = ordersQB.prepare();
     result = dao.queryForFirst(pq);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return result;
 }
コード例 #5
0
 public RedmineWiki fetchById(int connection, long project_id, String title) throws SQLException {
   PreparedQuery<RedmineWiki> query =
       dao.queryBuilder()
           .where()
           .eq(RedmineWiki.CONNECTION, connection)
           .and()
           .eq(RedmineWiki.PROJECT_ID, project_id)
           .and()
           .eq(RedmineWiki.TITLE, title)
           .prepare();
   Log.d(TAG, query.getStatement());
   RedmineWiki item = dao.queryForFirst(query);
   if (item == null) item = new RedmineWiki();
   return item;
 }
コード例 #6
0
  /** 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;
    }
  }
コード例 #7
0
  /**
   * Add data into new row of DB. If data already exist it checks whether it needs to overwrite or
   * not.
   *
   * @param name user name
   * @param score user score
   * @param overwrite overwrite data or not if duplicate exist.
   */
  private void writeIntoDB(String name, int score, boolean overwrite) {
    UserScoreData userScore = new UserScoreData(name, score);
    try {
      final Dao<UserScoreData, Integer> userScoreData = getHelper().getUserScoreData();
      if (overwrite) {
        QueryBuilder<UserScoreData, Integer> query = userScoreData.queryBuilder();
        query.where().eq("name", name);
        UserScoreData sub = userScoreData.queryForFirst(query.prepare());
        userScoreData.delete(sub);
        userScoreData.create(userScore);
      } else {
        userScoreData.create(userScore);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    mPresenterNotifier.PostNotification(IPresenterNotifier.NOTIFICATION_SAVE_RECORD, userScore);
  }
コード例 #8
0
ファイル: SyncHelper.java プロジェクト: YanHsia/DataSync
 public static <E extends SyncEntity> E findBySyncId(Dao<E, ?> dao, String syncId)
     throws SQLException {
   return dao.queryForFirst(dao.queryBuilder().where().eq(DB_OBJECT_ID_FIELD, syncId).prepare());
 }