Search in sources :

Example 81 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class ViewStudyUserServlet method processRequest.

@Override
public void processRequest() throws Exception {
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    String name = request.getParameter("name");
    String studyIdString = request.getParameter("studyId");
    // if(request.getParameter("submit")!=null)
    {
        if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
            addPageMessage(respage.getString("please_choose_a_user_to_view"));
            forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
        } else {
            int studyId = Integer.valueOf(studyIdString.trim()).intValue();
            UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
            request.setAttribute("user", user);
            StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
            request.setAttribute("uRole", uRole);
            StudyDAO sdao = new StudyDAO(sm.getDataSource());
            StudyBean study = (StudyBean) sdao.findByPK(studyId);
            request.setAttribute("uStudy", study);
            request.setAttribute("siteRoleMap", Role.siteRoleMap);
            // BWP 12/7/07 >>To provide the view with the correct date format
            // pattern, locale sensitive
            String pattn = "";
            pattn = ResourceBundleProvider.getFormatBundle().getString("date_format_string");
            request.setAttribute("dateFormatPattern", pattn);
            request.setAttribute("action", "");
            forwardPage(Page.VIEW_USER_IN_STUDY);
        }
    }
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 82 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class UpdateStudyServletNew method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    int studyId = fp.getInt("id");
    studyId = studyId == 0 ? fp.getInt("studyId") : studyId;
    String action = fp.getString("action");
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    boolean isInterventional = false;
    study = (StudyBean) sdao.findByPK(studyId);
    if (study.getId() != currentStudy.getId()) {
        addPageMessage(respage.getString("not_current_study") + respage.getString("change_study_contact_sysadmin"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    study.setId(studyId);
    StudyConfigService scs = new StudyConfigService(sm.getDataSource());
    study = scs.setParametersForStudy(study);
    request.setAttribute("studyToView", study);
    request.setAttribute("studyId", studyId + "");
    request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
    ArrayList statuses = Status.toStudyUpdateMembersList();
    statuses.add(Status.PENDING);
    request.setAttribute("statuses", statuses);
    String interventional = resadmin.getString("interventional");
    isInterventional = interventional.equalsIgnoreCase(study.getProtocolType());
    request.setAttribute("isInterventional", isInterventional ? "1" : "0");
    String protocolType = study.getProtocolTypeKey();
    // A. Hamid. 5001
    if (study.getParentStudyId() > 0) {
        StudyBean parentStudy = (StudyBean) sdao.findByPK(study.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    }
    ArrayList interventionArray = new ArrayList();
    if (isInterventional) {
        interventionArray = parseInterventions(study);
        setMaps(isInterventional, interventionArray);
    } else {
        setMaps(isInterventional, interventionArray);
    }
    if (!action.equals("submit")) {
        // First Load First Form
        if (study.getDatePlannedStart() != null) {
            fp.addPresetValue(INPUT_START_DATE, local_df.format(study.getDatePlannedStart()));
        }
        if (study.getDatePlannedEnd() != null) {
            fp.addPresetValue(INPUT_END_DATE, local_df.format(study.getDatePlannedEnd()));
        }
        if (study.getProtocolDateVerification() != null) {
            fp.addPresetValue(INPUT_VER_DATE, local_df.format(study.getProtocolDateVerification()));
        }
        setPresetValues(fp.getPresetValues());
    // first load 2nd form
    }
    if (study == null) {
        addPageMessage(respage.getString("please_choose_a_study_to_edit"));
        forwardPage(Page.STUDY_LIST_SERVLET);
        return;
    }
    if (action.equals("submit")) {
        validateStudy1(fp, v);
        validateStudy2(fp, new Validator(request));
        validateStudy3(isInterventional, new Validator(request), fp);
        validateStudy4(fp, new Validator(request));
        validateStudy5(fp, new Validator(request));
        validateStudy6(fp, new Validator(request));
        confirmWholeStudy(fp);
        request.setAttribute("studyToView", study);
        if (!errors.isEmpty()) {
            logger.error("found errors : " + errors.toString());
            request.setAttribute("formMessages", errors);
            forwardPage(Page.UPDATE_STUDY_NEW);
        } else {
            study.setProtocolType(protocolType);
            submitStudy(study);
            addPageMessage(respage.getString("the_study_has_been_updated_succesfully"));
            ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
            session.setAttribute("pageMessages", pageMessages);
            response.sendRedirect(request.getContextPath() + "/pages/studymodule");
        // forwardPage(Page.MANAGE_STUDY_MODULE);
        }
    } else {
        forwardPage(Page.UPDATE_STUDY_NEW);
    }
}
Also used : StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Validator(org.akaza.openclinica.control.form.Validator)

Example 83 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class UpdateSubStudyServlet method submitStudy.

/**
 * Inserts the new study into databa *
 * @throws MalformedURLException *
 */
private void submitStudy() throws MalformedURLException {
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) session.getAttribute("newStudy");
    ArrayList parameters = study.getStudyParameters();
    /*
         * logger.info("study bean to be updated:\n");
         * logger.info(study.getName()+ "\n" + study.getCreatedDate() + "\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.setCreatedDate(new Date());
    study.setUpdatedDate(new Date());
    study.setUpdater(ub);
    sdao.update(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();
        StudyParameterValueBean spv1 = spvdao.findByHandleAndStudy(spv.getStudyId(), spv.getParameter());
        if (spv1.getId() > 0) {
            spv = (StudyParameterValueBean) spvdao.update(spv);
        } else {
            spv = (StudyParameterValueBean) spvdao.create(spv);
        }
    // spv = (StudyParameterValueBean)spvdao.update(config.getValue());
    }
    submitSiteEventDefinitions(study);
    // session.removeAttribute("newStudy");
    // session.removeAttribute("parentName");
    // session.removeAttribute("definitions");
    // session.removeAttribute("sdvOptions");
    addPageMessage(respage.getString("the_site_has_been_updated_succesfully"));
    String fromListSite = (String) session.getAttribute("fromListSite");
    if (fromListSite != null && fromListSite.equals("yes")) {
        // session.removeAttribute("fromListSite");
        forwardPage(Page.SITE_LIST_SERVLET);
    } else {
        // session.removeAttribute("fromListSite");
        forwardPage(Page.STUDY_LIST_SERVLET);
    }
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Example 84 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class ViewSectionDataEntryByIdServlet method processRequest.

/*
     * (non-Javadoc)
     * @see org.akaza.openclinica.control.managestudy.ViewSectionDataEntryServlet#processRequest()
     */
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    StudyDAO studyDao = new StudyDAO(getDataSource());
    StudyBean currentStudy = (StudyBean) studyDao.findByPK(1);
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
    if (request.getParameter("id") == null) {
        forwardPage(Page.LOGIN, request, response);
    }
    request.setAttribute("study", currentStudy);
    CRFVersionBean crfVersion = crfVersionDao.findByOid(request.getParameter("id"));
    if (crfVersion != null) {
        request.setAttribute("crfVersionId", String.valueOf(crfVersion.getId()));
        request.setAttribute("crfId", String.valueOf(crfVersion.getCrfId()));
        super.processRequest(request, response);
    } else {
        forwardPage(Page.LOGIN, request, response);
    }
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 85 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class CreateDiscrepancyNoteServlet method generateUserAccounts.

private ArrayList generateUserAccounts(int studyId, int subjectId) {
    UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    StudyBean subjectStudy = studyDAO.findByStudySubjectId(subjectId);
    // study id, tbh 03/2009
    ArrayList userAccounts = new ArrayList();
    if (currentStudy.getParentStudyId() > 0) {
        userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, currentStudy.getParentStudyId(), subjectId);
    } else if (subjectStudy.getParentStudyId() > 0) {
        userAccounts = userAccountDAO.findAllUsersByStudyOrSite(subjectStudy.getId(), subjectStudy.getParentStudyId(), subjectId);
    } else {
        userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, 0, subjectId);
    }
    return userAccounts;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)205 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)184 ArrayList (java.util.ArrayList)116 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)73 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)59 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)50 Date (java.util.Date)49 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)49 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)47 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)43 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)43 HashMap (java.util.HashMap)42 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)39 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)35 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)34 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)30