use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class ViewEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int defId = fp.getInt("id", true);
if (defId == 0) {
addPageMessage(respage.getString("please_choose_a_definition_to_view"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
// definition id
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
if (currentStudy.getId() != sed.getStudyId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
checkRoleByUserAndStudy(ub, sed.getStudyId(), 0);
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(this.currentStudy, defId);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
// edc.setCrfLabel(crf.getLabel());
edc.setCrfName(crf.getName());
// to show/hide edit action on jsp page
if (crf.getStatus().equals(Status.AVAILABLE)) {
edc.setOwner(crf.getOwner());
}
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
request.setAttribute("definition", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("defSize", new Integer(eventDefinitionCRFs.size()));
// request.setAttribute("eventDefinitionCRFs", new
// ArrayList(tm.values()));
forwardPage(Page.VIEW_EVENT_DEFINITION);
}
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class CreateSubStudyServlet method createSiteEventDefinitions.
private ArrayList<StudyEventDefinitionBean> createSiteEventDefinitions(StudyBean site, Validator v) throws MalformedURLException {
FormProcessor fp = new FormProcessor(request);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcsInSession = new ArrayList<EventDefinitionCRFBean>();
StudyBean parentStudyBean;
if (site.getParentStudyId() == 0) {
parentStudyBean = site;
} else {
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
parentStudyBean = (StudyBean) studyDAO.findByPK(site.getParentStudyId());
}
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyBean.getId());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
if (seds == null || seds.size() <= 0) {
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
seds = sedDao.findAllByStudy(parentStudy);
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
// EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
int start = 0;
for (EventDefinitionCRFBean edcBean : edcs) {
EventDefinitionCRFBean persistEventDefBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
int edcStatusId = edcBean.getStatus().getId();
if (edcStatusId == 5 || edcStatusId == 7) {
} else {
String order = start + "-" + edcBean.getId();
int defaultVersionId = fp.getInt("defaultVersionId" + order);
String requiredCRF = fp.getString("requiredCRF" + order);
String doubleEntry = fp.getString("doubleEntry" + order);
String electronicSignature = fp.getString("electronicSignature" + order);
String hideCRF = fp.getString("hideCRF" + order);
int sdvId = fp.getInt("sdvOption" + order);
String participantForm = fp.getString("participantForm" + order);
String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + order);
String submissionUrl = fp.getString("submissionUrl" + order);
String offline = fp.getString("offline" + order);
ArrayList<String> selectedVersionIdList = fp.getStringArray("versionSelection" + order);
int selectedVersionIdListSize = selectedVersionIdList.size();
String selectedVersionIds = "";
if (selectedVersionIdListSize > 0) {
for (String id : selectedVersionIdList) {
selectedVersionIds += id + ",";
}
selectedVersionIds = selectedVersionIds.substring(0, selectedVersionIds.length() - 1);
}
boolean changed = false;
boolean isRequired = !StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim()) ? true : false;
boolean isDouble = !StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim()) ? true : false;
boolean hasPassword = !StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim()) ? true : false;
boolean isHide = !StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim()) ? true : false;
if (edcBean.getParentId() > 0) {
int dbDefaultVersionId = edcBean.getDefaultVersionId();
if (defaultVersionId != dbDefaultVersionId) {
changed = true;
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
edcBean.setDefaultVersionId(defaultVersionId);
edcBean.setDefaultVersionName(defaultVersion.getName());
}
if (isRequired != edcBean.isRequiredCRF()) {
changed = true;
edcBean.setRequiredCRF(isRequired);
}
if (isDouble != edcBean.isDoubleEntry()) {
changed = true;
edcBean.setDoubleEntry(isDouble);
}
if (hasPassword != edcBean.isElectronicSignature()) {
changed = true;
edcBean.setElectronicSignature(hasPassword);
}
if (isHide != edcBean.isHideCrf()) {
changed = true;
edcBean.setHideCrf(isHide);
}
if (!submissionUrl.equals(edcBean.getSubmissionUrl()) || !submissionUrl.equals(persistEventDefBean.getSubmissionUrl())) {
changed = true;
edcBean.setSubmissionUrl(submissionUrl);
}
if (!StringUtil.isBlank(selectedVersionIds) && !selectedVersionIds.equals(edcBean.getSelectedVersionIds())) {
changed = true;
String[] ids = selectedVersionIds.split(",");
ArrayList<Integer> idList = new ArrayList<Integer>();
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
edcBean.setSelectedVersionIdList(idList);
edcBean.setSelectedVersionIds(selectedVersionIds);
}
if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
changed = true;
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
}
} else {
// only if definition-crf has been modified, will it be
// saved for the site
int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
if (defaultId == defaultVersionId) {
if (isRequired == edcBean.isRequiredCRF()) {
if (isDouble == edcBean.isDoubleEntry()) {
if (hasPassword == edcBean.isElectronicSignature()) {
if (isHide == edcBean.isHideCrf()) {
if (submissionUrl.equals("")) {
if (selectedVersionIdListSize > 0) {
if (selectedVersionIdListSize == edcBean.getVersions().size()) {
if (sdvId > 0) {
if (sdvId != edcBean.getSourceDataVerification().getCode()) {
changed = true;
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
edcBean.setSubmissionUrl(submissionUrl);
}
}
} else {
changed = true;
String[] ids = selectedVersionIds.split(",");
ArrayList<Integer> idList = new ArrayList<Integer>();
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
edcBean.setSelectedVersionIdList(idList);
edcBean.setSelectedVersionIds(selectedVersionIds);
edcBean.setSubmissionUrl(submissionUrl);
}
}
} else {
changed = true;
edcBean.setSubmissionUrl(submissionUrl);
}
} else {
changed = true;
edcBean.setHideCrf(isHide);
edcBean.setSubmissionUrl(submissionUrl);
}
} else {
changed = true;
edcBean.setElectronicSignature(hasPassword);
edcBean.setSubmissionUrl(submissionUrl);
}
} else {
changed = true;
edcBean.setDoubleEntry(isDouble);
edcBean.setSubmissionUrl(submissionUrl);
}
} else {
changed = true;
edcBean.setRequiredCRF(isRequired);
edcBean.setSubmissionUrl(submissionUrl);
}
} else {
changed = true;
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
edcBean.setDefaultVersionId(defaultVersionId);
edcBean.setDefaultVersionName(defaultVersion.getName());
}
}
changes.put(sed.getId() + "-" + edcBean.getId(), changed);
++start;
}
edcsInSession.add(edcBean);
}
sed.setPopulated(false);
eventDefCrfList = validateSubmissionUrl(edcsInSession, eventDefCrfList, v, sed);
edcsInSession.clear();
}
errors = v.validate();
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())) {
v.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"));
}
if (!errors.isEmpty()) {
// logger.info("has errors");
StudyBean study = createStudyBean();
session.setAttribute("newStudy", study);
session.setAttribute("definitions", seds);
request.setAttribute("formMessages", 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_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);
forwardPage(Page.CREATE_SUB_STUDY);
}
session.setAttribute("changed", changes);
return seds;
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class StudyModuleController method registerParticipate.
@RequestMapping(value = "/{study}/register", method = RequestMethod.POST)
public String registerParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
respage = ResourceBundleProvider.getPageMessagesBundle(locale);
// Check if desired hostName is available. If so, send OCUI registration request
String hostName = request.getParameter("hostName");
if (hostName == null || hostName.equals("")) {
addRegMessage(request, respage.getString("participate_hostname_invalid"));
return "redirect:/pages/studymodule";
}
String status = "";
String nameAvailability = registrar.getHostNameAvailability(hostName);
if (nameAvailability.equals(ParticipantPortalRegistrar.UNAVAILABLE)) {
addRegMessage(request, respage.getString("participate_hostname_not_available"));
return "redirect:/pages/studymodule";
} else if (nameAvailability.equals(ParticipantPortalRegistrar.UNKNOWN)) {
addRegMessage(request, respage.getString("participate_not_available"));
return "redirect:/pages/studymodule";
} else if (nameAvailability.equals(ParticipantPortalRegistrar.INVALID)) {
addRegMessage(request, respage.getString("participate_hostname_invalid"));
return "redirect:/pages/studymodule";
} else {
// Returned status was 'available'. Proceed with registration.
status = registrar.registerStudy(study.getOid(), hostName, study.getIdentifier());
}
// parameter.
if (status.equals("")) {
addRegMessage(request, respage.getString("participate_not_available"));
} else {
// Update OC Study configuration
spv.setStudyId(study.getId());
spv.setParameter("participantPortal");
spv.setValue("enabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setParticipantPortal("enabled");
}
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class StudyModuleController method deactivateRandomization.
@RequestMapping(value = "/{study}/deactivaterandomization", method = RequestMethod.GET)
public String deactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
spv.setStudyId(study.getId());
spv.setParameter("randomization");
spv.setValue("disabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setRandomization("disabled");
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class StudyModuleController method reactivateRandomization.
@RequestMapping(value = "/{study}/reactivaterandomization", method = RequestMethod.GET)
public String reactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
spv.setStudyId(study.getId());
spv.setParameter("randomization");
spv.setValue("enabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setRandomization("enabled");
return "redirect:/pages/studymodule";
}
Aggregations