コード例 #1
0
  public HashMap validateImportForm(HttpServletRequest request) {
    Validator v = new Validator(request);

    HashMap errors = v.validate();

    return errors;
  }
コード例 #2
0
  private void confirmStudy6() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    v.addValidation(
        "medlineIdentifier",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "url",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "urlDescription",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);

    errors = v.validate();

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.setMedlineIdentifier(fp.getString("medlineIdentifier"));
    newStudy.setResultsReference(fp.getBoolean("resultsReference"));
    newStudy.setUrl(fp.getString("url"));
    newStudy.setUrlDescription(fp.getString("urlDescription"));
    session.setAttribute("newStudy", newStudy);
    // request.setAttribute("interventions",session.getAttribute("interventions"));
    if (errors.isEmpty()) {
      forwardPage(Page.UPDATE_STUDY8);
    } else {
      request.setAttribute("formMessages", errors);
      forwardPage(Page.UPDATE_STUDY7);
    }
  }
コード例 #3
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);
    }
  }
コード例 #4
0
  private void confirmWholeStudy() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    errors = v.validate();

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.getStudyParameterConfig().setCollectDob(fp.getString("collectDob"));
    newStudy
        .getStudyParameterConfig()
        .setDiscrepancyManagement(fp.getString("discrepancyManagement"));
    newStudy.getStudyParameterConfig().setGenderRequired(fp.getString("genderRequired"));

    newStudy
        .getStudyParameterConfig()
        .setInterviewerNameRequired(fp.getString("interviewerNameRequired"));
    newStudy
        .getStudyParameterConfig()
        .setInterviewerNameDefault(fp.getString("interviewerNameDefault"));
    newStudy
        .getStudyParameterConfig()
        .setInterviewDateEditable(fp.getString("interviewDateEditable"));
    newStudy
        .getStudyParameterConfig()
        .setInterviewDateRequired(fp.getString("interviewDateRequired"));
    newStudy
        .getStudyParameterConfig()
        .setInterviewerNameEditable(fp.getString("interviewerNameEditable"));
    newStudy
        .getStudyParameterConfig()
        .setInterviewDateDefault(fp.getString("interviewDateDefault"));

    newStudy.getStudyParameterConfig().setSubjectIdGeneration(fp.getString("subjectIdGeneration"));
    newStudy
        .getStudyParameterConfig()
        .setSubjectPersonIdRequired(fp.getString("subjectPersonIdRequired"));
    newStudy
        .getStudyParameterConfig()
        .setSubjectIdPrefixSuffix(fp.getString("subjectIdPrefixSuffix"));

    newStudy.getStudyParameterConfig().setPersonIdShownOnCRF(fp.getString("personIdShownOnCRF"));

    session.setAttribute("newStudy", newStudy);

    if (errors.isEmpty()) {
      forwardPage(Page.STUDY_UPDATE_CONFIRM);

    } else {
      request.setAttribute("formMessages", errors);
      forwardPage(Page.UPDATE_STUDY8);
    }
  }
コード例 #5
0
  public HashMap validateImportJobForm(
      FormProcessor fp, HttpServletRequest request, String[] triggerNames, String properName) {
    Validator v = new Validator(request);
    v.addValidation(JOB_NAME, Validator.NO_BLANKS);
    // need to be unique too
    v.addValidation(JOB_DESC, Validator.NO_BLANKS);
    if (!"".equals(fp.getString(EMAIL))) {
      v.addValidation(EMAIL, Validator.IS_A_EMAIL);
    }
    // << tbh we are now allowing email to be optional
    // v.addValidation(PERIOD, Validator.NO_BLANKS);
    // v.addValidation(DIRECTORY, Validator.NO_BLANKS);
    // v.addValidation(DATE_START_JOB + "Date", Validator.IS_A_DATE);

    // TODO job names will have to be unique, tbh

    String hours = fp.getString("hours");
    String minutes = fp.getString("minutes");

    HashMap errors = v.validate();
    if ((hours.equals("0")) && (minutes.equals("0"))) {
      // System.out.println("got in the ERROR LOOP");
      // throw an error here, at least one should be greater than zero
      // errors.put(TAB, "Error Message - Pick one of the below");
      v.addError(errors, "hours", "At least one of the following should be greater than zero.");
    }
    for (String triggerName : triggerNames) {
      if (triggerName.equals(fp.getString(JOB_NAME)) && (!triggerName.equals(properName))) {
        v.addError(
            errors, JOB_NAME, "A job with that name already exists.  Please pick another name.");
      }
    }
    return errors;
  }
コード例 #6
0
  /**
   * Confirms the third input block of study info
   *
   * @throws Exception
   */
  private void confirmStudy3(boolean isInterventional) throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);

    v.addValidation("purpose", Validator.NO_BLANKS);
    for (int i = 0; i < 10; i++) {
      String type = fp.getString("interType" + i);
      String name = fp.getString("interName" + i);
      if (!StringUtil.isBlank(type) && StringUtil.isBlank(name)) {
        v.addValidation("interName", Validator.NO_BLANKS);
        request.setAttribute(
            "interventionError", respage.getString("name_cannot_be_blank_if_type"));
        break;
      }
      if (!StringUtil.isBlank(name) && StringUtil.isBlank(type)) {
        v.addValidation("interType", Validator.NO_BLANKS);
        request.setAttribute(
            "interventionError", respage.getString("name_cannot_be_blank_if_name"));
        break;
      }
    }

    errors = v.validate();
    updateStudy3(isInterventional);

    if (errors.isEmpty()) {
      logger.info("no errors");
      request.setAttribute("interventions", session.getAttribute("interventions"));
      forwardPage(Page.UPDATE_STUDY5);

    } else {
      logger.info("has validation errors");
      request.setAttribute("formMessages", errors);
      setMaps(isInterventional, (ArrayList) session.getAttribute("interventions"));
      if (isInterventional) {
        forwardPage(Page.UPDATE_STUDY3);
      } else {
        forwardPage(Page.UPDATE_STUDY4);
      }
    }
  }
コード例 #7
0
  public HashMap validateForm(
      FormProcessor fp, HttpServletRequest request, String[] triggerNames, String properName) {
    Validator v = new Validator(request);
    v.addValidation(JOB_NAME, Validator.NO_BLANKS);
    // need to be unique too
    v.addValidation(JOB_DESC, Validator.NO_BLANKS);
    v.addValidation(EMAIL, Validator.IS_A_EMAIL);
    v.addValidation(PERIOD, Validator.NO_BLANKS);
    v.addValidation(DATE_START_JOB + "Date", Validator.IS_A_DATE);
    // v.addValidation(DATE_START_JOB + "Date", new Date(), Validator.DATE_IS_AFTER_OR_EQUAL);
    // TODO job names will have to be unique, tbh

    String tab = fp.getString(TAB);
    String cdisc = fp.getString(CDISC);
    String cdisc12 = fp.getString(ExampleSpringJob.CDISC12);
    String cdisc13 = fp.getString(ExampleSpringJob.CDISC13);
    String cdisc13oc = fp.getString(ExampleSpringJob.CDISC13OC);
    String spss = fp.getString(SPSS);
    Date jobDate = fp.getDateTime(DATE_START_JOB);
    HashMap errors = v.validate();
    if ((tab == "")
        && (cdisc == "")
        && (spss == "")
        && (cdisc12 == "")
        && (cdisc13 == "")
        && (cdisc13oc == "")) {
      // throw an error here, at least one should work
      // errors.put(TAB, "Error Message - Pick one of the below");
      v.addError(errors, TAB, "Please pick at least one of the below.");
    }
    for (String triggerName : triggerNames) {
      if (triggerName.equals(fp.getString(JOB_NAME)) && (!triggerName.equals(properName))) {
        v.addError(
            errors, JOB_NAME, "A job with that name already exists.  Please pick another name.");
      }
    }
    if (jobDate.before(new Date())) {
      v.addError(
          errors, DATE_START_JOB + "Date", "This date needs to be later than the present time.");
    }
    return errors;
  }
コード例 #8
0
  /**
   * Validates the forth section of study and save it into study bean
   *
   * @param request
   * @param response
   * @throws Exception
   */
  private void confirmStudy4() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    v.addValidation(
        "conditions",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    v.addValidation(
        "keywords",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "eligibility",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    errors = v.validate();
    if (fp.getInt("expectedTotalEnrollment") <= 0) {
      Validator.addError(
          errors,
          "expectedTotalEnrollment",
          respage.getString("expected_total_enrollment_must_be_a_positive_number"));
    }

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.setConditions(fp.getString("conditions"));
    newStudy.setKeywords(fp.getString("keywords"));
    newStudy.setEligibility(fp.getString("eligibility"));
    newStudy.setGender(fp.getString("gender"));

    newStudy.setAgeMax(fp.getString("ageMax"));
    newStudy.setAgeMin(fp.getString("ageMin"));
    newStudy.setHealthyVolunteerAccepted(fp.getBoolean("healthyVolunteerAccepted"));
    newStudy.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment"));
    session.setAttribute("newStudy", newStudy);
    request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
    if (errors.isEmpty()) {
      forwardPage(Page.UPDATE_STUDY6);
    } else {
      request.setAttribute("formMessages", errors);
      forwardPage(Page.UPDATE_STUDY5);
    }
  }
コード例 #9
0
  /**
   * Validates the forth section of study and save it into study bean
   *
   * @param request
   * @param response
   * @throws Exception
   */
  private void confirmStudy5() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    if (!StringUtil.isBlank(fp.getString("facConEmail"))) {
      v.addValidation("facConEmail", Validator.IS_A_EMAIL);
    }
    v.addValidation(
        "facName",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "facCity",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "facState",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        20);
    v.addValidation(
        "facZip",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        64);
    v.addValidation(
        "facCountry",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        64);
    v.addValidation(
        "facConName",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "facConDegree",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "facConPhone",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "facConEmail",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    errors = v.validate();

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");

    newStudy.setFacilityCity(fp.getString("facCity"));
    newStudy.setFacilityContactDegree(fp.getString("facConDrgree"));
    newStudy.setFacilityName(fp.getString("facName"));
    newStudy.setFacilityContactEmail(fp.getString("facConEmail"));
    newStudy.setFacilityContactPhone(fp.getString("facConPhone"));
    newStudy.setFacilityContactName(fp.getString("facConName"));
    newStudy.setFacilityCountry(fp.getString("facCountry"));
    newStudy.setFacilityContactDegree(fp.getString("facConDegree"));
    // newStudy.setFacilityRecruitmentStatus(fp.getString("facRecStatus"));
    newStudy.setFacilityState(fp.getString("facState"));
    newStudy.setFacilityZip(fp.getString("facZip"));

    session.setAttribute("newStudy", newStudy);
    if (errors.isEmpty()) {
      forwardPage(Page.UPDATE_STUDY7);
    } else {
      request.setAttribute("formMessages", errors);
      request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
      forwardPage(Page.UPDATE_STUDY6);
    }
  }
コード例 #10
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);
    }
  }