Search in sources :

Example 61 with SectionBean

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

the class TableOfContentsServlet method sectionIdsInToc.

public static LinkedList<Integer> sectionIdsInToc(DisplayTableOfContentsBean toc) {
    LinkedList<Integer> ids = new LinkedList<Integer>();
    if (toc != null) {
        ArrayList<SectionBean> sectionBeans = toc.getSections();
        if (sectionBeans != null && sectionBeans.size() > 0) {
            for (int i = 0; i < sectionBeans.size(); ++i) {
                SectionBean s = sectionBeans.get(i);
                ids.add(s.getId());
            }
        }
    }
    return ids;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) LinkedList(java.util.LinkedList)

Example 62 with SectionBean

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

the class TableOfContentsServlet method getDisplayBeanWithShownSections.

/**
     * A section contains all hidden dynamics will be removed from data entry tab and jump box.
     *
     * @param ds
     * @param displayTableOfContentsBean
     * @param dynamicsMetadataService
     * @return
     */
public static DisplayTableOfContentsBean getDisplayBeanWithShownSections(DataSource ds, DisplayTableOfContentsBean displayTableOfContentsBean, DynamicsMetadataService dynamicsMetadataService) {
    if (displayTableOfContentsBean == null) {
        return displayTableOfContentsBean;
    }
    EventCRFBean ecb = displayTableOfContentsBean.getEventCRF();
    SectionDAO sectionDAO = new SectionDAO(ds);
    ArrayList<SectionBean> sectionBeans = getSections(ecb, ds);
    ArrayList<SectionBean> showSections = new ArrayList<SectionBean>();
    if (sectionBeans != null && sectionBeans.size() > 0) {
        for (SectionBean s : sectionBeans) {
            if (sectionDAO.containNormalItem(s.getCRFVersionId(), s.getId())) {
                showSections.add(s);
            } else {
                //for section contains dynamics, does it contain showing item_group/item?
                if (dynamicsMetadataService.hasShowingDynGroupInSection(s.getId(), s.getCRFVersionId(), ecb.getId())) {
                    showSections.add(s);
                } else {
                    if (dynamicsMetadataService.hasShowingDynItemInSection(s.getId(), s.getCRFVersionId(), ecb.getId())) {
                        showSections.add(s);
                    }
                }
            }
        }
        displayTableOfContentsBean.setSections(showSections);
    }
    return displayTableOfContentsBean;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 63 with SectionBean

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

the class FormBeanUtil method createDisplaySectionBWithFormGroupsForPrint.

public DisplaySectionBean createDisplaySectionBWithFormGroupsForPrint(int sectionId, int crfVersionId, DataSource dataSource, int eventCRFDefId, EventCRFBean eventCrfBean, ServletContext context) {
    DisplaySectionBean displaySectionBean = new DisplaySectionBean();
    ItemGroupDAO formGroupDAO = new ItemGroupDAO(dataSource);
    ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(dataSource);
    ItemDAO itemDao = new ItemDAO(dataSource);
    ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(dataSource);
    SectionDAO sectionDao = new SectionDAO(dataSource);
    // Give the DisplaySectionBean a legitimate SectionBean
    SectionBean secBean = (SectionBean) sectionDao.findByPK(sectionId);
    displaySectionBean.setSection(secBean);
    // changed from: findGroupBySectionId
    List<ItemGroupBean> itemGroupBeans = formGroupDAO.findLegitGroupAllBySectionId(sectionId);
    // all items associated with the section, including those not in a group
    List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
    try {
        allMetas = metaDao.findAllBySectionId(sectionId);
    } catch (OpenClinicaException oce) {
        logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
    }
    // Sort these items according to their position on the CRF; their
    // ordinal
    Collections.sort(allMetas);
    // The DisplayItemGroupBean(s) for "nongrouped" items
    List<DisplayItemGroupBean> nonGroupBeans = null;
    // if(itemGroupBeans.isEmpty()) return displaySectionBean;
    // Find out whether there are any checkboxes/radios/select elements
    // and if so, get any null values
    // associated with them
    List<String> nullValuesList = new ArrayList<String>();
    boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
    if (itemsHaveChecksRadios && eventCRFDefId > 0) {
        // method returns null values as a List<String>
        nullValuesList = this.getNullValuesByEventCRFDefId(eventCRFDefId, dataSource);
    }
    // Get the items associated with each group
    List<ItemBean> itBeans;
    List<DisplayItemBean> displayItems;
    List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
    DisplayItemGroupBean displayItemGBean;
    for (ItemGroupBean itemGroup : itemGroupBeans) {
        //TODO:fix me!
        itBeans = itemDao.findAllItemsByGroupIdForPrint(itemGroup.getId(), crfVersionId, sectionId);
        logger.debug("just ran find all by group id " + itemGroup.getId() + " found " + itBeans.size() + " item beans");
        //TODO:fix me add item_form_metadata.section_id to the query
        List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSectionForPrint(itemGroup.getId(), crfVersionId, sectionId);
        if (!metadata.isEmpty()) {
            // for a given crf version, all the items in the same group
            // have the same group metadata info
            // so we can get one of the metadata and set the metadata for
            // the group
            ItemGroupMetadataBean meta = metadata.get(0);
            itemGroup.setMeta(meta);
        }
        displayItems = getDisplayBeansFromItemsForPrint(itBeans, dataSource, eventCrfBean, sectionId, nullValuesList, context, crfVersionId);
        displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
        displayFormBeans.add(displayItemGBean);
    }
    // We still have to sort these display item group beans on their
    // ItemGroupMetadataBean?
    // then number their ordinals accordingly
    Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {

        public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
            return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
        }
    });
    // Now provide the display item group beans with an ordinal
    int digOrdinal = 0;
    for (DisplayItemGroupBean digBean : displayFormBeans) {
        digBean.setOrdinal(++digOrdinal);
    }
    // find out whether there are any ungrouped items by comparing the
    // number of
    // grouped items to allMetas.size()
    // List<DisplayItemGroupBean> nonGroupBeans=null;
    int tempCount = 0;
    for (DisplayItemGroupBean groupBean : displayFormBeans) {
        tempCount += groupBean.getItems().size();
    }
    if (tempCount < allMetas.size()) {
        nonGroupBeans = createGroupBeansForNongroupedItems(allMetas, displayFormBeans, sectionId, dataSource, nullValuesList, eventCrfBean, context);
    }
    if (nonGroupBeans != null) {
        displayFormBeans.addAll(nonGroupBeans);
    }
    // sort the list according to the ordinal of the contained
    // DisplayItemGroupBeans
    Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {

        public int compare(DisplayItemGroupBean disFormGroupBean, DisplayItemGroupBean disFormGroupBean1) {
            Integer compInt = disFormGroupBean1.getOrdinal();
            Integer compInt2 = disFormGroupBean.getOrdinal();
            return compInt2.compareTo(compInt);
        }
    });
    displaySectionBean.setDisplayFormGroups(displayFormBeans);
    return displaySectionBean;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) ArrayList(java.util.ArrayList) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) ItemGroupMetadataDAO(org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean) 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