use of org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO in project OpenClinica by OpenClinica.
the class ImportDataRuleRunnerContainer method isRepeatIGForSure.
private boolean isRepeatIGForSure(DataSource ds, Integer crfVersionId, String itemGroupOid, Integer igOrdinal, Integer itemId) {
boolean isRepeatForSure = igOrdinal != null && igOrdinal > 1 ? true : false;
if (!isRepeatForSure) {
if (itemGroupOid.endsWith("_UNGROUPED") || itemGroupOid.contains("_UNGROUPED_"))
isRepeatForSure = false;
else {
ItemGroupMetadataBean itemGroupMetadataBean = (ItemGroupMetadataBean) new ItemGroupMetadataDAO<String, ArrayList>(ds).findByItemAndCrfVersion(itemId, crfVersionId);
isRepeatForSure = itemGroupMetadataBean.isRepeatingGroup();
}
}
return isRepeatForSure;
}
use of org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO in project OpenClinica by OpenClinica.
the class FormBeanUtil method createDisplaySectionBWithFormGroups.
/**
* Create a DisplaySectionBean with a list of ItemGroupBeans. This List will
* include any ItemGroupBeans that are associated with ungrouped items; in
* other words, the DisplaySectionBean will represent a section that has
* both ungrouped and grouped tables.
*
* @param sectionId
* The Section ID associated with the Items, which end up
* providing the content of the tables.
* @param crfVersionId
* The CRF version ID associated with the Items.
* @param dataSource
* @param eventCRFDefId
* The id for the Event CRF Definition.
* @return A DisplaySectionBean with sorted ItemGroupBeans, meaning the
* ItemGroupBeans should be listed in the order that they appear on
* the CRF section.
* @return A DisplaySectionBean representing a CRF section.
*/
public DisplaySectionBean createDisplaySectionBWithFormGroups(int sectionId, int crfVersionId, DataSource dataSource, int eventCRFDefId, EventCRFBean eventCrfBean, ServletContext context) {
DisplaySectionBean displaySectionBean = new DisplaySectionBean();
ItemGroupDAO formGroupDAO = new ItemGroupDAO(dataSource);
ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(dataSource);
ItemDAO itemDao = new ItemDAO(dataSource);
ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(dataSource);
SectionDAO sectionDao = new SectionDAO(dataSource);
// Give the DisplaySectionBean a legitimate SectionBean
SectionBean secBean = (SectionBean) sectionDao.findByPK(sectionId);
displaySectionBean.setSection(secBean);
// changed from: findGroupBySectionId
List<ItemGroupBean> itemGroupBeans = formGroupDAO.findLegitGroupAllBySectionId(sectionId);
// all items associated with the section, including those not in a group
List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
try {
allMetas = metaDao.findAllBySectionId(sectionId);
} catch (OpenClinicaException oce) {
logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
}
// Sort these items according to their position on the CRF; their
// ordinal
Collections.sort(allMetas);
// The DisplayItemGroupBean(s) for "nongrouped" items
List<DisplayItemGroupBean> nonGroupBeans = null;
// if(itemGroupBeans.isEmpty()) return displaySectionBean;
// Find out whether there are any checkboxes/radios/select elements
// and if so, get any null values
// associated with them
List<String> nullValuesList = new ArrayList<String>();
boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
if (itemsHaveChecksRadios && eventCRFDefId > 0) {
// method returns null values as a List<String>
nullValuesList = this.getNullValuesByEventCRFDefId(eventCRFDefId, dataSource);
}
// Get the items associated with each group
List<ItemBean> itBeans;
List<DisplayItemBean> displayItems;
List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
DisplayItemGroupBean displayItemGBean;
for (ItemGroupBean itemGroup : itemGroupBeans) {
itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), crfVersionId);
logger.debug("just ran find all by group id " + itemGroup.getId() + " found " + itBeans.size() + " item beans");
List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), crfVersionId, sectionId);
if (!metadata.isEmpty()) {
// for a given crf version, all the items in the same group
// have the same group metadata info
// so we can get one of the metadata and set the metadata for
// the group
ItemGroupMetadataBean meta = metadata.get(0);
itemGroup.setMeta(meta);
}
displayItems = getDisplayBeansFromItems(itBeans, dataSource, eventCrfBean, sectionId, nullValuesList, context);
displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
displayFormBeans.add(displayItemGBean);
}
// We still have to sort these display item group beans on their
// ItemGroupMetadataBean?
// then number their ordinals accordingly
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
}
});
// Now provide the display item group beans with an ordinal
int digOrdinal = 0;
for (DisplayItemGroupBean digBean : displayFormBeans) {
digBean.setOrdinal(++digOrdinal);
}
// find out whether there are any ungrouped items by comparing the
// number of
// grouped items to allMetas.size()
// List<DisplayItemGroupBean> nonGroupBeans=null;
int tempCount = 0;
for (DisplayItemGroupBean groupBean : displayFormBeans) {
tempCount += groupBean.getItems().size();
}
if (tempCount < allMetas.size()) {
nonGroupBeans = createGroupBeansForNongroupedItems(allMetas, displayFormBeans, sectionId, dataSource, nullValuesList, eventCrfBean, context);
}
if (nonGroupBeans != null) {
displayFormBeans.addAll(nonGroupBeans);
}
// sort the list according to the ordinal of the contained
// DisplayItemGroupBeans
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean disFormGroupBean, DisplayItemGroupBean disFormGroupBean1) {
Integer compInt = disFormGroupBean1.getOrdinal();
Integer compInt2 = disFormGroupBean.getOrdinal();
return compInt2.compareTo(compInt);
}
});
displaySectionBean.setDisplayFormGroups(displayFormBeans);
return displaySectionBean;
}
use of org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO in project OpenClinica by OpenClinica.
the class FormBeanUtil method createDisplaySectionWithItemGroups.
/**
* Create a DisplaySectionBean with a list of ItemGroupBeans. NOTE:
* unGrouped Items are not included
*
* @param study
* The StudyBean
* @param sectionId
* The Section ID associated with the Items, which end up
* providing the content of the tables.
* @param crfVersionId
* The CRF version ID associated with the Items.
* @param studyEventId
* The Study Event ID associated with the CRF Version ID.
* @param sm
* A SessionManager, from which DataSources are acquired for the
* DAO objects.
* @return A DisplaySectionBean.
*/
public DisplaySectionBean createDisplaySectionWithItemGroups(StudyBean study, int sectionId, EventCRFBean eventCrfBean, int studyEventId, SessionManager sm, int eventDefinitionCRFId, ServletContext context) {
DisplaySectionBean dBean = new DisplaySectionBean();
ItemGroupDAO formGroupDAO = new ItemGroupDAO(sm.getDataSource());
ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(sm.getDataSource());
List<ItemGroupBean> arrList = formGroupDAO.findLegitGroupBySectionId(sectionId);
// all items associated with the section, including those not in a group
List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
try {
allMetas = metaDao.findAllBySectionId(sectionId);
} catch (OpenClinicaException oce) {
logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
}
// Collections.sort(allMetas);
if (arrList.isEmpty())
return dBean;
// Find out whether there are any checkboxes/radios/select elements
// and if so, get any null values
// associated with them
List<String> nullValuesList = new ArrayList<String>();
boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
// "+eventDefinitionCRFId);
if (eventDefinitionCRFId <= 0) {
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(study, studyEventId, eventCrfBean.getCRFVersionId());
eventDefinitionCRFId = edcBean.getId();
}
// "+eventDefinitionCRFId);
if (itemsHaveChecksRadios && eventDefinitionCRFId > 0) {
// method returns null values as a List<String>
nullValuesList = this.getNullValuesByEventCRFDefId(eventDefinitionCRFId, sm.getDataSource());
}
// Get the items associated with each group
List<ItemBean> itBeans;
List<DisplayItemBean> displayItems;
List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
DisplayItemGroupBean displayItemGBean;
for (ItemGroupBean itemGroup : arrList) {
itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), eventCrfBean.getCRFVersionId());
List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), eventCrfBean.getCRFVersionId(), sectionId);
if (!metadata.isEmpty()) {
// for a given crf version, all the items in the same group
// have the same group metadata
// so we can get one of them and set metadata for the group
ItemGroupMetadataBean meta = metadata.get(0);
itemGroup.setMeta(meta);
}
// include arrayList parameter until I determine difference in
// classes
displayItems = getDisplayBeansFromItems(itBeans, sm.getDataSource(), eventCrfBean, sectionId, nullValuesList, context);
displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
displayFormBeans.add(displayItemGBean);
}
// We still have to sort these display item group beans on their
// ItemGroupMetadataBean?
// then number their ordinals accordingly
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
}
});
// Now provide the display item group beans with an ordinal
int digOrdinal = 0;
for (DisplayItemGroupBean digBean : displayFormBeans) {
digBean.setOrdinal(++digOrdinal);
}
dBean.setDisplayFormGroups(displayFormBeans);
return dBean;
}
use of org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO in project OpenClinica by OpenClinica.
the class FormBeanUtil method createDisplaySectionBeanWithItemGroups.
/**
* Create a DisplaySectionBean with a list of FormGroupBeans.
*
* @param crfVersionId
* The CRF version ID associated with the Items.
* @param sectionBean
* The SectionBean with an ID associated with the Items, which
* end up providing the content of the tables.
* @param sm
* A SessionManager, from which DataSources are acquired for the
* DAO objects.
* @return A DisplaySectionBean.
*/
public DisplaySectionBean createDisplaySectionBeanWithItemGroups(int sectionId, EventCRFBean eventCrfBean, SectionBean sectionBean, SessionManager sm, ServletContext context) {
DisplaySectionBean dBean = new DisplaySectionBean();
ItemGroupDAO formGroupDAO = new ItemGroupDAO(sm.getDataSource());
ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
// Get all items associated with this crfVersion ID; divide them up into
// items with a group, and those without a group.
// get all items associated with a section id, then split them up into
// grouped
// and non-grouped items
List<ItemBean> allItems = itemDao.findAllParentsBySectionId(sectionId);
// Get a List of FormGroupBeans for each group associated with
// this crfVersionId.
// List<ItemGroupBean> arrList =
// formGroupDAO.findGroupByCRFVersionIDMap(crfVersionId);
List<ItemGroupBean> arrList = formGroupDAO.findLegitGroupBySectionId(sectionId);
if (arrList.isEmpty())
return dBean;
// Get the items associated with each group
List<ItemBean> itBeans;
List<DisplayItemBean> displayItems;
List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
DisplayItemGroupBean displayFormGBean;
for (ItemGroupBean itemGroup : arrList) {
itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), eventCrfBean.getCRFVersionId());
List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), eventCrfBean.getCRFVersionId(), sectionId);
// this requirement
if (!metadata.isEmpty()) {
// for a given crf version, all the items in the same group have
// the same group metadata
// so we can get one of them and set metadata for the group
ItemGroupMetadataBean meta = metadata.get(0);
itemGroup.setMeta(meta);
}
// TODO: the last arg is a list of null value strings
displayItems = getDisplayBeansFromItems(itBeans, sm.getDataSource(), eventCrfBean, sectionBean.getId(), null, context);
displayFormGBean = this.createDisplayFormGroup(displayItems, itemGroup);
displayFormBeans.add(displayFormGBean);
}
// sort the list according to the ordinal of the contained
// FormGroupBeans
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean disFormGroupBean, DisplayItemGroupBean disFormGroupBean1) {
return disFormGroupBean.getGroupMetaBean().getOrdinal().compareTo(disFormGroupBean1.getGroupMetaBean().getOrdinal());
}
});
dBean.setDisplayFormGroups(displayFormBeans);
return dBean;
}
use of org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO in project OpenClinica by OpenClinica.
the class OpenRosaXmlGenerator method getItemGroupMetadataByGroup.
@SuppressWarnings({ "unchecked", "rawtypes" })
private ItemGroupMetadataBean getItemGroupMetadataByGroup(ItemGroupBean itemGroupBean, CRFVersionBean crfVersion) throws Exception {
ArrayList<ItemGroupMetadataBean> itemGroupMetadataBean = null;
ItemGroupMetadataDAO itemGroupMetadataDAO = new ItemGroupMetadataDAO(dataSource);
itemGroupMetadataBean = (ArrayList<ItemGroupMetadataBean>) itemGroupMetadataDAO.findMetaByGroupAndCrfVersion(itemGroupBean.getId(), crfVersion.getId());
return itemGroupMetadataBean.get(0);
}
Aggregations