コード例 #1
0
  public static void updateRowFromTable2(Context context, ObservationInstance sp) {
    Dao<ObservationInstance, Integer> dao;
    try {
      dao = DatabaseHelper.getInstance(context).getSaveParamsDao();
      UpdateBuilder<ObservationInstance, Integer> query = dao.updateBuilder();
      // query.updateColumnValue("group_id", sp.getGroupId());
      query.updateColumnValue("group", sp.getGroup());
      query.updateColumnValue("habitat_id", sp.getHabitatId());
      query.updateColumnValue("fromDate", sp.getFromDate());
      query.updateColumnValue("placeName", sp.getPlaceName());
      query.updateColumnValue("areas", sp.getAreas());
      query.updateColumnValue("maxVotedReco", sp.getMaxVotedReco());
      // query.updateColumnValue("recoName", sp.getRecoName());

      query.updateColumnValue("resource", sp.getResource());
      // query.updateColumnValue("image_type", sp.getImageType());
      query.updateColumnValue("status", sp.getStatus());
      query.updateColumnValue("message", sp.getMessage());
      query.updateColumnValue("notes", sp.getNotes());
      query.updateColumnValue("userGroupsList", sp.getUserGroupsList());
      if (sp.getId() == -1)
        query.where().eq("server_id", sp.getServer_id()).and().eq("id", sp.getId());
      else query.where().eq("id", sp.getId());
      int count = query.update();
      Log.d("ObservationParamTable", "Updated " + count + " orders");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  public static boolean isRecordAvailable(Context context, ObservationInstance sp) {
    List<ObservationInstance> record = null;
    try {
      QueryBuilder<ObservationInstance, Integer> query =
          DatabaseHelper.getInstance(context).getSaveParamsDao().queryBuilder();
      if (sp.getId() == -1)
        query.where().eq("server_id", sp.getServer_id()).and().eq("id", sp.getId()); // Obv id
      else query.where().eq("id", sp.getId()); // Obv id
      record = DatabaseHelper.getInstance(context).getSaveParamsDao().query(query.prepare());
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return record.size() > 0;
  }