Search in sources :

Example 51 with EventDefinitionCRFDAO

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

the class SDVUtil method setSDVStatusForStudySubjects.

public boolean setSDVStatusForStudySubjects(List<Integer> studySubjectIds, int userId, boolean setVerification) {
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    EventDefinitionCRFDAO eventDefinitionCrfDAO = new EventDefinitionCRFDAO(dataSource);
    StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
    CRFDAO crfDAO = new CRFDAO(dataSource);
    if (studySubjectIds == null || studySubjectIds.isEmpty()) {
        return true;
    }
    for (Integer studySubjectId : studySubjectIds) {
        ArrayList<EventCRFBean> eventCrfs = eventCRFDAO.getEventCRFsByStudySubjectCompleteOrLocked(studySubjectId);
        StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);
        for (EventCRFBean eventCRFBean : eventCrfs) {
            CRFBean crfBean = crfDAO.findByVersionId(eventCRFBean.getCRFVersionId());
            StudyEventBean studyEvent = (StudyEventBean) studyEventDAO.findByPK(eventCRFBean.getStudyEventId());
            EventDefinitionCRFBean eventDefinitionCrf = eventDefinitionCrfDAO.findByStudyEventDefinitionIdAndCRFIdAndStudyId(studyEvent.getStudyEventDefinitionId(), crfBean.getId(), studySubject.getStudyId());
            if (eventDefinitionCrf.getId() == 0) {
                eventDefinitionCrf = eventDefinitionCrfDAO.findForStudyByStudyEventDefinitionIdAndCRFId(studyEvent.getStudyEventDefinitionId(), crfBean.getId());
            }
            if (eventDefinitionCrf.getSourceDataVerification() == SourceDataVerification.AllREQUIRED || eventDefinitionCrf.getSourceDataVerification() == SourceDataVerification.PARTIALREQUIRED) {
                try {
                    eventCRFDAO.setSDVStatus(setVerification, userId, eventCRFBean.getId());
                } catch (Exception exc) {
                    //   System.out.println(exc.getMessage());
                    return false;
                }
            }
        }
        studySubjectDAO.update(studySubject);
    }
    return true;
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 52 with EventDefinitionCRFDAO

use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO 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;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 53 with EventDefinitionCRFDAO

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

the class ChangeDefinitionCRFOrdinalServlet method processRequest.

/**
     * Override processRequest in super class
     */
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int current = fp.getInt("current");
    int previous = fp.getInt("previous");
    int currOrdinal = fp.getInt("currentOrdinal");
    int prevOrdinal = fp.getInt("previousOrdinal");
    int definitionId = fp.getInt("id");
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    increase(current, previous, currOrdinal, prevOrdinal, definitionId, edcdao);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    int siteId = fp.getInt("siteId");
    if (siteId > 0) {
        request.setAttribute("idToSort", new Integer(definitionId).toString());
        request.setAttribute("siteId", siteId);
        forwardPage(Page.VIEW_SITE_SERVLET);
    } else {
        request.setAttribute("id", new Integer(definitionId).toString());
        forwardPage(Page.VIEW_EVENT_DEFINITION_SERVLET);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 54 with EventDefinitionCRFDAO

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

the class DataEntryServlet method getEventDefinitionCRFBean.

protected void getEventDefinitionCRFBean(HttpServletRequest request) {
    HttpSession session = request.getSession();
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    {
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
        StudyBean study = (StudyBean) session.getAttribute("study");
        edcb = edcdao.findByStudyEventIdAndCRFVersionId(study, ecb.getStudyEventId(), ecb.getCRFVersionId());
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HttpSession(javax.servlet.http.HttpSession) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 55 with EventDefinitionCRFDAO

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

the class StudyModuleController method handleMainPage.

@RequestMapping(method = RequestMethod.GET)
public ModelMap handleMainPage(HttpServletRequest request, HttpServletResponse response) {
    ModelMap map = new ModelMap();
    // Todo need something to reset panel from all the Spring Controllers
    StudyInfoPanel panel = new StudyInfoPanel();
    UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    panel.reset();
    request.getSession().setAttribute("panel", panel);
    // setUpSidebar(request);
    ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    eventDefinitionCRFDao = new EventDefinitionCRFDAO(dataSource);
    studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
    crfDao = new CRFDAO(dataSource);
    studyGroupClassDao = new StudyGroupClassDAO(dataSource);
    studyDao = new StudyDAO(dataSource);
    userDao = new UserAccountDAO(dataSource);
    ruleDao = new RuleDAO(dataSource);
    StudyModuleStatus sms = studyModuleStatusDao.findByStudyId(currentStudy.getId());
    if (sms == null) {
        sms = new StudyModuleStatus();
        sms.setStudyId(currentStudy.getId());
    }
    int crfCount = crfDao.findAllByStudy(currentStudy.getId()).size();
    int crfWithEventDefinition = crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
    int totalCrf = crfCount + crfWithEventDefinition;
    // int eventDefinitionCount = eventDefinitionCRFDao.findAllActiveByStudy(currentStudy).size();
    int eventDefinitionCount = studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
    int subjectGroupCount = studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
    // List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByStudy(currentStudy);
    // ruleSets = ruleSetService.filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets);
    int ruleCount = ruleSetService.getCountByStudy(currentStudy);
    int siteCount = studyDao.findOlnySiteIdsByStudy(currentStudy).size();
    int userCount = userDao.findAllUsersByStudy(currentStudy.getId()).size();
    Collection childStudies = studyDao.findAllByParent(currentStudy.getId());
    Map childStudyUserCount = new HashMap();
    for (Object sb : childStudies) {
        StudyBean childStudy = (StudyBean) sb;
        childStudyUserCount.put(childStudy.getName(), userDao.findAllUsersByStudy(childStudy.getId()).size());
    }
    if (sms.getCrf() == 0) {
        sms.setCrf(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getCrf() != 3 && totalCrf > 0) {
        sms.setCrf(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getEventDefinition() == 0) {
        sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
        sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSubjectGroup() == 0) {
        sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
        sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getRule() == 0) {
        sms.setRule(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getRule() != 3 && ruleCount > 0) {
        sms.setRule(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSite() == 0) {
        sms.setSite(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSite() != 3 && siteCount > 0) {
        sms.setSite(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getUsers() == 0) {
        sms.setUsers(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getUsers() != 3 && userCount > 0) {
        sms.setUsers(StudyModuleStatus.IN_PROGRESS);
    }
    map.addAttribute(sms);
    map.addAttribute("crfCount", totalCrf);
    map.addAttribute("eventDefinitionCount", eventDefinitionCount);
    map.addAttribute("subjectGroupCount", subjectGroupCount);
    map.addAttribute("ruleCount", ruleCount);
    map.addAttribute("siteCount", siteCount);
    map.addAttribute("userCount", userCount);
    map.addAttribute("childStudyUserCount", childStudyUserCount);
    map.addAttribute("studyId", currentStudy.getId());
    map.addAttribute("currentStudy", currentStudy);
    // Load Participate registration information
    String portalURL = CoreResources.getField("portalURL");
    map.addAttribute("portalURL", portalURL);
    if (portalURL != null && !portalURL.equals("")) {
        String participateOCStatus = currentStudy.getStudyParameterConfig().getParticipantPortal();
        ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
        Authorization pManageAuthorization = registrar.getAuthorization(currentStudy.getOid());
        String participateStatus = "";
        String url = "";
        try {
            URL pManageUrl = new URL(portalURL);
            if (pManageAuthorization != null && pManageAuthorization.getAuthorizationStatus() != null && pManageAuthorization.getAuthorizationStatus().getStatus() != null)
                participateStatus = pManageAuthorization.getAuthorizationStatus().getStatus();
            map.addAttribute("participateURL", pManageUrl);
            map.addAttribute("participateOCStatus", participateOCStatus);
            map.addAttribute("participateStatus", participateStatus);
            if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
                url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
            }
        } catch (MalformedURLException e) {
            logger.error(e.getMessage());
            logger.error(ExceptionUtils.getStackTrace(e));
        }
        map.addAttribute("participateURLDisplay", url);
        map.addAttribute("participateURLFull", url + "/#/login");
    }
    // Load Randomization  information
    String moduleManager = CoreResources.getField("moduleManager");
    map.addAttribute("moduleManager", moduleManager);
    if (moduleManager != null && !moduleManager.equals("")) {
        String randomizationOCStatus = currentStudy.getStudyParameterConfig().getRandomization();
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO randomization = null;
        try {
            randomization = randomizationRegistrar.getCachedRandomizationDTOObject(currentStudy.getOid(), true);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        String randomizationStatus = "";
        URL randomizeUrl = null;
        if (randomization != null && randomization.getStatus() != null) {
            randomizationStatus = randomization.getStatus();
            if (randomization.getUrl() != null) {
                try {
                    randomizeUrl = new URL(randomization.getUrl());
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        map.addAttribute("randomizeURL", randomizeUrl);
        map.addAttribute("randomizationOCStatus", randomizationOCStatus);
        map.addAttribute("randomizationStatus", randomizationStatus);
    }
    // @pgawade 13-April-2011- #8877: Added the rule designer URL
    if (null != coreResources) {
        map.addAttribute("ruleDesignerURL", coreResources.getField("designer.url"));
        map.addAttribute("contextPath", getContextPath(request));
        logMe("before checking getHostPath url = " + request.getRequestURL());
        // JN: for the eclinicalhosting the https is not showing up in the request path, going for a fix of taking
        // the hostpath from sysurl
        // map.addAttribute("hostPath", getHostPath(request));
        map.addAttribute("hostPath", getHostPathFromSysUrl(coreResources.getField("sysURL.base"), request.getContextPath()));
        map.addAttribute("path", "pages/studymodule");
    }
    // UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    request.setAttribute("userBean", userBean);
    ArrayList statusMap = Status.toStudyUpdateMembersList();
    // statusMap.add(Status.PENDING);
    request.setAttribute("statusMap", statusMap);
    if (currentStudy.getParentStudyId() > 0) {
        StudyBean parentStudy = (StudyBean) studyDao.findByPK(currentStudy.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    }
    ArrayList pageMessages = new ArrayList();
    if (request.getSession().getAttribute("pageMessages") != null) {
        pageMessages.addAll((ArrayList) request.getSession().getAttribute("pageMessages"));
        request.setAttribute("pageMessages", pageMessages);
        request.getSession().removeAttribute("pageMessages");
    }
    ArrayList regMessages = new ArrayList();
    if (request.getSession().getAttribute(REG_MESSAGE) != null) {
        regMessages.addAll((ArrayList) request.getSession().getAttribute(REG_MESSAGE));
        request.setAttribute(REG_MESSAGE, regMessages);
        request.getSession().removeAttribute(REG_MESSAGE);
    }
    return map;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) ArrayList(java.util.ArrayList) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel) URL(java.net.URL) RuleDAO(org.akaza.openclinica.dao.rule.RuleDAO) Authorization(org.akaza.openclinica.service.pmanage.Authorization) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyModuleStatus(org.akaza.openclinica.domain.managestudy.StudyModuleStatus) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) Collection(java.util.Collection) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)84 ArrayList (java.util.ArrayList)72 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)58 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)53 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)45 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)41 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)41 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)39 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)39 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)36 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)35 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)30 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)28 Date (java.util.Date)27 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)27 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26