private void addSync() {
    QueryBuilder<Donor, Integer> queryBuilder = databaseHelper.getDonorListDao().queryBuilder();
    // get the WHERE object to build our query
    Where<Donor, Integer> where = queryBuilder.where();
    try {
      where.eq("status", new Integer(DhenupaApplication.STATUS_DONOR_ADDED));
      // and
      where.or();

      where.eq("status", new Integer(DhenupaApplication.STATUS_DONOR_UPDATED));

      PreparedQuery<Donor> preparedQuery = queryBuilder.prepare();
      List<Donor> donorList = databaseHelper.getDonorListDao().query(preparedQuery);
      for (Donor donor : donorList) {
        new DonorManager(this).addNewDonor(donor);
        // Sleep is added to maintain a different Timestamp between multiple entries
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
  public void update(final Dataset dataset, final Field field, final String data) {
    try {
      UpdateBuilder<Data, Integer> updateBuilder = getDataDao().updateBuilder();
      Where<Data, Integer> where = updateBuilder.where();
      where.eq("dataset_id", dataset);
      where.and();
      where.eq("field_id", field);

      updateBuilder.updateColumnValue("data" /* column */, data /* value */);
      updateBuilder.update();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
 public List<Data> getAllData(final int datasetId, final int fieldId) {
   try {
     QueryBuilder<Data, Integer> queryBuilder = getDataDao().queryBuilder();
     Where<Data, Integer> where = queryBuilder.where();
     where.eq("dataset_id", datasetId);
     where.and();
     where.eq("field_id", fieldId);
     PreparedQuery<Data> preparedQuery = queryBuilder.prepare();
     return getDataDao().query(preparedQuery);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return null;
 }
 public Data getData(final Dataset dataset, final Field field) {
   try {
     QueryBuilder<Data, Integer> queryBuilder = getDataDao().queryBuilder();
     Where<Data, Integer> where = queryBuilder.where();
     where.eq("dataset_id", dataset);
     where.and();
     where.eq("field_id", field);
     PreparedQuery<Data> preparedQuery = queryBuilder.prepare();
     return getDataDao().queryForFirst(preparedQuery);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return null;
 }
  public void delete(final Dataset dataset, final Field field, final String data) {
    try {
      DeleteBuilder<Data, Integer> deleteBuilder = getDataDao().deleteBuilder();
      Where<Data, Integer> where = deleteBuilder.where();
      where.eq("dataset_id", dataset);
      where.and();
      where.eq("field_id", field);
      where.and();
      where.eq("data", data);
      deleteBuilder.delete();

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
 @SuppressWarnings("unchecked")
 public int deleteMarkStarredAndUnStarred(Article article) {
   try {
     DeleteBuilder<ArticleSyncAction, Integer> deleteBuilder = deleteBuilder();
     Where<ArticleSyncAction, Integer> where = deleteBuilder.where();
     where.and(
         where.eq(COLUMN_ARTICLEID, article.getId()),
         where
             .eq(COLUMN_ACTION, ArticleSyncAction.Action.MarkStarred)
             .or()
             .eq(COLUMN_ACTION, ArticleSyncAction.Action.MarkUnstarred));
     return deleteBuilder.delete();
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
 }
 private List<KnouNoticeInfo> getListKnouNoticeInfo(String blngDc, String blngCd, String anncNo) {
   List<KnouNoticeInfo> knouNoticeInfoList = null;
   try {
     Dao<KnouNoticeInfo, Long> knouNoticeInfoDao = this.getHelper().getKnouNoticeInfoDao();
     QueryBuilder<KnouNoticeInfo, Long> qb = knouNoticeInfoDao.queryBuilder();
     Where where = qb.where();
     where.eq(KNOU_NOTICE.blngDc, blngDc);
     where.and();
     where.eq(KNOU_NOTICE.blngCd, blngCd);
     where.and();
     where.eq(KNOU_NOTICE.anncNo, anncNo);
     System.out.println("sql:" + qb.prepareStatementString());
     knouNoticeInfoList = qb.query();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return knouNoticeInfoList;
 }
 public void deleteByDataset(final int dataset) {
   try {
     DeleteBuilder<Data, Integer> deleteBuilder = getDataDao().deleteBuilder();
     Where<Data, Integer> where = deleteBuilder.where();
     where.eq("dataset_id", dataset);
     deleteBuilder.delete();
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 9
0
 @Test
 public void testWhere() throws Exception {
   QueryBuilder<Foo, Integer> qb =
       new QueryBuilder<Foo, Integer>(databaseType, baseFooTableInfo, null);
   Where<Foo, Integer> where = qb.where();
   String val = "1";
   where.eq(Foo.ID_COLUMN_NAME, val);
   StringBuilder sb = new StringBuilder();
   sb.append("SELECT * FROM ");
   databaseType.appendEscapedEntityName(sb, baseFooTableInfo.getTableName());
   sb.append(" WHERE ");
   databaseType.appendEscapedEntityName(sb, Foo.ID_COLUMN_NAME);
   sb.append(" = ").append(val).append(' ');
   assertEquals(sb.toString(), qb.prepareStatementString());
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
  @Override
  public List<Photocategory> getCategories(String id) {
    if (noUid()) {
      return null;
    }

    Where<Photocategory, String> where = this.category.queryBuilder().where();
    List<Photocategory> datas = null;
    try {

      datas = where.eq("_Users_uid", this.uid).and().eq("parentid", id).query(); // 找子类

      return datas;
    } catch (SQLException e) {
      log.setExcetion(id, e);
      return null;
    }
  }
Exemplo n.º 12
0
 /**
  * 查询标题和描述一致的专辑
  *
  * @param pDiggerAlbum 专辑对象
  * @return
  */
 public ArrayList<DiggerAlbum> existedDiggerAlbum(DiggerAlbum pDiggerAlbum) {
   List<DiggerAlbum> list = new ArrayList<>();
   QueryBuilder<DiggerAlbum, String> builder = mDiggerAlbumDao.queryBuilder();
   Where<DiggerAlbum, String> where = builder.where();
   try {
     where
         .eq(COLUMN_ALBUM_TITLE, pDiggerAlbum.getAlbum_title())
         .and()
         .eq(COLUMN_ALBUM_DES, pDiggerAlbum.getAlbum_des());
     list = builder.query();
     if (TextUtil.isListEmpty(list)) {
       return new ArrayList<>();
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return new ArrayList<>(list);
 }