예제 #1
0
 @Override
 public void prepare() throws Exception {
   user = (Users) this.getSession().get(APConstants.SESSION_USER);
   idEntSystem = UsersDao.getEntitySystem(user.getIdUsr());
   usrDao = new UsersDao();
   idUsrSystem = user.getIdUsr();
 }
예제 #2
0
  @Override
  public void prepare() throws Exception {
    user = (Users) ActionContext.getContext().getSession().get(APConstants.SESSION_USER);
    //        user = (Users) this.getSession().get(APConstants.SESSION_USER);
    idEntSystem = UsersDao.getEntitySystem(user.getIdUsr());
    EntitiesDao entDao = new EntitiesDao();
    Entities entTemp = entDao.findById(idEntSystem);
    typeEnt = entTemp.getEntitiesTypes().getIdEntTyp();
    if (entTemp.getEntitiesTypes().getIdEntTyp() == 2) {
      ProducersDao proDao = new ProducersDao();
      Producers proTemp = new Producers();
      proTemp = proDao.objectByEntityId(idEntSystem);
      if (proTemp != null) {
        idProducer = proTemp.getIdPro();
        name_producer = entTemp.getNameEnt();
      }
    }
    this.setDepartment_property(new DepartmentsDao().findAll());
    usrDao = new UsersDao();
    idUsrSystem = user.getIdUsr();
    List<Municipalities> mun = new ArrayList<Municipalities>();
    mun.add(new Municipalities());
    this.setCity_property(mun);
    assDao = new AssociationDao();
    //        HashMap route = new HashMap();
    //        route.put("getting", getText("email.from"));
    //        listRoute.add(route);
    //        route = new HashMap();
    ////        String val = getText('text.title.farm');
    //        route.put("listFarm", getText("email.from"));
    //        listRoute.add(route);

  }
예제 #3
0
  public String getReport() throws Exception {
    if (!usrDao.getPrivilegeUser(idUsrSystem, "farm/list")) {
      return BaseAction.NOT_AUTHORIZED;
    }

    String selAll = "false";
    if (selectAllname_agronomist != null) {
      selAll = "true";
    }

    HashMap findParams = new HashMap();
    findParams.put("selAll", selAll);
    findParams.put("selItem", selectItemname_agronomist);
    Integer entTypeId = new EntitiesDao().getEntityTypeId(user.getIdUsr());
    findParams.put("entType", entTypeId);
    findParams.put("idEntUser", idEntSystem);
    String fileName = "" + getText("file.docfarm");
    //        String fileName  = "farmsInfo.csv";
    farDao.getFarms(findParams, fileName);

    File f = new File(fileName);
    inputStream = new FileInputStream(f);
    return "OUTPUTCSV";
  }
예제 #4
0
  /**
   * Encargado de buscar las coincidencias de un formulario de busqueda, para cada una de las fincas
   * registradas a un usuario
   *
   * @param valName: Nombre del valor a buscar
   * @param valId: Identificacion del valor a buscar
   * @param selected: Valor seleccionado
   * @return lista de fincas
   */
  public String search() {
    if (!usrDao.getPrivilegeUser(idUsrSystem, "farm/list")) {
      //        if (!false) {
      return BaseAction.NOT_AUTHORIZED;
    }
    valName = (String) (this.getRequest().getParameter("valName"));
    valId = (String) (this.getRequest().getParameter("valId"));
    selected = (String) (this.getRequest().getParameter("selected"));
    viewInfo = (String) (this.getRequest().getParameter("viewInfo"));
    String selAll = "false";
    if (selected == null) {
      selected = "property";
      selAll = "true";
    }

    if (selectAllname_agronomist != null) {
      selAll = "true";
    }
    additionals = new HashMap();
    additionals.put("selected", selected);
    HashMap findParams = new HashMap();
    findParams.put("selAll", selAll);
    findParams.put("selItem", selectItemname_agronomist);
    Integer entTypeId = new EntitiesDao().getEntityTypeId(user.getIdUsr());
    findParams.put("entType", entTypeId);
    list_agronomist = assDao.gelAllAgronomist(idEntSystem);
    if (searchFromFarm != null && searchFromFarm == 2) {
      search_farm = "";
    }

    //        fardParams.put("nameProperty", this.getName_property());
    //        System.out.println("this.getAltitude_property()->"+this.getAltitude_property());
    findParams.put("idEntUser", idEntSystem);
    findParams.put("search_farm", search_farm);
    findParams.put("name_producer", name_producer);
    findParams.put("name_property", name_property);
    findParams.put("depFar", depFar);
    findParams.put("cityFar", cityFar);
    findParams.put("lane_property", lane_property);
    findParams.put("altitude_property", altitude_property);
    findParams.put("latitude_property", latitude_property);
    findParams.put("length_property", length_property);
    int pageReq;
    if (this.getRequest().getParameter("page") == null) {
      pageReq = this.getPage();
    } else {
      pageReq = Integer.parseInt(StringUtils.trim(this.getRequest().getParameter("page")));
    }
    findParams.put("pageNow", pageReq);
    findParams.put("maxResults", this.getMaxResults());
    FarmsDao farmDao = new FarmsDao();
    //        System.out.println("entreeee");
    listProperties = farmDao.findByParams(findParams);
    //        this.setCountTotal(100);
    //        System.out.println("entreeee->"+listProperties.get(0).get("countTotal"));
    this.setCountTotal(Integer.parseInt(String.valueOf(listProperties.get(0).get("countTotal"))));
    this.setPage(page);
    listProperties.remove(0);
    //        System.out.println("countTotal->"+this.getCountTotal());
    return SUCCESS;
  }