Search in sources :

Example 31 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method prepareItemdataOrdinals.

protected HashMap<Integer, TreeSet<Integer>> prepareItemdataOrdinals(HttpServletRequest request) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    HashMap<Integer, TreeSet<Integer>> ordinals = new HashMap<Integer, TreeSet<Integer>>();
    SectionDAO sdao = new SectionDAO(getDataSource());
    ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    for (SectionBean section : sbs) {
        ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(section.getId(), ecb.getId());
        if (idbs != null && idbs.size() > 0) {
            for (ItemDataBean idb : idbs) {
                int itemId = idb.getItemId();
                TreeSet<Integer> os = new TreeSet<Integer>();
                if (ordinals == null) {
                    os.add(idb.getOrdinal());
                    ordinals.put(itemId, os);
                } else if (ordinals.containsKey(itemId)) {
                    os = ordinals.get(itemId);
                    os.add(idb.getOrdinal());
                    ordinals.put(itemId, os);
                } else {
                    os.add(idb.getOrdinal());
                    ordinals.put(itemId, os);
                }
            }
        }
    }
    return ordinals;
}
Also used : HashMap(java.util.HashMap) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) TreeSet(java.util.TreeSet) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 32 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method getAllDisplayBeans.

/**
     * Retrieve the DisplaySectionBean which will be used to display the Event CRF Section on the JSP, and also is used to controll processRequest.
     * @param request TODO
     */
protected ArrayList getAllDisplayBeans(HttpServletRequest request) throws Exception {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    ArrayList sections = new ArrayList();
    HttpSession session = request.getSession();
    StudyBean study = (StudyBean) session.getAttribute("study");
    SectionDAO sdao = new SectionDAO(getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    // ALL_SECTION_BEANS
    ArrayList<SectionBean> allSectionBeans = (ArrayList<SectionBean>) request.getAttribute(ALL_SECTION_BEANS);
    for (int j = 0; j < allSectionBeans.size(); j++) {
        SectionBean sb = allSectionBeans.get(j);
        DisplaySectionBean section = new DisplaySectionBean();
        section.setEventCRF(ecb);
        if (sb.getParentId() > 0) {
            SectionBean parent = (SectionBean) sdao.findByPK(sb.getParentId());
            sb.setParent(parent);
        }
        section.setSection(sb);
        CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
        section.setCrfVersion(cvb);
        CRFDAO cdao = new CRFDAO(getDataSource());
        CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
        section.setCrf(cb);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
        EventDefinitionCRFBean edcb = edcdao.findByStudyEventIdAndCRFVersionId(study, ecb.getStudyEventId(), cvb.getId());
        section.setEventDefinitionCRF(edcb);
        // setup DAO's here to avoid creating too many objects
        ItemDAO idao = new ItemDAO(getDataSource());
        ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
        iddao = new ItemDataDAO(getDataSource(), locale);
        // get all the display item beans
        ArrayList displayItems = getParentDisplayItems(false, sb, edcb, idao, ifmdao, iddao, false, request);
        LOGGER.debug("222 just ran get parent display, has group " + " FALSE has ungrouped FALSE");
        // now sort them by ordinal
        Collections.sort(displayItems);
        // now get the child DisplayItemBeans
        for (int i = 0; i < displayItems.size(); i++) {
            DisplayItemBean dib = (DisplayItemBean) displayItems.get(i);
            dib.setChildren(getChildrenDisplayItems(dib, edcb, request));
            if (shouldLoadDBValues(dib)) {
                LOGGER.trace("should load db values is true, set value");
                dib.loadDBValue();
            }
            displayItems.set(i, dib);
        }
        section.setItems(displayItems);
        sections.add(section);
    }
    return sections;
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HttpSession(javax.servlet.http.HttpSession) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 33 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DoubleDataEntryServlet method mayProceed.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#mayProceed()
     */
@Override
protected void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
    checkStudyLocked(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_locked"), request, response);
    checkStudyFrozen(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_frozen"), request, response);
    UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
    StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
    HttpSession session = request.getSession();
    locale = LocaleResolver.getLocale(request);
    // < respage =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
    // locale);
    // < restext =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
    // <
    // resexception=ResourceBundle.getBundle(
    // "org.akaza.openclinica.i18n.exceptions",locale);
    // < resword =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
    getInputBeans(request);
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    FormProcessor fp = new FormProcessor(request);
    SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
    // BWP 12/2/07>> The following COUNT_VALIDATE session attribute is not
    // accessible,
    // for unknown reasons (threading problems?), when
    // double-data entry displays error messages; it's value is always 0; so
    // I have to create my
    // own session variable here to keep track of DDE stages
    // We'll go by the SectionBean's ordinal first
    int tabNumber = 1;
    if (sb != null) {
        tabNumber = sb.getOrdinal();
    }
    // if tabNumber still isn't valid, check the "tab" parameter
    if (tabNumber < 1) {
        if (fp == null) {
            fp = new FormProcessor(request);
        }
        String tab = fp.getString("tab");
        if (tab == null || tab.length() < 1) {
            tabNumber = 1;
        } else {
            tabNumber = fp.getInt("tab");
        }
    }
    SectionDAO sectionDao = new SectionDAO(getDataSource());
    int crfVersionId = ecb.getCRFVersionId();
    int eventCRFId = ecb.getId();
    ArrayList sections = sectionDao.findAllByCRFVersionId(crfVersionId);
    int sectionSize = sections.size();
    HttpSession mySession = request.getSession();
    DoubleDataProgress doubleDataProgress = (DoubleDataProgress) mySession.getAttribute(DDE_PROGESS);
    if (doubleDataProgress == null || doubleDataProgress.getEventCRFId() != eventCRFId) {
        doubleDataProgress = new DoubleDataProgress(sectionSize, eventCRFId);
        mySession.setAttribute(DDE_PROGESS, doubleDataProgress);
    }
    boolean hasVisitedSection = doubleDataProgress.getSectionVisited(tabNumber, eventCRFId);
    // setting up one-time validation here
    // admit that it's an odd place to put it, but where else?
    // placing it in dataentryservlet is creating too many counts
    int keyId = ecb.getId();
    Integer count = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);
    if (count != null) {
        count++;
        session.setAttribute(COUNT_VALIDATE + keyId, count);
        LOGGER.info("^^^just set count to session: " + count);
    } else {
        count = 0;
        session.setAttribute(COUNT_VALIDATE + keyId, count);
        LOGGER.info("***count not found, set to session: " + count);
    }
    DataEntryStage stage = ecb.getStage();
    if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) && !hasVisitedSection) {
        // if the user has not entered this section yet in Double Data
        // Entry, then
        // set a flag that default values should be shown in the form
        request.setAttribute(DDE_ENTERED, true);
    }
    // Now update the session attribute
    doubleDataProgress.setSectionVisited(eventCRFId, tabNumber, true);
    mySession.setAttribute("doubleDataProgress", doubleDataProgress);
    // StudyEventStatus status =
    Role r = currentRole.getRole();
    session.setAttribute("mayProcessUploading", "true");
    return;
}
Also used : HttpSession(javax.servlet.http.HttpSession) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) ArrayList(java.util.ArrayList) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage) Role(org.akaza.openclinica.bean.core.Role) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 34 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method prepareGroupSizes.

protected HashMap<Integer, Integer> prepareGroupSizes(HashMap<String, ItemBean> scoreItems, HttpServletRequest request) {
    HashMap<Integer, Integer> groupSizes = new HashMap<Integer, Integer>();
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    SectionDAO sdao = new SectionDAO(getDataSource());
    Iterator iter = scoreItems.keySet().iterator();
    while (iter.hasNext()) {
        int itemId = scoreItems.get(iter.next().toString()).getId();
        groupSizes.put(itemId, 1);
    }
    ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
    for (SectionBean section : sbs) {
        ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(section.getId(), ecb.getId());
        for (ItemDataBean idb : idbs) {
            int itemId = idb.getItemId();
            if (groupSizes != null && groupSizes.containsKey(itemId)) {
                int groupsize = iddao.getGroupSize(itemId, ecb.getId());
                groupsize = groupsize > 0 ? groupsize : 1;
                groupSizes.put(itemId, groupsize);
            }
        }
    }
    return groupSizes;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) Iterator(java.util.Iterator) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 35 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class OpenRosaXmlGenerator method getSectionBean.

private SectionBean getSectionBean(Integer ID) {
    sdao = new SectionDAO(dataSource);
    SectionBean sBean = (SectionBean) sdao.findByPK(ID);
    return sBean;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Aggregations

SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)40 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)35 ArrayList (java.util.ArrayList)31 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)28 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)19 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)18 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)18 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)17 HashMap (java.util.HashMap)16 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)14 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)14 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)14 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)13 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)12 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)12 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)11 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)11 ItemGroupDAO (org.akaza.openclinica.dao.submit.ItemGroupDAO)11 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)10