Example #1
0
  /**
   * Encargado de mostrar en un formulario la informacion de un riego de la identificacion
   *
   * @param idIrr: Identificacion del riego
   * @return Informacion del riego
   */
  public String show() {
    if (!usrDao.getPrivilegeUser(idUsrSystem, "crop/create")
        || !usrDao.getPrivilegeUser(idUsrSystem, "crop/modify")) {
      return BaseAction.NOT_AUTHORIZED;
    }
    actExe = (String) (this.getRequest().getParameter("action"));
    try {
      this.setIdCrop(Integer.parseInt(this.getRequest().getParameter("idCrop")));
    } catch (NumberFormatException e) {
      //            LOG.error("There was an error trying to parse the activityId parameter");
      this.setIdCrop(-1);
    }

    HashMap prod = cropDao.findById(idCrop);
    Integer tyCro = Integer.parseInt(String.valueOf(prod.get("typeCrop")));
    //        System.out.println("tyCro=>"+tyCro);

    try {
      this.setIdIrr(Integer.parseInt(this.getRequest().getParameter("idIrr")));
    } catch (NumberFormatException e) {
      //            LOG.error("There was an error trying to parse the activityId parameter");
      this.setIdIrr(-1);
    }

    this.setType_irr_typ(new IrrigationsTypesDao().findAllByTypeCrop(tyCro));
    if (this.getIdIrr() != -1) {
      irr = irrDao.objectById(this.getIdIrr());
    }
    return SUCCESS;
  }
Example #2
0
  /**
   * Encargado de borrar la informacion de un riego apartir de su identificacion
   *
   * @param idIrr: Identificacion del riego
   * @return Estado del proceso
   */
  public String delete() {
    if (!usrDao.getPrivilegeUser(idUsrSystem, "crop/delete")) {
      return BaseAction.NOT_AUTHORIZED;
    }
    Integer idIrr = 0;
    try {
      idIrr = Integer.parseInt(this.getRequest().getParameter("idIrr"));
    } catch (NumberFormatException e) {
      idIrr = -1;
    }

    if (idIrr == -1) {
      state = "failure";
      info = "Fallo al momento de obtener la informacion a borrar";
      return "states";
    }

    SessionFactory sessions = HibernateUtil.getSessionFactory();
    Session session = sessions.openSession();
    Transaction tx = null;

    try {
      tx = session.beginTransaction();
      Irrigation pr = irrDao.objectById(idIrr);
      pr.setStatus(false);
      //            session.delete(pro);
      session.saveOrUpdate(pr);

      LogEntities log = new LogEntities();
      log.setIdLogEnt(null);
      log.setIdEntityLogEnt(idEntSystem);
      log.setIdObjectLogEnt(pr.getIdIrr());
      log.setTableLogEnt("irrigation");
      log.setDateLogEnt(new Date());
      log.setActionTypeLogEnt("D");
      session.saveOrUpdate(log);
      //            logDao.save(log);
      tx.commit();
      state = "success";
      info = "El riego ha sido borrado con exito";
    } catch (HibernateException e) {
      if (tx != null) {
        tx.rollback();
      }
      e.printStackTrace();
      state = "failure";
      info = "Fallo al momento de borrar un riego";
    } finally {
      session.close();
    }

    return "states";
    //        return SUCCESS;
  }
Example #3
0
  /**
   * Encargado de buscar las coincidencias de un formulario de busqueda, para cada uno de los riegos
   * registrados a un usuario
   *
   * @param valName: Nombre del valor a buscar
   * @param valId: Identificacion del valor a buscar
   * @param selected: Valor seleccionado
   * @return lista de riegos
   */
  public String search() {
    if (!usrDao.getPrivilegeUser(idUsrSystem, "crop/list")) {
      return BaseAction.NOT_AUTHORIZED;
    }
    try {
      this.setIdCrop(Integer.parseInt(this.getRequest().getParameter("idCrop")));
    } catch (NumberFormatException e) {
      //            LOG.error("There was an error trying to parse the activityId parameter");
      this.setIdCrop(-1);
    }

    HashMap findParams = new HashMap();
    findParams.put("idEntUser", idEntSystem);
    findParams.put("idEvent", this.getIdCrop());
    listIrr = irrDao.findByParams(findParams);
    return SUCCESS;
  }