Search in sources :

Example 51 with SectionBean

use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.

the class PrintCRFServlet method processRequest.

@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // The PrintDataEntry servlet handles this parameter
    int eventCRFId = fp.getInt("ecId");
    //JN:The following were the the global variables, moved as local.
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
    // Whether IE6 or IE7 is involved
    String isIE = fp.getString("ie");
    if ("y".equalsIgnoreCase(isIE)) {
        request.setAttribute("isInternetExplorer", "true");
    }
    int eventDefinitionCRFId = fp.getInt("eventDefinitionCRFId");
    // EventDefinitionCRFDao findByStudyEventIdAndCRFVersionId(int
    // studyEventId, int crfVersionId)
    SectionDAO sdao = new SectionDAO(getDataSource());
    CRFVersionDAO crfVersionDAO = new CRFVersionDAO(getDataSource());
    CRFDAO crfDao = new CRFDAO(getDataSource());
    ArrayList<SectionBean> allSectionBeans = new ArrayList<SectionBean>();
    ArrayList sectionBeans = new ArrayList();
    // The existing application doesn't print null values, even if they are
    // defined in the event definition
    int crfVersionId = fp.getInt("id", true);
    boolean isSubmitted = false;
    if (crfVersionId == 0) {
        addPageMessage(respage.getString("please_choose_a_crf_to_view_details"), request);
        forwardPage(Page.CRF_LIST_SERVLET, request, response);
    } else {
        // BWP 2/7/2008>> Find out if the CRF has grouped tables, and if so,
        // use
        // that dedicated JSP
        ItemGroupDAO itemGroupDao = new ItemGroupDAO(getDataSource());
        // Find truely grouped tables, not groups with a name of 'Ungrouped'
        List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionId);
        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(crfVersionId);
            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(crfVersionId);
            request.setAttribute("crfVersionBean", crfverBean);
            CRFBean crfBean = crfDao.findByVersionId(crfVersionId);
            request.setAttribute("crfBean", crfBean);
            // Set an attribute signaling that data is not involved
            request.setAttribute("dataInvolved", "false");
            // request.setAttribute("displaySection",displaySection);
            forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PRINT_GROUPS, request, response);
            // IllegalStateException
            return;
        }
        //JN:Revisit ME
        ecb = new EventCRFBean();
        ecb.setCRFVersionId(crfVersionId);
        CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionId);
        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(ALL_SECTION_BEANS, allSectionBeans);
        request.setAttribute(INPUT_EVENT_CRF, ecb);
        sectionBeans = super.getAllDisplayBeans(request);
    }
    request.setAttribute(INPUT_EVENT_CRF, ecb);
    request.setAttribute(SECTION_BEAN, sb);
    DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
    request.setAttribute("allSections", sectionBeans);
    request.setAttribute("displayAllCRF", "1");
    request.setAttribute(BEAN_DISPLAY, dsb);
    request.setAttribute(BEAN_ANNOTATIONS, ecb.getAnnotations());
    request.setAttribute("sec", sb);
    request.setAttribute("EventCRFBean", ecb);
    forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PRINT, request, response);
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) 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) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO) DisplaySectionBeanHandler(org.akaza.openclinica.view.display.DisplaySectionBeanHandler)

Example 52 with SectionBean

use of org.akaza.openclinica.bean.submit.SectionBean 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 53 with SectionBean

use of org.akaza.openclinica.bean.submit.SectionBean 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 54 with SectionBean

use of org.akaza.openclinica.bean.submit.SectionBean 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 55 with SectionBean

use of org.akaza.openclinica.bean.submit.SectionBean 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)

Aggregations

SectionBean (org.akaza.openclinica.bean.submit.SectionBean)63 ArrayList (java.util.ArrayList)49 SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)35 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)33 HashMap (java.util.HashMap)28 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)28 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)22 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)20 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)20 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)19 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)17 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)16 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)15 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)15 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)15 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)15 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)14 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)14 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)14