use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DynamicsItemFormMetadataDao method findByItemDataBean.
public DynamicsItemFormMetadataBean findByItemDataBean(ItemDataBean itemDataBean) {
String query = "from " + getDomainClassName() + " metadata where metadata.itemDataId = :item_data_id ";
Query q = getCurrentSession().createQuery(query);
q.setInteger("item_data_id", new Integer(itemDataBean.getId()));
return (DynamicsItemFormMetadataBean) q.uniqueResult();
}
use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean 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);
}
}
}
}
}
}
}
use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method isShown.
// deprecated?
public boolean isShown(Integer itemId, EventCRFBean eventCrfBean) {
// do we check against the database, or just against the object? prob against the db
// ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) metadataBean;
// return itemFormMetadataBean.isShowItem();
ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemId, eventCrfBean.getCRFVersionId());
DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean, null);
// DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataDao().findByMetadataBean(itemFormMetadataBean, eventCrfBean);
if (dynamicsMetadataBean != null) {
return dynamicsMetadataBean.isShowItem();
} else {
logger.debug("did not find a row in the db for " + itemFormMetadataBean.getId());
return false;
}
// return false;
}
use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method hideItem.
public boolean hideItem(ItemFormMetadataBean metadataBean, EventCRFBean eventCrfBean, ItemDataBean itemDataBean) {
ItemFormMetadataBean itemFormMetadataBean = metadataBean;
DynamicsItemFormMetadataBean dynamicsMetadataBean = this.getDynamicsItemFormMetadataDao().findByItemDataBean(itemDataBean);
dynamicsMetadataBean = dynamicsMetadataBean != null && dynamicsMetadataBean.getId() > 0 ? dynamicsMetadataBean : new DynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean);
dynamicsMetadataBean.setShowItem(false);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
return true;
}
use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method showItem.
public boolean showItem(ItemFormMetadataBean metadataBean, EventCRFBean eventCrfBean, ItemDataBean itemDataBean) {
ItemFormMetadataBean itemFormMetadataBean = metadataBean;
itemFormMetadataBean.setShowItem(true);
DynamicsItemFormMetadataBean dynamicsMetadataBean = new DynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean);
dynamicsMetadataBean.setItemDataId(itemDataBean.getId());
dynamicsMetadataBean.setShowItem(true);
dynamicsMetadataBean.setPassedDde(0);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
logger.debug("just touched ifmb id " + metadataBean.getId() + " ecb id " + eventCrfBean.getId() + " item id " + metadataBean.getItemId() + " itemdata id " + itemDataBean.getId());
return true;
}
Aggregations