/** Metodo encargado de validar el formulario de un riego */ @Override public void validate() { /* * Se evalua dependiendo a la accion realizada: * 1) create: Al momento de guardar un registro por primera ves * 2) modify: Al momento de modificar un registro * 3) delete: Al momento de borrar un registro */ // numberFormatter = NumberFormat.getNumberInstance(new Locale("en_US")); // quantityOut = numberFormatter.format(rasta.getLatitudRas()); if (actExe.equals("create") || actExe.equals("modify")) { boolean enter = false; sowing = sowDao.objectById(this.getIdCrop()); HashMap required = new HashMap(); // required.put("irr.useIrrigationIrr", irr.getUseIrrigationIrr()); // if (irr.getUseIrrigationIrr()!=null && irr.getUseIrrigationIrr()) { required.put("irr.dateIrr", irr.getDateIrr()); // required.put("irr.amountIrr", irr.getAmountIrr()); required.put("irr.irrigationsTypes.idIrrTyp", irr.getIrrigationsTypes().getIdIrrTyp()); // } for (Iterator it = required.keySet().iterator(); it.hasNext(); ) { String sK = (String) it.next(); String sV = String.valueOf(required.get(sK)); // System.out.println(sK + " : " + sV); if (StringUtils.trim(sV).equals("null") || StringUtils.trim(sV) == null || StringUtils.trim(sV).equals("") || sV.equals("-1")) { addFieldError(sK, "El campo es requerido"); enter = true; } } if (enter) { addActionError("Faltan campos por ingresar por favor digitelos"); } Date dateSowing = null; // if (sowing.getDateSow()!=null) { if (sowing != null) { dateSowing = sowing.getDateSow(); String dmySow = new SimpleDateFormat("dd/MM/yyyy").format(sowing.getDateSow()); if (!dmySow.equals("") && irr.getDateIrr() != null) { Integer valDiffBef = GlobalFunctions.compareDateBeforeSowing(irr.getDateIrr(), sowing.getDateSow()); Integer valDiffAff = GlobalFunctions.compareDateAfterSowing(irr.getDateIrr(), sowing.getDateSow(), 0); if (valDiffBef == 2 && valDiffAff == 2) { addFieldError("irr.dateIrr", "Dato invalido"); addActionError( "Se ingreso una fecha de riego que no se encuentra 6 meses antes de la siembra o 10 meses despues de la siembra (" + dmySow + ")"); } } } if (irr.getAmountIrr() != null) { if (irr.getAmountIrr() < 0 || irr.getAmountIrr() > 1000) { addFieldError("irr.amountIrr", "Dato invalido valor entre 0 y 1000"); addActionError( "Se ingreso una cantidad aportada por hectarea invalida, por favor ingresar un valor entre 0 y 1000"); } } sowing = null; } }