private void collectGlobalVariables() { StudyBean study = studyBase.getStudy(); String sn = study.getName(); String sd = study.getSummary().trim(); String pn = study.getIdentifier(); if (parentStudy.getId() > 0) { sn = parentStudy.getName() + " - " + study.getName(); sd = parentStudy.getSummary().trim() + " - " + study.getSummary().trim(); pn = parentStudy.getIdentifier() + " - " + study.getIdentifier(); } GlobalVariablesBean gv = this.odmStudy.getGlobalVariables(); gv.setStudyName(sn); gv.setStudyDescription(sd); gv.setProtocolName(pn); }
@SuppressWarnings("unchecked") @Override public void setDataAndLimitVariables(TableFacade tableFacade) { // initialize i18n resword = ResourceBundleProvider.getWordsBundle(getLocale()); resformat = ResourceBundleProvider.getFormatBundle(getLocale()); Limit limit = tableFacade.getLimit(); ListSubjectFilter listSubjectFilter = getListSubjectFilter(limit); if (!limit.isComplete()) { int totalRows = getSubjectDao().getCountWithFilter(listSubjectFilter, getCurrentStudy()); tableFacade.setTotalRows(totalRows); } ListSubjectSort listSubjectSort = getListSubjectSort(limit); int rowStart = limit.getRowSelect().getRowStart(); int rowEnd = limit.getRowSelect().getRowEnd(); Collection<SubjectBean> items = getSubjectDao() .getWithFilterAndSort( getCurrentStudy(), listSubjectFilter, listSubjectSort, rowStart, rowEnd); Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>(); for (SubjectBean subject : items) { UserAccountBean owner = (UserAccountBean) getUserAccountDao().findByPK(subject.getOwnerId()); UserAccountBean updater = subject.getUpdaterId() == 0 ? null : (UserAccountBean) getUserAccountDao().findByPK(subject.getUpdaterId()); HashMap<Object, Object> h = new HashMap<Object, Object>(); String studySubjectIdAndStudy = ""; List<StudySubjectBean> studySubjects = getStudySubjectDao().findAllBySubjectId(subject.getId()); for (StudySubjectBean studySubjectBean : studySubjects) { StudyBean study = (StudyBean) getStudyDao().findByPK(studySubjectBean.getStudyId()); studySubjectIdAndStudy += studySubjectIdAndStudy.length() == 0 ? "" : ","; studySubjectIdAndStudy += study.getIdentifier() + "-" + studySubjectBean.getLabel(); } h.put("studySubjectIdAndStudy", studySubjectIdAndStudy); h.put("subject", subject); h.put("subject.uniqueIdentifier", subject.getUniqueIdentifier()); h.put("subject.gender", subject.getGender()); h.put("subject.createdDate", subject.getCreatedDate()); h.put("subject.owner", owner); h.put("subject.updatedDate", subject.getUpdatedDate()); h.put("subject.updater", updater); h.put("subject.status", subject.getStatus()); theItems.add(h); } tableFacade.setItems(theItems); }
/** Inserts the new study into database */ private void submitStudy() { FormProcessor fp = new FormProcessor(request); StudyDAO sdao = new StudyDAO(sm.getDataSource()); StudyBean study = (StudyBean) session.getAttribute("newStudy"); ArrayList parameters = study.getStudyParameters(); logger.info("study bean to be created:\n"); logger.info( study.getName() + "\n" + study.getIdentifier() + "\n" + study.getParentStudyId() + "\n" + study.getSummary() + "\n" + study.getPrincipalInvestigator() + "\n" + study.getDatePlannedStart() + "\n" + study.getDatePlannedEnd() + "\n" + study.getFacilityName() + "\n" + study.getFacilityCity() + "\n" + study.getFacilityState() + "\n" + study.getFacilityZip() + "\n" + study.getFacilityCountry() + "\n" + study.getFacilityRecruitmentStatus() + "\n" + study.getFacilityContactName() + "\n" + study.getFacilityContactEmail() + "\n" + study.getFacilityContactPhone() + "\n" + study.getFacilityContactDegree()); study.setOwner(ub); study.setCreatedDate(new Date()); StudyBean parent = (StudyBean) sdao.findByPK(study.getParentStudyId()); study.setType(parent.getType()); // YW 10-10-2007, enable setting site status study.setStatus(study.getStatus()); // YW >> study.setGenetic(parent.isGenetic()); study = (StudyBean) sdao.create(study); StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource()); for (int i = 0; i < parameters.size(); i++) { StudyParamsConfig config = (StudyParamsConfig) parameters.get(i); StudyParameterValueBean spv = config.getValue(); spv.setStudyId(study.getId()); spv = (StudyParameterValueBean) spvdao.create(config.getValue()); } // YW << here only "collectDob" and "genderRequired" have been corrected // for sites. StudyParameterValueBean spv = new StudyParameterValueBean(); StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parent.getId(), "collectDob"); spv.setStudyId(study.getId()); spv.setParameter("collectDob"); spv.setValue(parentSPV.getValue()); spvdao.create(spv); parentSPV = spvdao.findByHandleAndStudy(parent.getId(), "genderRequired"); spv.setParameter("genderRequired"); spv.setValue(parentSPV.getValue()); spvdao.create(spv); // YW >> // switch user to the newly created site session.setAttribute("study", session.getAttribute("newStudy")); currentStudy = (StudyBean) session.getAttribute("study"); session.removeAttribute("newStudy"); addPageMessage(respage.getString("the_new_site_created_succesfully_current")); forwardPage(Page.SITE_LIST_SERVLET); }
/** * Validates the first section of study and save it into study bean * * @throws Exception */ private void confirmStudy() throws Exception { Validator v = new Validator(request); FormProcessor fp = new FormProcessor(request); v.addValidation("name", Validator.NO_BLANKS); v.addValidation("uniqueProId", Validator.NO_BLANKS); // >> tbh // v.addValidation("description", Validator.NO_BLANKS); // << tbh, #3943, 07/2009 v.addValidation("prinInvestigator", Validator.NO_BLANKS); if (!StringUtil.isBlank(fp.getString(INPUT_START_DATE))) { 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); } if (!StringUtil.isBlank(fp.getString("facConEmail"))) { v.addValidation("facConEmail", Validator.IS_A_EMAIL); } if (!StringUtil.isBlank(fp.getString(INPUT_VER_DATE))) { v.addValidation(INPUT_VER_DATE, Validator.IS_A_DATE); } // v.addValidation("statusId", Validator.IS_VALID_TERM); v.addValidation( "secondProId", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255); 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(); // >> tbh StudyDAO studyDAO = new StudyDAO(sm.getDataSource()); ArrayList<StudyBean> allStudies = (ArrayList<StudyBean>) studyDAO.findAll(); for (StudyBean thisBean : allStudies) { if (fp.getString("uniqueProId").trim().equals(thisBean.getIdentifier())) { Validator.addError( errors, "uniqueProId", resexception.getString("unique_protocol_id_existed")); } } // << tbh #3999 08/2009 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.getInt("expectedTotalEnrollment") <= 0) { Validator.addError( errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number")); } StudyBean newSite = this.createStudyBean(); StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(newSite.getParentStudyId()); session.setAttribute("newStudy", newSite); session.setAttribute("definitions", this.createSiteEventDefinitions(parentStudy)); if (errors.isEmpty()) { logger.info("no errors"); forwardPage(Page.CONFIRM_CREATE_SUB_STUDY); } else { 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)); } 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)); } setPresetValues(fp.getPresetValues()); logger.info("has validation errors"); request.setAttribute("formMessages", errors); // request.setAttribute("facRecruitStatusMap", // CreateStudyServlet.facRecruitStatusMap); request.setAttribute("statuses", Status.toActiveArrayList()); forwardPage(Page.CREATE_SUB_STUDY); } }