Search in sources :

Example 51 with Validator

use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.

the class UpdateStudyServlet method confirmStudy3.

/**
     * 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);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Validator(org.akaza.openclinica.control.form.Validator)

Example 52 with Validator

use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.

the class UpdateStudyServlet method confirmStudy6.

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);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Validator(org.akaza.openclinica.control.form.Validator)

Example 53 with Validator

use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.

the class UpdateStudyServlet method confirmWholeStudy.

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);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Validator(org.akaza.openclinica.control.form.Validator)

Aggregations

Validator (org.akaza.openclinica.control.form.Validator)53 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)44 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)20 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)13 Date (java.util.Date)12 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)12 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)11 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)7 ResourceBundle (java.util.ResourceBundle)6 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)6 Role (org.akaza.openclinica.bean.core.Role)5 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 SecurityManager (org.akaza.openclinica.core.SecurityManager)4 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)4 LinkedHashMap (java.util.LinkedHashMap)3 Locale (java.util.Locale)3 Map (java.util.Map)3