Search in sources :

Example 26 with DisplayItemGroupBean

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

the class BeanFactory method createGroupBeans.

/**
     * This method creates a List of DisplayItemGroupBeans. The
     * DisplayItemGroupBeans are listed in the order their items are defined in
     * the CRF spreadsheet. These beans include the items that are and are not
     * associated with a group. If an item is defined in a spreadsheet but does
     * not have a group label, that item is included in a DisplayItemGroupBean,
     * but not linked to any groups (i.e., that DisplayItemGroupBean has an
     * empty FormGroupBean object, with an empty String for a group label). For
     * example, if the spreadsheet defines two items first, but does not assign
     * them a group, then those items will make up the first
     * DisplayItemGroupBean. The spreadsheet then might define a <em>group</em>
     * of items followed by more items that are not part of a group. The former
     * items will represent the second DisplayItemGroupBean. The third
     * DisplayItemGroupBean will include the last collection of "orphaned"
     * items, accompanied by an empty FormGroupBean object.
     * 
     * @param itemsMap
     *            A Map containing rows of Item information from the
     *            spreadsheet. The items are in the order they were defined in
     *            the spreadsheet.
     * @param sectionLabel
     *            A String specifying the name of the section we are displaying.
     * @param groupsMap
     *            A Map containing rows of Group information from the
     *            spreadsheet.
     * @param crfName
     *            The name of the CRF, a String.
     * @see org.akaza.openclinica.bean.submit.ItemGroupBean
     * @return A List of DisplayItemGroupBeans
     */
public List<DisplayItemGroupBean> createGroupBeans(Map<Integer, Map<String, String>> itemsMap, Map<Integer, Map<String, String>> groupsMap, String sectionLabel, String crfName) {
    List<DisplayItemGroupBean> groupBeans = new ArrayList<DisplayItemGroupBean>();
    // properly build group beans
    if (groupsMap == null || groupsMap.isEmpty() || sectionLabel == null || sectionLabel.length() < 1 || sectionLabel.equalsIgnoreCase(UNGROUPED) || itemsMap == null || itemsMap.isEmpty()) {
        return groupBeans;
    }
    // First, separate the items into those only associated with this
    // section
    Map<String, String> innermap;
    List<DisplayItemBean> displayItems;
    Map.Entry<Integer, Map<String, String>> me;
    // This Map will hold the DisplayitemBeans that are associated with this
    // section
    Map<Integer, Map<String, String>> newMap = new HashMap<Integer, Map<String, String>>();
    String lab;
    for (Iterator<Map.Entry<Integer, Map<String, String>>> iter = itemsMap.entrySet().iterator(); iter.hasNext(); ) {
        me = iter.next();
        innermap = me.getValue();
        lab = innermap.get("section_label");
        if (lab != null && lab.equalsIgnoreCase(sectionLabel)) {
            newMap.put(me.getKey(), innermap);
        }
    }
    displayItems = this.createDisplayItemBeansFromMap(newMap, crfName);
    // Now, separate the DisplayItemBeans into those associated with groups,
    // and any others that do not have groups
    ItemGroupBean fgBean;
    DisplayItemGroupBean disFgBean;
    String latestGroupLabel;
    boolean validGroupFlag = false;
    int ordinal = 0;
    // the List.
    for (DisplayItemBean disBean : displayItems) {
        latestGroupLabel = disBean.getMetadata().getGroupLabel();
        // to a group. Store it in a FormGroupBean.
        if (latestGroupLabel != null && latestGroupLabel.length() > 0 && !latestGroupLabel.equalsIgnoreCase(UNGROUPED)) {
            // set this flag to true, indicating that the items being
            // processed now
            // are associated with a valid group
            validGroupFlag = true;
            // If lastGroupLabel is not yet stored in the List of
            // DisplayGroupBeans
            // then the beans associated with that label (DisplayGroupBeans
            // and
            // FormGroupBeans) have to be initialized.
            // Otherwise, just store the new displayitembean in the existing
            // FormGroupBean/DisplayFormGroupBean
            disFgBean = getGroupFromLabel(latestGroupLabel, groupBeans);
            // then a new one has to be initialized for this DisplayItemBean
            if (!(disFgBean.getItemGroupBean().getName().length() > 0)) {
                // Get FormGroupBean from group label
                fgBean = initFormGroupFromMap(latestGroupLabel, groupsMap);
                ordinal++;
                fgBean.getMeta().setOrdinal(ordinal);
                disFgBean.setItemGroupBean(fgBean);
                disFgBean.setGroupMetaBean(fgBean.getMeta());
                groupBeans.add(disFgBean);
            }
        } else {
            // if there is no group label associated with the
            // DisplayItemBean, then it
            // does not have a group; it is an "orphaned" item. In this
            // case, create a
            // DisplayFormGroup with a group label signified with an empty
            // string. This
            // "group" will hold the orphaned items. What if there are
            // orphaned items
            // in the spreadsheet that are divided by grouped items? Then
            // these orphaned
            // items have to be in separate DisplayFormGroups. To handle
            // this case, the
            // code checks the validGroupFlag boolean variable. if "true,"
            // indicating that
            // non-orphaned beans have just been processed, then create a
            // new
            // DisplayFormGroup for these orphaned items.
            boolean isFirst = isFirstUngroupedItem(groupBeans);
            if (validGroupFlag || isFirst) {
                disFgBean = new DisplayItemGroupBean();
                fgBean = new ItemGroupBean();
                ordinal++;
                fgBean.getMeta().setOrdinal(ordinal);
                fgBean.setName(UNGROUPED);
                disFgBean.setItemGroupBean(fgBean);
                disFgBean.setGroupMetaBean(fgBean.getMeta());
                groupBeans.add(disFgBean);
            } else {
                // The existing DisplayFormGroupBean for orphaned items
                // is the FormGroupBean containing the highest ordinal, and
                // with a group label
                // containing an empty string
                disFgBean = getLatestDisFormBeanForOrphanedItems(groupBeans);
            }
            validGroupFlag = false;
        }
        disFgBean.getItems().add(disBean);
    }
    return groupBeans;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 27 with DisplayItemGroupBean

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

the class DataEntryServlet method reshuffleReasonForChangeHashAndDiscrepancyNotes.

private void reshuffleReasonForChangeHashAndDiscrepancyNotes(List<DisplayItemWithGroupBean> allItems, HttpServletRequest request, EventCRFBean ecb) {
    int manualRows = 0;
    HashMap<String, Boolean> noteSubmitted = (HashMap<String, Boolean>) request.getSession().getAttribute(DataEntryServlet.NOTE_SUBMITTED);
    FormDiscrepancyNotes noteTree = (FormDiscrepancyNotes) request.getSession().getAttribute(CreateDiscrepancyNoteServlet.FLAG_DISCREPANCY_RFC);
    ArrayList<DiscrepancyNoteBean> fieldNote = null;
    String intendedKey = null;
    String replacementKey = null;
    if ((noteSubmitted == null || noteSubmitted.size() < 1) && (noteTree == null || noteTree.getFieldNotes() == null || noteTree.getFieldNotes().size() < 1)) {
        return;
    }
    for (int i = 0; i < allItems.size(); i++) {
        DisplayItemWithGroupBean diwb = allItems.get(i);
        if (diwb.isInGroup()) {
            List<DisplayItemGroupBean> dgbs = diwb.getItemGroups();
            for (int j = 0; j < dgbs.size(); j++) {
                DisplayItemGroupBean digb = dgbs.get(j);
                ItemGroupBean igb = digb.getItemGroupBean();
                List<DisplayItemBean> dibs = digb.getItems();
                if (j == 0) {
                    // first repeat
                    for (DisplayItemBean dib : dibs) {
                        intendedKey = ecb.getId() + "_" + digb.getInputId() + getInputName(dib);
                        replacementKey = ecb.getId() + "_" + digb.getItemGroupBean().getOid() + "_" + j + getInputName(dib);
                        if (!replacementKey.equals(intendedKey)) {
                            if (noteSubmitted.containsKey(intendedKey)) {
                                noteSubmitted.put(replacementKey, Boolean.TRUE);
                                noteSubmitted.remove(intendedKey);
                            }
                            if (noteTree.getNotes(intendedKey) != null) {
                                fieldNote = (ArrayList<DiscrepancyNoteBean>) noteTree.getNotes(intendedKey);
                                if (fieldNote != null && fieldNote.size() > 0) {
                                    noteTree.getFieldNotes().put(replacementKey, fieldNote);
                                    noteTree.getFieldNotes().remove(intendedKey);
                                }
                            //not changing here because this hash should not be used
                            //                                      noteTree.addIdNote(note.getEntityId(), field);
                            //
                            }
                        }
                    }
                } else {
                    // everything in between
                    manualRows++;
                    for (DisplayItemBean dib : dibs) {
                        intendedKey = ecb.getId() + "_" + digb.getInputId() + getInputName(dib);
                        replacementKey = ecb.getId() + "_" + digb.getItemGroupBean().getOid() + "_manual" + (j) + getInputName(dib);
                        if (!replacementKey.equals(intendedKey)) {
                            if (noteSubmitted != null && noteSubmitted.containsKey(intendedKey)) {
                                noteSubmitted.put(replacementKey, Boolean.TRUE);
                                noteSubmitted.remove(intendedKey);
                            }
                            if (noteTree != null && noteTree.getNotes(intendedKey) != null) {
                                fieldNote = (ArrayList<DiscrepancyNoteBean>) noteTree.getNotes(intendedKey);
                                if (fieldNote != null && fieldNote.size() > 0) {
                                    noteTree.getFieldNotes().put(replacementKey, fieldNote);
                                    noteTree.getFieldNotes().remove(intendedKey);
                                }
                            }
                        }
                    }
                }
                LOGGER.debug("removing: " + intendedKey + " and replacing it with " + replacementKey);
            }
        }
    }
    request.getSession().setAttribute(DataEntryServlet.NOTE_SUBMITTED, noteSubmitted);
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) HashMap(java.util.HashMap) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) DisplayItemWithGroupBean(org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean)

Example 28 with DisplayItemGroupBean

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

the class AdministrativeEditingServlet method validateDisplayItemGroupBean.

@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, HttpServletRequest request, HttpServletResponse response) {
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
    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);
            }
            validateDisplayItemBean(v, displayItem, inputName, request);
        }
    }
    return formGroups;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 29 with DisplayItemGroupBean

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

the class AdministrativeEditingServlet 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) {
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
    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) {
            // tbh trying to set this correctly 01/2010
            if (displayGroup.isAuto()) {
                inputName = getGroupItemInputName(displayGroup, order, displayItem);
            } else {
                inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
            // manualcount++;
            }
            LOGGER.debug("THe oid is " + displayItem.getItem().getOid() + " order : " + order + " inputName : " + inputName);
            if (groupOrdinalPLusItemOid.containsKey(displayItem.getItem().getOid()) || groupOrdinalPLusItemOid.containsKey(String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid())) {
                LOGGER.debug("IN : " + String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid());
                validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, true, groupOrdinalPLusItemOid.get(String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid()), request);
            } else {
                validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, false, null, request);
            }
        }
    }
    return formGroups;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 30 with DisplayItemGroupBean

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

the class DataEntryServlet method getManualRows.

public int getManualRows(List<DisplayItemGroupBean> formGroups) {
    int manualRows = 0;
    for (int j = 0; j < formGroups.size(); j++) {
        DisplayItemGroupBean formItemGroup = formGroups.get(j);
        LOGGER.debug("begin formGroup Ordinal:" + formItemGroup.getOrdinal());
        if (formItemGroup.isAuto() == false) {
            manualRows = manualRows + 1;
        }
    }
    LOGGER.debug("+++ returning manual rows: " + manualRows + " from a form group size of " + formGroups.size());
    // logger.debug("+++ returning manual rows: " + manualRows + " from a form group size of " + formGroups.size());
    return manualRows;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean)

Aggregations

DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)43 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)33 ArrayList (java.util.ArrayList)24 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)13 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)13 DisplayItemWithGroupBean (org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean)12 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)11 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)10 HashMap (java.util.HashMap)9 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)9 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)9 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)9 HttpSession (javax.servlet.http.HttpSession)7 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)7 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)7 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)6 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)6 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)6 Map (java.util.Map)5 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)5