Search in sources :

Example 81 with ItemBean

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

the class DynamicsMetadataService method oneToManyOld.

@Deprecated
private void oneToManyOld(ItemDataBean itemDataBeanA, EventCRFBean eventCrfBeanA, ItemGroupMetadataBean itemGroupMetadataBeanA, ItemBean itemBeanB, ItemGroupBean itemGroupBeanB, ItemGroupMetadataBean itemGroupMetadataBeanB, EventCRFBean eventCrfBeanB, UserAccountBean ub, String value) {
    //List<ItemDataBean> itemDataBeans = new ArrayList<ItemDataBean>();
    Integer size = getItemDataDAO().getGroupSize(itemBeanB.getId(), eventCrfBeanB.getId());
    int maxOrdinal = getItemDataDAO().getMaxOrdinalForGroupByItemAndEventCrf(itemBeanB.getId(), eventCrfBeanB);
    if (size > 0 || maxOrdinal > 0) {
        List<ItemDataBean> itemDataBeans = getItemDataDAO().findAllByEventCRFIdAndItemId(eventCrfBeanB.getId(), itemBeanB.getId());
        for (ItemDataBean oidBasedItemData : itemDataBeans) {
            oidBasedItemData.setValue(value);
            getItemDataDAO().updateValue(oidBasedItemData, "yyyy-MM-dd");
        }
    } else {
        List<ItemBean> items = getItemDAO().findAllItemsByGroupId(itemGroupBeanB.getId(), eventCrfBeanB.getCRFVersionId());
        for (int ordinal = 1 + maxOrdinal; ordinal <= itemGroupMetadataBeanB.getRepeatNum() + maxOrdinal; ordinal++) {
            for (ItemBean itemBeanX : items) {
                ItemDataBean oidBasedItemData = getItemData(itemBeanX, eventCrfBeanB, ordinal);
                if (oidBasedItemData.getId() == 0) {
                    oidBasedItemData = createItemData(oidBasedItemData, itemBeanX, ordinal, eventCrfBeanB, ub);
                }
                if (itemBeanX.getId() == itemBeanB.getId()) {
                    oidBasedItemData.setValue(value);
                    getItemDataDAO().updateValue(oidBasedItemData, "yyyy-MM-dd");
                }
            }
        }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean)

Example 82 with ItemBean

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

the class DynamicsMetadataService method oneToIndexedMany.

private ItemDataBean oneToIndexedMany(ItemDataBean itemDataBeanA, EventCRFBean eventCrfBeanA, ItemGroupMetadataBean itemGroupMetadataBeanA, ItemBean itemBeanB, ItemGroupBean itemGroupBeanB, ItemGroupMetadataBean itemGroupMetadataBeanB, EventCRFBean eventCrfBeanB, UserAccountBean ub, int index) {
    ItemDataBean theOidBasedItemData = null;
    int size = getItemDataDAO().getGroupSize(itemBeanB.getId(), eventCrfBeanB.getId());
    int maxOrdinal = getItemDataDAO().getMaxOrdinalForGroupByItemAndEventCrf(itemBeanB.getId(), eventCrfBeanB);
    if (size > 0 && size >= index) {
        List<ItemDataBean> theItemDataBeans = getItemDataDAO().findAllByEventCRFIdAndItemId(eventCrfBeanB.getId(), itemBeanB.getId());
        theOidBasedItemData = theItemDataBeans.get(index - 1);
    } else {
        List<ItemBean> items = getItemDAO().findAllItemsByGroupId(itemGroupBeanB.getId(), eventCrfBeanB.getCRFVersionId());
        int number = itemGroupMetadataBeanB.getRepeatNum() > index ? itemGroupMetadataBeanB.getRepeatNum() : index <= itemGroupMetadataBeanB.getRepeatMax() ? index : 0;
        for (int ordinal = 1 + maxOrdinal; ordinal <= number + maxOrdinal - size; ordinal++) {
            for (ItemBean itemBeanX : items) {
                ItemDataBean oidBasedItemData = getItemData(itemBeanX, eventCrfBeanB, ordinal);
                if (oidBasedItemData.getId() == 0) {
                    oidBasedItemData = createItemData(oidBasedItemData, itemBeanX, ordinal, eventCrfBeanB, ub);
                }
            }
        }
        List<ItemDataBean> theItemDataBeans = getItemDataDAO().findAllByEventCRFIdAndItemId(eventCrfBeanB.getId(), itemBeanB.getId());
        theOidBasedItemData = theItemDataBeans.get(index - 1);
    }
    return theOidBasedItemData;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean)

Example 83 with ItemBean

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

the class DynamicsMetadataService method oneToEndMany.

private ItemDataBean oneToEndMany(ItemDataBean itemDataBeanA, EventCRFBean eventCrfBeanA, ItemGroupMetadataBean itemGroupMetadataBeanA, ItemBean itemBeanB, ItemGroupBean itemGroupBeanB, ItemGroupMetadataBean itemGroupMetadataBeanB, EventCRFBean eventCrfBeanB, UserAccountBean ub) {
    ItemDataBean theOidBasedItemData = null;
    int size = getItemDataDAO().getGroupSize(itemBeanB.getId(), eventCrfBeanB.getId());
    int maxOrdinal = getItemDataDAO().getMaxOrdinalForGroupByItemAndEventCrf(itemBeanB.getId(), eventCrfBeanB);
    List<ItemBean> items = getItemDAO().findAllItemsByGroupId(itemGroupBeanB.getId(), eventCrfBeanB.getCRFVersionId());
    if (1 + maxOrdinal > itemGroupMetadataBeanB.getRepeatMax()) {
        logger.debug("Cannot add new repeat of this group because it has reached MaxRepeat.");
    } else {
        for (ItemBean itemBeanX : items) {
            ItemDataBean oidBasedItemData = getItemData(itemBeanX, eventCrfBeanB, 1 + maxOrdinal);
            if (oidBasedItemData.getId() == 0) {
                oidBasedItemData = createItemData(oidBasedItemData, itemBeanX, 1 + maxOrdinal, eventCrfBeanB, ub);
            }
        }
    }
    List<ItemDataBean> theItemDataBeans = getItemDataDAO().findAllByEventCRFIdAndItemId(eventCrfBeanB.getId(), itemBeanB.getId());
    theOidBasedItemData = theItemDataBeans.get(theItemDataBeans.size() - 1);
    return theOidBasedItemData;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean)

Example 84 with ItemBean

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

the class DynamicsMetadataService method getItemOrItemGroup.

private ItemOrItemGroupHolder getItemOrItemGroup(String oid) {
    String[] theOid = oid.split(ESCAPED_SEPERATOR);
    if (theOid.length == 2) {
        ItemGroupBean itemGroup = getItemGroupDAO().findByOid(theOid[0].trim());
        if (itemGroup != null) {
            ItemBean item = getItemDAO().findItemByGroupIdandItemOid(itemGroup.getId(), theOid[1].trim());
            if (item != null) {
                // System.out.println("returning two non nulls");
                return new ItemOrItemGroupHolder(item, itemGroup);
            }
        }
    }
    if (theOid.length == 1) {
        ItemGroupBean itemGroup = getItemGroupDAO().findByOid(oid.trim());
        if (itemGroup != null) {
            // System.out.println("returning item group not null");
            return new ItemOrItemGroupHolder(null, itemGroup);
        }
        List<ItemBean> items = getItemDAO().findByOid(oid.trim());
        ItemBean item = items.size() > 0 ? items.get(0) : null;
        if (item != null) {
            // System.out.println("returning item not null");
            return new ItemOrItemGroupHolder(item, null);
        }
    }
    return new ItemOrItemGroupHolder(null, null);
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean)

Example 85 with ItemBean

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

the class DatasetDAO method initialDatasetData.

/**
     * Initialize itemMap, itemIds, itemDefCrf and groupIds for a DatasetBean
     *
     * @param db
     * @return
     * @author ywang (Feb., 2008)
     */
public DatasetBean initialDatasetData(int datasetId) {
    ItemDAO idao = new ItemDAO(ds);
    DatasetBean db = (DatasetBean) findByPK(datasetId);
    String sql = db.getSQLStatement();
    sql = sql.split("study_event_definition_id in")[1];
    String[] ss = sql.split("and item_id in");
    String sedIds = ss[0];
    String[] sss = ss[1].split("and");
    String itemIds = sss[0];
    this.setDefinitionCrfItemTypesExpected();
    logger.debug("begin to execute GetDefinitionCrfItemSql");
    ArrayList alist = select(getDefinitionCrfItemSql(sedIds, itemIds));
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        ItemBean ib = (ItemBean) idao.getEntityFromHashMap(row);
        Integer defId = (Integer) row.get("sed_id");
        String defName = (String) row.get("sed_name");
        String crfName = (String) row.get("crf_name");
        Integer itemId = ib.getId();
        String key = defId + "_" + itemId;
        if (!db.getItemMap().containsKey(key)) {
            ib.setSelected(true);
            ib.setDefName(defName);
            ib.setCrfName(crfName);
            ib.setDatasetItemMapKey(key);
            // contains study_event_definition_ids
            if (!db.getEventIds().contains(defId)) {
                db.getEventIds().add(defId);
            }
            db.getItemIds().add(itemId);
            db.getItemDefCrf().add(ib);
            db.getItemMap().put(key, ib);
        }
    }
    db.setSubjectGroupIds(getGroupIds(db.getId()));
    return db;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

ItemBean (org.akaza.openclinica.bean.submit.ItemBean)132 ArrayList (java.util.ArrayList)77 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)56 HashMap (java.util.HashMap)50 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)43 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)42 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)36 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)26 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)25 Iterator (java.util.Iterator)23 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)22 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)22 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)21 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)20 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)15 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)15 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)13 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)13 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)13