protected void fillFormVars(HttpServletRequest httpServletRequest, LazyValidatorForm frm) {
    IranianInfo infMaster =
        (IranianInfo) httpServletRequest.getSession().getAttribute("personData");
    frm.set(FATHER_NAME, Utils.trimConvert(Utils.nvl(infMaster.getFatherName())));
    frm.set(FATHER_FNAME, Utils.trimConvert(Utils.nvl(infMaster.getFatherFname())));
    if (infMaster.getFatherNin() == 0) {
      frm.set(FATHER_NIN, "");
    } else {
      frm.set(FATHER_NIN, Long.toString(infMaster.getFatherNin()));
    }
    frm.set(FATHER_SHENAS_NO, Integer.toString(infMaster.getFatherShenasNo()));
    if (Utils.isEmpty(infMaster.getFatherShenasSeri())) {
      frm.set(FATHER_SHENAS_SERI, "");
    } else {
      frm.set(FATHER_SHENAS_SERI, infMaster.getFatherShenasSeri());
    }
    if (infMaster.getFatherShenasSrno() == 0) {
      frm.set(FATHER_SHENAS_SRNO, "");
    } else {
      frm.set(FATHER_SHENAS_SRNO, Integer.toString(infMaster.getFatherShenasSrno()));
    }
    /* frm.set(FATHER_SHENAS_ISSUE_PLACE,
    Utils.nvl(infMaster.getFatherShenasIssuePlace()));*/
    frm.set(FATHER_OFFICE_CODE, Utils.nvl(Short.toString(infMaster.getFatherOfficeCode())));
    //  frm.set(FATHER_HOZEH, Utils.nvl(infMaster.getFatherHozeh()));
    if (infMaster.getFatherHozehKind() != null) {
      frm.set(
          FATHER_HOZEH_CODE_KIND,
          ((infMaster.getFatherHozehCode())
              + Constants.DATA_SEPARATOR
              + (infMaster.getFatherHozehKind()).trim()));
    } else {
      frm.set(FATHER_HOZEH_CODE_KIND, "");
    }
    if (Utils.isEmpty(infMaster.getFatherDateOfBirth())) {
      frm.set(FATHER_DATE_OF_BIRTH, "");
    } else {
      if (infMaster.getFatherDateOfBirth().length() == 8) {
        frm.set(FATHER_DATE_OF_BIRTH, DateUtils.revFormatDate(infMaster.getFatherDateOfBirth()));
      } else {
        frm.set(FATHER_DATE_OF_BIRTH, infMaster.getFatherDateOfBirth());
      }
    }
    if (infMaster.getFatherAddressGeoSerial() == 0) {
      frm.set(FATHER_ADDRESS_GEO_SERIAL, "");
    } else {
      frm.set(FATHER_ADDRESS_GEO_SERIAL, Integer.toString(infMaster.getFatherAddressGeoSerial()));
    }
    frm.set(FATHER_ADDRESS, Utils.nvl(infMaster.getFatherAddress()));
    if (infMaster.getFatherZipCode() == 0) {
      frm.set(FATHER_ZIP_CODE, "");
    } else {
      frm.set(FATHER_ZIP_CODE, Long.toString(infMaster.getFatherZipCode()));
    }
    frm.set(MOTHER_NAME, Utils.trimConvert(Utils.nvl(infMaster.getMotherName())));
    frm.set(MOTHER_FNAME, Utils.trimConvert(Utils.nvl(infMaster.getMotherFname())));
    if (infMaster.getMotherNin() == 0) {
      frm.set(MOTHER_NIN, "");
    } else {
      frm.set(MOTHER_NIN, Long.toString(infMaster.getMotherNin()));
    }
    frm.set(MOTHER_SHENAS_NO, Integer.toString(infMaster.getMotherShenasNo()));
    if (Utils.isEmpty(infMaster.getMotherShenasSeri())) {
      frm.set(MOTHER_SHENAS_SERI, "");
    } else {
      frm.set(MOTHER_SHENAS_SERI, infMaster.getMotherShenasSeri());
    }
    if (infMaster.getMotherShenasSrno() == 0) {
      frm.set(MOTHER_SHENAS_SRNO, "");
    } else {
      frm.set(MOTHER_SHENAS_SRNO, Integer.toString(infMaster.getMotherShenasSrno()));
    }
    frm.set(MOTHER_OFFICE_CODE, Utils.nvl(Short.toString(infMaster.getMotherOfficeCode())));
    if (infMaster.getMotherHozehKind() != null) {
      frm.set(
          MOTHER_HOZEH_CODE_KIND,
          ((infMaster.getMotherHozehCode())
              + Constants.DATA_SEPARATOR
              + (infMaster.getMotherHozehKind()).trim()));
    } else {
      frm.set(MOTHER_HOZEH_CODE_KIND, "");
    }

    if (Utils.isEmpty(infMaster.getMotherDateOfBirth())) {
      frm.set(MOTHER_DATE_OF_BIRTH, "");
    } else {
      if (infMaster.getMotherDateOfBirth().length() == 8) {
        frm.set(MOTHER_DATE_OF_BIRTH, DateUtils.revFormatDate(infMaster.getMotherDateOfBirth()));
      } else {
        frm.set(MOTHER_DATE_OF_BIRTH, infMaster.getMotherDateOfBirth());
      }
    }
    if (infMaster.getMotherAddressGeoSerial() == 0) {
      frm.set(MOTHER_ADDRESS_GEO_SERIAL, "");
    } else {
      frm.set(MOTHER_ADDRESS_GEO_SERIAL, Integer.toString(infMaster.getMotherAddressGeoSerial()));
    }
    frm.set(MOTHER_ADDRESS, Utils.trimConvert(Utils.nvl(infMaster.getMotherAddress())));
    if (infMaster.getMotherZipCode() == 0) {
      frm.set(MOTHER_ZIP_CODE, "");
    } else {
      frm.set(MOTHER_ZIP_CODE, Long.toString(infMaster.getMotherZipCode()));
    }
    frm.set(PARENT_REGST_OFFICE_NO, Utils.nvl(infMaster.getParentRegstOfficeNo()));
    frm.set(PARENT_REGST_OFFICE_GEO, Utils.nvl(infMaster.getParentRegstOfficeGeo()));
    frm.set(PARENT_MARR_REGST_NO, Utils.nvl(infMaster.getParentMarrRegstNo()));
    if (Utils.isEmpty(infMaster.getParentDateOfMarriage())) {
      frm.set(PARENT_DATE_OF_MARRIAGE, "");
      frm.set(MARR_REG, Constants.MarriageRegisteration.NOT_REGISTERED);
    } else {
      frm.set(
          PARENT_DATE_OF_MARRIAGE, DateUtils.revFormatDate(infMaster.getParentDateOfMarriage()));
      frm.set(MARR_REG, Constants.MarriageRegisteration.REGISTERED);
    }
  }
Beispiel #2
0
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest httpServletRequest,
      HttpServletResponse httpServletResponse) {
    LazyValidatorForm frm = (LazyValidatorForm) actionForm;
    resetFocusControl(frm, CANCEL);
    ActionMessages msgs = new ActionMessages();

    if (formCanceled(frm)) {
      return actionMapping.findForward(SUCCESS);
    }

    String geoFlag = (String) frm.get(GEO_FLAG);
    if (Utils.isEmpty(geoFlag)) {
      geoFlag = (String) httpServletRequest.getParameter(GEO_FLAG);
      frm.set(GEO_FLAG, geoFlag);
    }

    if (!formSaved(frm)) {
      setFormMode(frm, ((String) httpServletRequest.getParameter(BROWSE_ACTION)));
      setFormId(frm, (String) httpServletRequest.getParameter(BROWSE_ID));
      try {
        LoginInfo loginInfo = getLoginInfo(httpServletRequest);

        String geoFlagDesc = Misc.getHardCodeDesc(Constants.TableId.GEO_FLAG, geoFlag);
        frm.set(GEO_FLAG_DESC, geoFlagDesc);

        if (!loginInfo.userHasAccess("Geo_Conversion", getFormMode(frm))) {
          if (isFormInModifyMode(frm)
              && loginInfo.userHasAccess("Geo_Conversion", Constants.ActionType.ENQUERY)) {
            setFormMode(frm, Constants.ActionType.ENQUERY);
          } else {
            throw new Exception(INVALID_ACCESS);
          }
        }
        if (!geoFlag.equals(Constants.GeoFlag.VILLAGE)) {
          throw new Exception(INVALID_ACCESS);
        }
        if (!isFormInAddMode(frm)) {
          String formKey = (String) httpServletRequest.getParameter(BROWSE_KEY);
          GeoFormationInfo inf = Geo.getGeoFormationDetails(Integer.parseInt(formKey));
          frm.set(GEO_FORMATION_SERIAL, Integer.toString(inf.getGeoFormationSerial()));
          frm.set(GEO_SERIAL, Integer.toString(inf.getGeoSerial()));
          frm.set(APPROVAL_LETTER_NO, inf.getApprovalLetterNo());
          frm.set(APPROVAL_LETTER_DATE, DateUtils.revFormatDate(inf.getApprovalLetterDate()));
          frm.set(GEO_DESC, Geo.getGeoDesc(inf.getGeoSerial()));
        }
        frm.set(GEO_FLAG_DESC, geoFlagDesc);

        if (isFormInModifyMode(frm)) {
          resetFocusControl(frm, APPROVAL_LETTER_NO);
        }
      } catch (Exception ex) {
        addError(msgs, ex.getMessage());
        saveErrors(httpServletRequest, msgs);
      }
      return actionMapping.findForward(EDIT);
    } else {
      try {
        String geoFlagDesc = (String) frm.get(GEO_FLAG_DESC);
        if (!geoFlag.equals(Constants.GeoFlag.VILLAGE)) {
          addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "علامت محل جغرافيايي");
          setFocusControl(frm, GEO_SERIAL);
        }
        GeoFormationInfo inf = new GeoFormationInfo();
        resetFocusControl(frm, "");
        if (isFormInDeleteMode(frm) || isFormInModifyMode(frm)) {
          String geoFormationSerial = ((String) frm.get(GEO_FORMATION_SERIAL)).trim();
          if (Utils.isEmpty(geoFormationSerial)) {
            addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "سريال");
            setFocusControl(frm, GEO_SERIAL);
          } else if (!Utils.isValidNotZeroNumber(geoFormationSerial, 6)) {
            addError(msgs, FIELD_INVALID, "سريال");
            setFocusControl(frm, GEO_SERIAL);
          } else {
            inf.setGeoFormationSerial(Integer.parseInt(geoFormationSerial));
          }
        }

        if (isFormInAddMode(frm)) {
          String geoSerial = ((String) frm.get(GEO_SERIAL)).trim();
          if (Utils.isEmpty(geoSerial)) {
            addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "سريال " + geoFlagDesc);
            setFocusControl(frm, GEO_SERIAL);
          }
          /*  else if (searchGeoDesc(frm, geoFlag) == false) {
            addError(msgs, FIELD_INVALID, "سريال " + geoFlagDesc);
            setFocusControl(frm, GEO_SERIAL);
          }  */
          else {
            inf.setGeoSerial(Integer.parseInt(geoSerial));
          }
        }

        if (!isFormInDeleteMode(frm)) {
          String approvalLetterNo = Utils.trimConvert((String) frm.get(APPROVAL_LETTER_NO));
          frm.set(APPROVAL_LETTER_NO, approvalLetterNo);
          if (Utils.isEmpty(approvalLetterNo)) {
            addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "شماره تصويب نامه");
            setFocusControl(frm, APPROVAL_LETTER_NO);
          } else if (approvalLetterNo.length() > 20) {
            addError(msgs, FIELD_INVALID, "شماره تصويب نامه");
            setFocusControl(frm, APPROVAL_LETTER_NO);
          } else {
            inf.setApprovalLetterNo(approvalLetterNo);
          }

          String approvalLetterDate = ((String) frm.get(APPROVAL_LETTER_DATE)).trim();
          if (Utils.isEmpty(approvalLetterDate)) {
            addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "تاريخ تصويب نامه");
            setFocusControl(frm, APPROVAL_LETTER_DATE);
          } else if (!DateUtils.isValidRevFormattedFDate(approvalLetterDate)) {
            addError(msgs, FIELD_INVALID, "تاريخ تصويب نامه");
            setFocusControl(frm, APPROVAL_LETTER_DATE);
          } else if (DateUtils.unformatRevFormattedFdate(approvalLetterDate)
                  .compareTo(DateUtils.fDate())
              > 0) {
            addError(msgs, FIELD_SHOULD_BE_LESS_THAN, "تاريخ تصويب نامه", "تاريخ روز");
            setFocusControl(frm, APPROVAL_LETTER_DATE);
          } else {
            inf.setApprovalLetterDate(DateUtils.unformatRevFormattedFdate(approvalLetterDate));
          }
        }

        if (!msgs.isEmpty()) {
          saveErrors(httpServletRequest, msgs);
          return actionMapping.findForward(EDIT);
        }
        resetFocusControl(frm, CANCEL);
        Geo.saveConversion(getFormMode(frm), inf, geoFlag);
        httpServletRequest.setAttribute(BROWSE_KEY, inf.getKey());
        return actionMapping.findForward(SUCCESS);
      } catch (Exception ex) {
        resetFocusControl(frm, CANCEL);
        addError(msgs, ex.getMessage());
        saveErrors(httpServletRequest, msgs);
        return actionMapping.findForward(EDIT);
      }
    }
  }