@Override public void processRequest() throws Exception { FormProcessor fp = new FormProcessor(request); String action = request.getParameter("action"); if (StringUtil.isBlank(action)) { if (currentStudy.getParentStudyId() > 0) { addPageMessage(respage.getString("you_cannot_create_site_itself_site")); forwardPage(Page.SITE_LIST_SERVLET); } else { StudyBean newStudy = new StudyBean(); newStudy.setParentStudyId(currentStudy.getId()); // get default facility info from property file newStudy.setFacilityName(SQLInitServlet.getField(CreateStudyServlet.FAC_NAME)); newStudy.setFacilityCity(SQLInitServlet.getField(CreateStudyServlet.FAC_CITY)); newStudy.setFacilityState(SQLInitServlet.getField(CreateStudyServlet.FAC_STATE)); newStudy.setFacilityCountry(SQLInitServlet.getField(CreateStudyServlet.FAC_COUNTRY)); newStudy.setFacilityContactDegree( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_DEGREE)); newStudy.setFacilityContactEmail( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_EMAIL)); newStudy.setFacilityContactName( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_NAME)); newStudy.setFacilityContactPhone( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_PHONE)); newStudy.setFacilityZip(SQLInitServlet.getField(CreateStudyServlet.FAC_ZIP)); ArrayList parentConfigs = currentStudy.getStudyParameters(); // logger.info("parentConfigs size:" + parentConfigs.size()); ArrayList configs = new ArrayList(); for (int i = 0; i < parentConfigs.size(); i++) { StudyParamsConfig scg = (StudyParamsConfig) parentConfigs.get(i); if (scg != null) { // find the one that sub study can change if (scg.getValue().getId() > 0 && scg.getParameter().isOverridable()) { logger.info("parameter:" + scg.getParameter().getHandle()); logger.info("value:" + scg.getValue().getValue()); // YW 10-12-2007, set overridable study parameters // for a site if (scg.getParameter().getHandle().equalsIgnoreCase("interviewerNameRequired")) { scg.getValue().setValue(fp.getString("interviewerNameRequired")); } else if (scg.getParameter() .getHandle() .equalsIgnoreCase("interviewerNameDefault")) { scg.getValue().setValue(fp.getString("interviewerNameDefault")); } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateRequired")) { scg.getValue().setValue(fp.getString("interviewDateRequired")); } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateDefault")) { scg.getValue().setValue(fp.getString("interviewDateDefault")); } // YW >> configs.add(scg); } } } newStudy.setStudyParameters(configs); // YW 10-12-2007 << newStudy .getStudyParameterConfig() .setInterviewerNameRequired(fp.getString("interviewerNameRequired")); newStudy .getStudyParameterConfig() .setInterviewerNameDefault(fp.getString("interviewerNameDefault")); newStudy .getStudyParameterConfig() .setInterviewDateRequired(fp.getString("interviewDateRequired")); newStudy .getStudyParameterConfig() .setInterviewDateDefault(fp.getString("interviewDateDefault")); // YW >> session.setAttribute("newStudy", newStudy); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); request.setAttribute("statuses", Status.toActiveArrayList()); forwardPage(Page.CREATE_SUB_STUDY); } } else { if ("confirm".equalsIgnoreCase(action)) { confirmStudy(); } else if ("back".equalsIgnoreCase(action)) { request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); request.setAttribute("statuses", Status.toActiveArrayList()); forwardPage(Page.CREATE_SUB_STUDY); } else if ("submit".equalsIgnoreCase(action)) { submitStudy(); } } }
/** * Constructs study bean from request * * @param request * @return */ private StudyBean createStudyBean() { FormProcessor fp = new FormProcessor(request); StudyBean study = (StudyBean) session.getAttribute("newStudy"); study.setName(fp.getString("name")); study.setIdentifier(fp.getString("uniqueProId")); study.setSecondaryIdentifier(fp.getString("secondProId")); study.setSummary(fp.getString("description")); study.setPrincipalInvestigator(fp.getString("prinInvestigator")); study.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment")); java.util.Date startDate = null; java.util.Date endDate = null; try { local_df.setLenient(false); startDate = local_df.parse(fp.getString("startDate")); } catch (ParseException fe) { startDate = study.getDatePlannedStart(); logger.info(fe.getMessage()); } study.setDatePlannedStart(startDate); try { local_df.setLenient(false); endDate = local_df.parse(fp.getString("endDate")); } catch (ParseException fe) { endDate = study.getDatePlannedEnd(); } study.setDatePlannedEnd(endDate); study.setFacilityCity(fp.getString("facCity")); study.setFacilityContactDegree(fp.getString("facConDrgree")); study.setFacilityName(fp.getString("facName")); study.setFacilityContactEmail(fp.getString("facConEmail")); study.setFacilityContactPhone(fp.getString("facConPhone")); study.setFacilityContactName(fp.getString("facConName")); study.setFacilityContactDegree(fp.getString("facConDegree")); study.setFacilityCountry(fp.getString("facCountry")); // study.setFacilityRecruitmentStatus(fp.getString("facRecStatus")); study.setFacilityState(fp.getString("facState")); study.setFacilityZip(fp.getString("facZip")); study.setStatus(Status.get(fp.getInt("statusId"))); ArrayList parameters = study.getStudyParameters(); for (int i = 0; i < parameters.size(); i++) { StudyParamsConfig scg = (StudyParamsConfig) parameters.get(i); String value = fp.getString(scg.getParameter().getHandle()); logger.info("get value:" + value); scg.getValue().setParameter(scg.getParameter().getHandle()); scg.getValue().setValue(value); } // YW 10-12-2007 << study .getStudyParameterConfig() .setInterviewerNameRequired(fp.getString("interviewerNameRequired")); study .getStudyParameterConfig() .setInterviewerNameDefault(fp.getString("interviewerNameDefault")); study.getStudyParameterConfig().setInterviewDateRequired(fp.getString("interviewDateRequired")); study.getStudyParameterConfig().setInterviewDateDefault(fp.getString("interviewDateDefault")); // YW >> return study; }
private void validateStudy5(FormProcessor fp, Validator v) { 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(); study.setFacilityCity(fp.getString("facCity")); study.setFacilityContactDegree(fp.getString("facConDrgree")); study.setFacilityName(fp.getString("facName")); study.setFacilityContactEmail(fp.getString("facConEmail")); study.setFacilityContactPhone(fp.getString("facConPhone")); study.setFacilityContactName(fp.getString("facConName")); study.setFacilityCountry(fp.getString("facCountry")); study.setFacilityContactDegree(fp.getString("facConDegree")); // newStudy.setFacilityRecruitmentStatus(fp.getString("facRecStatus")); study.setFacilityState(fp.getString("facState")); study.setFacilityZip(fp.getString("facZip")); if (errors.isEmpty()) { } else { request.setAttribute("formMessages", errors); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); } }
/** * 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); } }
@Override public void processRequest() throws Exception { FormProcessor fp = new FormProcessor(request); String action = request.getParameter("action"); session.setAttribute("sdvOptions", this.setSDVOptions()); if (StringUtil.isBlank(action)) { if (currentStudy.getParentStudyId() > 0) { addPageMessage(respage.getString("you_cannot_create_site_itself_site")); forwardPage(Page.SITE_LIST_SERVLET); } else { StudyBean newStudy = new StudyBean(); newStudy.setParentStudyId(currentStudy.getId()); // get default facility info from property file newStudy.setFacilityName(SQLInitServlet.getField(CreateStudyServlet.FAC_NAME)); newStudy.setFacilityCity(SQLInitServlet.getField(CreateStudyServlet.FAC_CITY)); newStudy.setFacilityState(SQLInitServlet.getField(CreateStudyServlet.FAC_STATE)); newStudy.setFacilityCountry(SQLInitServlet.getField(CreateStudyServlet.FAC_COUNTRY)); newStudy.setFacilityContactDegree( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_DEGREE)); newStudy.setFacilityContactEmail( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_EMAIL)); newStudy.setFacilityContactName( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_NAME)); newStudy.setFacilityContactPhone( SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_PHONE)); newStudy.setFacilityZip(SQLInitServlet.getField(CreateStudyServlet.FAC_ZIP)); List<StudyParamsConfig> parentConfigs = currentStudy.getStudyParameters(); // logger.info("parentConfigs size:" + parentConfigs.size()); ArrayList configs = new ArrayList(); for (StudyParamsConfig scg : parentConfigs) { // StudyParamsConfig scg = (StudyParamsConfig) // parentConfigs.get(i); if (scg != null) { // find the one that sub study can change if (scg.getValue().getId() > 0 && scg.getParameter().isOverridable()) { logger.info("parameter:" + scg.getParameter().getHandle()); logger.info("value:" + scg.getValue().getValue()); // YW 10-12-2007, set overridable study parameters // for a site if (scg.getParameter().getHandle().equalsIgnoreCase("interviewerNameRequired")) { scg.getValue().setValue(fp.getString("interviewerNameRequired")); } else if (scg.getParameter() .getHandle() .equalsIgnoreCase("interviewerNameDefault")) { scg.getValue().setValue(fp.getString("interviewerNameDefault")); } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateRequired")) { scg.getValue().setValue(fp.getString("interviewDateRequired")); } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateDefault")) { scg.getValue().setValue(fp.getString("interviewDateDefault")); } // YW >> configs.add(scg); } } } newStudy.setStudyParameters(configs); // YW 10-12-2007 << newStudy .getStudyParameterConfig() .setInterviewerNameRequired(fp.getString("interviewerNameRequired")); newStudy .getStudyParameterConfig() .setInterviewerNameDefault(fp.getString("interviewerNameDefault")); newStudy .getStudyParameterConfig() .setInterviewDateRequired(fp.getString("interviewDateRequired")); newStudy .getStudyParameterConfig() .setInterviewDateDefault(fp.getString("interviewDateDefault")); // YW >> // BWP 3169 1-12-2008 << newStudy .getStudyParameterConfig() .setInterviewerNameEditable( currentStudy.getStudyParameterConfig().getInterviewerNameEditable()); newStudy .getStudyParameterConfig() .setInterviewDateEditable( currentStudy.getStudyParameterConfig().getInterviewDateEditable()); // >> 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_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)); } // tbh 3946 07/2009 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)); } // >> tbh setPresetValues(fp.getPresetValues()); session.setAttribute("newStudy", newStudy); session.setAttribute("definitions", this.initDefinitions(newStudy)); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); request.setAttribute("statuses", Status.toActiveArrayList()); forwardPage(Page.CREATE_SUB_STUDY); } } else { if ("confirm".equalsIgnoreCase(action)) { confirmStudy(); } else if ("back".equalsIgnoreCase(action)) { StudyBean newStudy = (StudyBean) session.getAttribute("newStudy"); try { fp.addPresetValue(INPUT_START_DATE, local_df.format(newStudy.getDatePlannedEnd())); } catch (Exception pe) { fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE)); } try { fp.addPresetValue(INPUT_END_DATE, local_df.format(newStudy.getDatePlannedStart())); } catch (Exception pe) { fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE)); } try { fp.addPresetValue( INPUT_VER_DATE, local_df.format(newStudy.getProtocolDateVerification())); } catch (Exception pe) { fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE)); } setPresetValues(fp.getPresetValues()); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); request.setAttribute("statuses", Status.toActiveArrayList()); forwardPage(Page.CREATE_SUB_STUDY); } else if ("submit".equalsIgnoreCase(action)) { submitStudy(); } } }