예제 #1
0
  @Override
  public StatusBean delete(String projectID) {
    StatusBean statusBean = new StatusBean();
    try {
      projectDao
          .updateBuilder()
          .updateColumnValue("isDisabled", true)
          .where()
          .idEq(Integer.parseInt(projectID));
      List<MachineConfigurationBean> machineConfigList =
          MachineConfigDAOManager.getInstance().retireveBoxesForProject(projectID);

      for (MachineConfigurationBean machineConfig : machineConfigList) {
        MachineConfigDAOManager.getInstance().delete(machineConfig.getMachineID().toString());
      }

    } catch (SQLException e) {
      logger.error("Error deleting a project : " + e.getMessage());
      statusBean.setStatusCode(1);
      statusBean.setStatusMessage("Error deleting  a project : " + e.getMessage());
      e.printStackTrace();
    }
    statusBean.setStatusCode(0);
    statusBean.setStatusMessage("Project deleted successfully");
    return statusBean;
  }
  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();
    }
  }
  private void updateCatagory() {

    final Dao<CatagoryModel, Integer> catagoryDoa;

    try {
      catagoryDoa = getHelper().getCatagoryDao();

      UpdateBuilder<CatagoryModel, Integer> updateBuilder = catagoryDoa.updateBuilder();
      updateBuilder.updateColumnValue("catagoryName", catagoryEditText.getText().toString());

      updateBuilder
          .where()
          .eq("categoryId", Integer.valueOf(catagoryModel.getCategoryId()))
          .and()
          .eq("catagoryName", catagoryModel.getCatagoryName());
      ;
      updateBuilder.update();

      Snackbar snackbar =
          Snackbar.make(view, "Catagory updated sucessfully!!", Snackbar.LENGTH_LONG);

      snackbar.show();

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }