Search in sources :

Example 71 with ItemDataBean

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

the class ItemDataDAO method updateStatus.

/**
     * this will update item data status
     */
public EntityBean updateStatus(EntityBean eb) {
    ItemDataBean idb = (ItemDataBean) eb;
    idb.setActive(false);
    HashMap<Integer, Comparable> variables = new HashMap<Integer, Comparable>();
    variables.put(new Integer(1), new Integer(idb.getStatus().getId()));
    variables.put(new Integer(2), new Integer(idb.getId()));
    this.execute(digester.getQuery("updateStatus"), variables);
    if (isQuerySuccessful()) {
        idb.setActive(true);
    }
    return idb;
}
Also used : HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean)

Example 72 with ItemDataBean

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

the class ItemDataDAO method updateValue.

/**
     * This will update item data value
     * 
     * @param eb
     * @return
     */
public EntityBean updateValue(EntityBean eb, String current_df_string) {
    ItemDataBean idb = (ItemDataBean) eb;
    ItemDataType dataType = getDataType(idb.getItemId());
    setItemDataBeanIfDateOrPdate(idb, current_df_string, dataType);
    idb.setActive(false);
    HashMap<Integer, Comparable> variables = new HashMap<Integer, Comparable>();
    variables.put(new Integer(1), new Integer(idb.getStatus().getId()));
    variables.put(new Integer(2), idb.getValue());
    variables.put(new Integer(3), new Integer(idb.getUpdaterId()));
    variables.put(new Integer(4), new Integer(idb.getId()));
    this.execute(digester.getQuery("updateValue"), variables);
    if (isQuerySuccessful()) {
        idb.setActive(true);
    }
    return idb;
}
Also used : ItemDataType(org.akaza.openclinica.bean.core.ItemDataType) HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean)

Example 73 with ItemDataBean

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

the class ItemDataDAO method findAll.

public Collection<ItemDataBean> findAll() {
    setTypesExpected();
    ArrayList alist = this.select(digester.getQuery("findAll"));
    ArrayList<ItemDataBean> al = new ArrayList<ItemDataBean>();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        ItemDataBean eb = (ItemDataBean) this.getEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 74 with ItemDataBean

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

the class ItemDataDAO method findByItemIdAndEventCRFIdAndOrdinalRaw.

public ItemDataBean findByItemIdAndEventCRFIdAndOrdinalRaw(int itemId, int eventCRFId, int ordinal) {
    setTypesExpected();
    ItemDataBean answer = new ItemDataBean();
    HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
    variables.put(new Integer(1), new Integer(itemId));
    variables.put(new Integer(2), new Integer(eventCRFId));
    variables.put(new Integer(3), new Integer(ordinal));
    EntityBean eb = this.executeFindByPKQuery("findByItemIdAndEventCRFIdAndOrdinal", variables);
    if (!eb.isActive()) {
        // hmm, return null instead?
        return new ItemDataBean();
    } else {
        return (ItemDataBean) eb;
    }
}
Also used : HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) EntityBean(org.akaza.openclinica.bean.core.EntityBean)

Example 75 with ItemDataBean

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

the class DynamicsMetadataService method showNew.

public void showNew(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet) {
    ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
    EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
    ItemGroupMetadataBean itemGroupMetadataBeanA = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(), eventCrfBeanA.getCRFVersionId());
    Boolean isGroupARepeating = isGroupRepeating(itemGroupMetadataBeanA);
    String itemGroupAOrdinal = getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
    for (PropertyBean propertyBean : properties) {
        String oid = propertyBean.getOid();
        ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
        // OID is an item
        if (itemOrItemGroup.getItemBean() != null) {
            String expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
            ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
            ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
            EventCRFBean eventCrfBeanB = eventCrfBeanA;
            ItemGroupMetadataBean itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
            Boolean isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
            String itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
            List<ItemDataBean> itemDataBeans = new ArrayList<ItemDataBean>();
            // If A and B are both non repeating groups
            if (!isGroupARepeating && !isGroupBRepeating) {
                ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is not repeating group & B is a repeating group with no index selected
            if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
                List<ItemDataBean> oidBasedItemDatas = oneToMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
                itemDataBeans.addAll(oidBasedItemDatas);
            }
            // If A is not repeating group & B is a repeating group with index selected
            if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is repeating group with index & B is a repeating group with index selected
            if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is repeating group with index & B is a repeating group with no index selected
            if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupAOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            logger.debug("** found item data beans: " + itemDataBeans.toString());
            for (ItemDataBean oidBasedItemData : itemDataBeans) {
                ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
                DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                if (dynamicsMetadataBean == null) {
                    showItem(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                // itemsAlreadyShown.add(new Integer(oidBasedItemData.getId()));
                } else if (dynamicsMetadataBean != null && !dynamicsMetadataBean.isShowItem()) {
                    dynamicsMetadataBean.setShowItem(true);
                    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
                // itemsAlreadyShown.add(new Integer(oidBasedItemData.getId()));
                } else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                    logger.debug("hit DDE here: idb " + oidBasedItemData.getId());
                    // need a guard clause to guarantee DDE
                    // if we get there, it means that we've hit DDE and the bean exists
                    //setVersion(1);// version 1 = passed DDE
                    dynamicsMetadataBean.setPassedDde(1);
                    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
                }
            }
        } else // OID is a group
        {
            logger.debug("found item group id 1 " + oid);
            ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
            ArrayList sectionBeans = getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
            for (int i = 0; i < sectionBeans.size(); i++) {
                SectionBean sectionBean = (SectionBean) sectionBeans.get(i);
                // System.out.println("found section " + sectionBean.getId());
                List<ItemGroupMetadataBean> itemGroupMetadataBeans = getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(), eventCrfBeanA.getCRFVersionId(), sectionBean.getId());
                for (ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
                    if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
                        // System.out.println("found item group id 2 " + oid);
                        DynamicsItemGroupMetadataBean dynamicsGroupBean = getDynamicsItemGroupMetadataBean(itemGroupMetadataBean, eventCrfBeanA);
                        if (dynamicsGroupBean == null) {
                            showGroup(itemGroupMetadataBean, eventCrfBeanA);
                        } else if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
                            dynamicsGroupBean.setShowGroup(true);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        } else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                            //setVersion(1); // version 1 = passed DDE
                            dynamicsGroupBean.setPassedDde(1);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        }
                    }
                }
            }
        }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ArrayList(java.util.ArrayList) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) DynamicsItemGroupMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) DynamicsItemGroupMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)133 ArrayList (java.util.ArrayList)74 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)64 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)61 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)42 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)41 HashMap (java.util.HashMap)39 Date (java.util.Date)37 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)37 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)33 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)33 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)26 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)26 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)26 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)21 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)21 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)20 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)20 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)18