Search in sources :

Example 56 with DisplayItemBean

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

the class PrintEventCRFServlet method validateDisplayItemBean.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.submit.DataEntryServlet#validateDisplayItemBean(org.akaza.openclinica.core.form.Validator,
     *      org.akaza.openclinica.bean.submit.DisplayItemBean)
     */
@Override
protected DisplayItemBean validateDisplayItemBean(DiscrepancyValidator v, DisplayItemBean dib, String inputName, HttpServletRequest request) {
    ItemBean ib = dib.getItem();
    org.akaza.openclinica.bean.core.ResponseType rt = dib.getMetadata().getResponseSet().getResponseType();
    // note that this step sets us up both for
    // displaying the data on the form again, in the event of an error
    // and sending the data to the database, in the event of no error
    dib = loadFormValue(dib, request);
    // types TEL and ED are not supported yet
    if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXT) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXTAREA)) {
        dib = validateDisplayItemBeanText(v, dib, inputName, request);
    } else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.RADIO) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECT)) {
        dib = validateDisplayItemBeanSingleCV(v, dib, inputName);
    } else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {
        dib = validateDisplayItemBeanMultipleCV(v, dib, inputName);
    } else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CALCULATION) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.GROUP_CALCULATION)) {
        // for now, treat calculation like any other text input --
        // eventually this might need to be customized
        dib = validateDisplayItemBeanText(v, dib, inputName, request);
    }
    return dib;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean)

Example 57 with DisplayItemBean

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

the class DataEntryServlet method buildMatrixForRepeatingGroups.

//@pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb, DisplayItemGroupBean itemGroup, EventCRFBean ecb, SectionBean sb, List<ItemBean> itBeans, Map<String, ItemDataBean> dataMap, List<String> nullValuesList, boolean isSubmitted) {
    int tempOrdinal = 1;
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    int maxOrdinal = iddao.getMaxOrdinalForGroup(ecb, sb, itemGroup.getItemGroupBean());
    //Incase of no data
    if (maxOrdinal == 0)
        maxOrdinal = 1;
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO<String, ArrayList>(getDataSource());
    List<DisplayItemGroupBean> itemGroups = new ArrayList<DisplayItemGroupBean>();
    boolean groupHasData = false;
    for (int i = 1; i <= maxOrdinal; i++) {
        List<DisplayItemBean> displayItemBeans = new ArrayList<DisplayItemBean>();
        DisplayItemGroupBean dig = new DisplayItemGroupBean();
        for (ItemBean itBean : itBeans) {
            DisplayItemBean displayItemBean = new DisplayItemBean();
            ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(itBean.getId(), ecb.getCRFVersionId());
            // itBean.setItemMeta(ifm);//TODO:remove this or the one down displayItemBean.setMetadata(ifm);
            displayItemBean.setMetadata(ifm);
            displayItemBean.setItem(itBean);
            ItemDataBean itemData = dataMap.get(itBean.getId() + "," + i);
            if (itemData != null) {
                //to indicate any item in the group has data;
                groupHasData = true;
                displayItemBean.setIsNewItem(false);
            }
            if (itemData == null) {
                itemData = displayItemBean.getData();
                itemData.setValue("");
                itemData.setOrdinal(i);
            }
            addNullValues(displayItemBean, nullValuesList);
            displayItemBean.setData(itemData);
            //                displayItemBean.loadDBValue();
            if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
                if (shouldLoadDBValues(displayItemBean) && !isSubmitted) {
                    displayItemBean.loadDBValue();
                }
            } else {
                if (shouldLoadDBValues(displayItemBean)) {
                    LOGGER.trace("should load db values is true, set value");
                    displayItemBean.loadDBValue();
                    LOGGER.trace("just got data loaded: " + displayItemBean.getData().getValue());
                }
            }
            displayItemBeans.add(displayItemBean);
        }
        Collections.sort(displayItemBeans);
        dig.setItems(displayItemBeans);
        dig.setHasData(groupHasData);
        itemGroups.add(dig);
    }
    diwgb.setItemGroups(itemGroups);
    diwgb.setDbItemGroups(itemGroups);
    return diwgb;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 58 with DisplayItemBean

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

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

the class DoubleDataEntryServlet method validateDisplayItemGroupBean.

@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, RuleValidator rv, HashMap<String, ArrayList<String>> groupOrdinalPLusItemOid, HttpServletRequest request, HttpServletResponse response) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    // logger.info("===got this far");
    int keyId = ecb.getId();
    Integer validationCount = (Integer) request.getSession().getAttribute(COUNT_VALIDATE + keyId);
    formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
    LOGGER.info("found formgroups size for " + digb.getGroupMetaBean().getName() + ": " + formGroups.size() + " compare to db groups size: " + digbs.size());
    String inputName = "";
    for (int i = 0; i < formGroups.size(); i++) {
        DisplayItemGroupBean displayGroup = formGroups.get(i);
        List<DisplayItemBean> items = displayGroup.getItems();
        int order = displayGroup.getOrdinal();
        if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
            order = displayGroup.getFormInputOrdinal();
        }
        for (DisplayItemBean displayItem : items) {
            if (displayGroup.isAuto()) {
                inputName = getGroupItemInputName(displayGroup, order, displayItem);
            } else {
                inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
            }
            if (displayItem.getMetadata().isShowItem() || getItemMetadataService().isShown(displayItem.getItem().getId(), ecb, displayItem.getData())) {
                // add the validation
                if (groupOrdinalPLusItemOid.containsKey(displayItem.getItem().getOid()) || groupOrdinalPLusItemOid.containsKey(String.valueOf(order + 1) + displayItem.getItem().getOid())) {
                    LOGGER.debug("IN : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
                    validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, true, groupOrdinalPLusItemOid.get(String.valueOf(order + 1) + displayItem.getItem().getOid()), request);
                } else {
                    validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, false, null, request);
                }
            } else {
                LOGGER.debug("OUT : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
            }
        // validateDisplayItemBean(v, displayItem, inputName);
        }
    }
    return formGroups;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 60 with DisplayItemBean

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

the class DataEntryServlet method processInputForGroupItem.

/**
     * @param fp
     * @param dibs
     * @param i
     * @param digb
     * @return
     */
private List<DisplayItemBean> processInputForGroupItem(FormProcessor fp, List<DisplayItemBean> dibs, int i, DisplayItemGroupBean digb, boolean isAuto) {
    for (int j = 0; j < dibs.size(); j++) {
        DisplayItemBean displayItem = dibs.get(j);
        String inputName = "";
        org.akaza.openclinica.bean.core.ResponseType rt = displayItem.getMetadata().getResponseSet().getResponseType();
        if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {
            if (isAuto) {
                inputName = getGroupItemInputName(digb, i, displayItem);
            } else {
                inputName = getGroupItemManualInputName(digb, i, displayItem);
            }
            ArrayList valueArray = fp.getStringArray(inputName);
            displayItem.setFieldName(inputName);
            displayItem.loadFormValue(valueArray);
        } else {
            if (isAuto) {
                inputName = getGroupItemInputName(digb, i, displayItem);
            } else {
                inputName = getGroupItemManualInputName(digb, i, displayItem);
            }
            displayItem.setFieldName(inputName);
            displayItem.loadFormValue(fp.getString(inputName));
            // necessary here
            if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECT)) {
                ensureSelectedOption(displayItem);
            }
        // BWP>>
        }
    }
    return dibs;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ArrayList(java.util.ArrayList)

Aggregations

DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)80 ArrayList (java.util.ArrayList)44 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)37 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)33 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)24 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)22 HashMap (java.util.HashMap)19 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)18 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)16 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)16 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)15 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)15 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)12 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)12 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)12 DisplayItemWithGroupBean (org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean)11 Element (org.jdom.Element)10 List (java.util.List)8 Map (java.util.Map)8 HttpSession (javax.servlet.http.HttpSession)8