use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class CreateStudyServlet method submitStudy.
/**
* Inserts the new study into database
*/
private void submitStudy() {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
logger.info("study bean to be created:" + newStudy.getName() + newStudy.getProtocolDateVerification());
// newStudy.setType(StudyType.NONGENETIC);//need to refine in the future
newStudy.setOwner(ub);
newStudy.setCreatedDate(new Date());
// newStudy.setStatus(Status.AVAILABLE);
StudyBean finalStudy = (StudyBean) sdao.create(newStudy);
logger.info("new study created");
StudyParameterValueBean spv = new StudyParameterValueBean();
spv.setStudyId(finalStudy.getId());
spv.setParameter("collectDob");
spv.setValue(newStudy.getStudyParameterConfig().getCollectDob());
spvdao.create(spv);
spv.setParameter("discrepancyManagement");
spv.setValue(newStudy.getStudyParameterConfig().getDiscrepancyManagement());
spvdao.create(spv);
spv.setParameter("genderRequired");
spv.setValue(newStudy.getStudyParameterConfig().getGenderRequired());
spvdao.create(spv);
spv.setParameter("subjectPersonIdRequired");
spv.setValue(newStudy.getStudyParameterConfig().getSubjectPersonIdRequired());
spvdao.create(spv);
spv.setParameter("interviewerNameRequired");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewerNameRequired());
spvdao.create(spv);
spv.setParameter("interviewerNameDefault");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewerNameDefault());
spvdao.create(spv);
spv.setParameter("interviewerNameEditable");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewerNameEditable());
spvdao.create(spv);
spv.setParameter("interviewDateRequired");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewDateRequired());
spvdao.create(spv);
spv.setParameter("interviewDateDefault");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewDateDefault());
spvdao.create(spv);
spv.setParameter("interviewDateEditable");
spv.setValue(newStudy.getStudyParameterConfig().getInterviewDateEditable());
spvdao.create(spv);
spv.setParameter("subjectIdGeneration");
spv.setValue(newStudy.getStudyParameterConfig().getSubjectIdGeneration());
spvdao.create(spv);
spv.setParameter("subjectIdPrefixSuffix");
spv.setValue(newStudy.getStudyParameterConfig().getSubjectIdPrefixSuffix());
spvdao.create(spv);
spv.setParameter("personIdShownOnCRF");
spv.setValue(newStudy.getStudyParameterConfig().getPersonIdShownOnCRF());
spvdao.create(spv);
spv.setParameter("secondaryLabelViewable");
spv.setValue(newStudy.getStudyParameterConfig().getSecondaryLabelViewable());
spvdao.create(spv);
spv.setParameter("adminForcedReasonForChange");
spv.setValue(newStudy.getStudyParameterConfig().getAdminForcedReasonForChange());
spvdao.create(spv);
logger.info("study parameters created done");
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class CreateSubStudyServlet method initDefinitions.
private ArrayList<StudyEventDefinitionBean> initDefinitions(StudyBean site) throws MalformedURLException {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
seds = sedDao.findAllByStudy(parentStudy);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, site.getId(), parentStudy.getId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
// sed.setCrfNum(edcs.size());
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
} else {
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
edcBean.setSubmissionUrl("");
/* EventDefinitionCRFBean eBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
if (eBean.isActive()){
edcBean.setSubmissionUrl(eBean.getSubmissionUrl());
}else{
edcBean.setSubmissionUrl("");
}
*/
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
}
edcBean.setSelectedVersionIdList(idList);
defCrfs.add(edcBean);
++start;
}
}
logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
return seds;
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class RequestStudyServlet method confirm.
/**
* @param request
* @param response
*/
private void confirm() throws Exception {
Validator v = new Validator(request);
v.addValidation("studyId", Validator.IS_AN_INTEGER);
v.addValidation("studyRoleId", Validator.IS_VALID_TERM, TermType.ROLE);
HashMap errors = v.validate();
FormProcessor fp = new FormProcessor(request);
StudyUserRoleBean newRole = new StudyUserRoleBean();
if (fp.getInt("studyRoleId") > 0) {
newRole.setRole(Role.get(fp.getInt("studyRoleId")));
}
newRole.setStudyId(fp.getInt("studyId"));
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean studyRequested = (StudyBean) sdao.findByPK(newRole.getStudyId());
newRole.setStudyName(studyRequested.getName());
session.setAttribute("newRole", newRole);
if (!errors.isEmpty()) {
logger.info("after processing form,error is not empty");
request.setAttribute("formMessages", errors);
forwardPage(Page.REQUEST_STUDY);
} else {
logger.info("after processing form,no errors");
forwardPage(Page.REQUEST_STUDY_CONFIRM);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class PrintAllEventCRFServlet method processRequest.
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
FormProcessor fp = new FormProcessor(request);
SessionManager sm = (SessionManager) request.getSession().getAttribute("sm");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
ArrayList<SectionBean> allSectionBeans;
// The PrintDataEntry servlet handles this parameter
boolean isSubmitted = false;
StudyEventDefinitionDAO sedao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
seds = sedao.findAllByStudy(currentStudy);
// ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByStudy(site);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcs = new ArrayList();
for (StudyEventDefinitionBean sed : seds) {
int defId = sed.getId();
edcs.addAll(edcdao.findAllByDefinition(currentStudy, defId));
}
Map eventDefinitionDefaultVersions = new LinkedHashMap();
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = edcs.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());
StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) sedao.findByPK(edc.getStudyEventDefinitionId());
edc.setDefaultVersionName(defaultVersion.getName());
if (defaultVersion.getStatus().isAvailable()) {
List list = (ArrayList) eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
if (list == null)
list = new ArrayList();
list.add(defaultVersion);
eventDefinitionDefaultVersions.put(studyEventDefinitionBean, list);
}
}
// Whether IE6 or IE7 is involved
String isIE = fp.getString("ie");
if ("y".equalsIgnoreCase(isIE)) {
request.setAttribute("isInternetExplorer", "true");
}
SectionDAO sdao = new SectionDAO(sm.getDataSource());
CRFVersionDAO crfVersionDAO = new CRFVersionDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
Map sedCrfBeans = null;
for (Iterator it = eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
if (sedCrfBeans == null)
sedCrfBeans = new LinkedHashMap();
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) it.next();
List crfVersions = (ArrayList) eventDefinitionDefaultVersions.get(sedBean);
for (Iterator crfIt = crfVersions.iterator(); crfIt.hasNext(); ) {
CRFVersionBean crfVersionBean = (CRFVersionBean) crfIt.next();
allSectionBeans = new ArrayList<SectionBean>();
ArrayList sectionBeans = new ArrayList();
ItemGroupDAO itemGroupDao = new ItemGroupDAO(sm.getDataSource());
// Find truely grouped tables, not groups with a name of 'Ungrouped'
List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
CRFBean crfBean = crfDao.findByVersionId(crfVersionBean.getId());
if (itemGroupBeans.size() > 0) {
// get a DisplaySectionBean for each section of the CRF, sort
// them, then
// dispatch the request to a print JSP. The constructor for this
// handler takes
// a boolean value depending on whether data is involved or not
// ('false' in terms of this
// servlet; see PrintDataEntryServlet).
DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
handler.setCrfVersionId(crfVersionBean.getId());
// handler.setEventCRFId(eventCRFId);
List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
// Make available the CRF names and versions for
// the web page's header
CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
request.setAttribute("crfVersionBean", crfverBean);
request.setAttribute("crfBean", crfBean);
// Set an attribute signaling that data is not involved
request.setAttribute("dataInvolved", "false");
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setDisplaySectionBeans(displaySectionBeans);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setGrouped(true);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
continue;
}
ecb = new EventCRFBean();
ecb.setCRFVersionId(crfVersionBean.getId());
CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
for (int i = 0; i < sects.size(); i++) {
sb = (SectionBean) sects.get(i);
// super.sb = sb;
int sectId = sb.getId();
if (sectId > 0) {
allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
}
}
request.setAttribute(INPUT_EVENT_CRF, ecb);
request.setAttribute(SECTION_BEAN, sb);
request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
sectionBeans = super.getAllDisplayBeans(request);
DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setAllSections(sectionBeans);
printCrfBean.setDisplaySectionBean(dsb);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setGrouped(false);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
}
}
request.setAttribute("sedCrfBeans", sedCrfBeans);
request.setAttribute("studyName", currentStudy.getName());
forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT, request, response);
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class PrintCRFByIdServlet method processRequest.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.control.managestudy.ViewSectionDataEntryServlet#processRequest()
*/
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
StudyDAO studyDao = new StudyDAO(getDataSource());
currentStudy = (StudyBean) studyDao.findByPK(1);
CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
if (request.getParameter("id") == null) {
forwardPage(Page.LOGIN, request, response);
}
CRFVersionBean crfVersion = crfVersionDao.findByOid(request.getParameter("id"));
request.setAttribute("study", currentStudy);
if (crfVersion != null) {
request.setAttribute("id", String.valueOf(crfVersion.getId()));
super.processRequest(request, response);
} else {
forwardPage(Page.LOGIN, request, response);
}
}
Aggregations