private void updateParameter(StudyParameterValueDAO spvdao, StudyParameterValueBean spv) { StudyParameterValueBean spv1 = spvdao.findByHandleAndStudy(spv.getStudyId(), spv.getParameter()); if (spv1.getId() > 0) { spvdao.update(spv); } else { spvdao.create(spv); } }
private void updateParameter(StudyParameterValueDAO spvdao, StudyParameterValueBean spv) { StudyParameterValueBean spv1 = spvdao.findByHandleAndStudy(spv.getStudyId(), spv.getParameter()); System.out.println("found parameter: " + spv.getParameter()); if (spv1.getId() > 0) { spvdao.update(spv); System.out.println("updating"); } else { spvdao.create(spv); System.out.println("creating"); } }
/** 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); }