コード例 #1
0
  private void confirmStudy2() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);

    v.addValidation(INPUT_START_DATE, Validator.IS_A_DATE);
    if (!StringUtil.isBlank(fp.getString(INPUT_END_DATE))) {
      v.addValidation(INPUT_END_DATE, Validator.IS_A_DATE);
    }
    v.addValidation(INPUT_VER_DATE, Validator.IS_A_DATE);

    errors = v.validate();
    boolean isInterventional = updateStudy2();

    if (errors.isEmpty()) {
      logger.info("no errors");
      ArrayList interventionArray = new ArrayList();
      if (isInterventional) {
        interventionArray = parseInterventions((StudyBean) session.getAttribute("newStudy"));
        setMaps(isInterventional, interventionArray);
        forwardPage(Page.UPDATE_STUDY3);
      } else {
        setMaps(isInterventional, interventionArray);
        forwardPage(Page.UPDATE_STUDY4);
      }

    } else {
      logger.info("has validation errors");
      try {
        local_df.parse(fp.getString(INPUT_START_DATE));
        fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
      } catch (ParseException pe) {
        fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
      }
      try {
        local_df.parse(fp.getString(INPUT_VER_DATE));
        fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
      } catch (ParseException pe) {
        fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
      }
      try {
        local_df.parse(fp.getString(INPUT_END_DATE));
        fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
      } catch (ParseException pe) {
        fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
      }
      setPresetValues(fp.getPresetValues());
      request.setAttribute("formMessages", errors);
      request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
      request.setAttribute("statuses", Status.toActiveArrayList());
      forwardPage(Page.UPDATE_STUDY2);
    }
  }
コード例 #2
0
  /**
   * Validates the first section of study and save it into study bean
   *
   * @param request
   * @param response
   * @throws Exception
   */
  private void confirmStudy1() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);

    v.addValidation("name", Validator.NO_BLANKS);
    v.addValidation("uniqueProId", Validator.NO_BLANKS);
    v.addValidation("description", Validator.NO_BLANKS);
    v.addValidation("prinInvestigator", Validator.NO_BLANKS);
    v.addValidation("sponsor", Validator.NO_BLANKS);

    v.addValidation(
        "secondProId",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "collaborators",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        1000);
    v.addValidation(
        "protocolDescription",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        1000);

    errors = v.validate();
    if (fp.getString("name").trim().length() > 100) {
      Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
    }
    if (fp.getString("uniqueProId").trim().length() > 30) {
      Validator.addError(
          errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
    }
    if (fp.getString("description").trim().length() > 255) {
      Validator.addError(
          errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
    }
    if (fp.getString("prinInvestigator").trim().length() > 255) {
      Validator.addError(
          errors,
          "prinInvestigator",
          resexception.getString("maximum_lenght_principal_investigator_255"));
    }
    if (fp.getString("sponsor").trim().length() > 255) {
      Validator.addError(errors, "sponsor", resexception.getString("maximum_lenght_sponsor_255"));
    }
    if (fp.getString("officialTitle").trim().length() > 255) {
      Validator.addError(
          errors, "officialTitle", resexception.getString("maximum_lenght_official_title_255"));
    }
    session.setAttribute("newStudy", createStudyBean());

    if (errors.isEmpty()) {
      logger.info("no errors in the first section");
      request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
      request.setAttribute("statuses", Status.toActiveArrayList());
      StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
      fp.addPresetValue(INPUT_START_DATE, local_df.format(newStudy.getDatePlannedStart()));
      if (newStudy.getDatePlannedEnd() != null) {
        fp.addPresetValue(INPUT_END_DATE, local_df.format(newStudy.getDatePlannedEnd()));
      }
      fp.addPresetValue(INPUT_VER_DATE, local_df.format(newStudy.getProtocolDateVerification()));
      setPresetValues(fp.getPresetValues());
      forwardPage(Page.UPDATE_STUDY2);

    } else {
      logger.info("has validation errors in the first section");
      request.setAttribute("formMessages", errors);

      forwardPage(Page.UPDATE_STUDY1);
    }
  }