use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ExtractBean method getMetadata.
/**
* Implements the Column algorithm in "Dataset Export Algorithms" Must be
* called after DatasetDAO.getDatasetData();
*/
public void getMetadata() {
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
CRFDAO cdao = new CRFDAO(ds);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDAO idao = new ItemDAO(ds);
ItemFormMetadataDAO ifmDAO = new ItemFormMetadataDAO(this.ds);
StudyGroupDAO studygroupDAO = new StudyGroupDAO(ds);
StudyGroupClassDAO studygroupclassDAO = new StudyGroupClassDAO(ds);
// SubjectGroupMapDAO subjectGroupMapDAO = new SubjectGroupMapDAO(ds);
studyGroupClasses = new ArrayList();
studyGroupMap = new HashMap();
studyGroupMaps = new HashMap<Integer, ArrayList>();
sedCrfColumns = new HashMap();
displayed = new HashMap();
sedCrfItemFormMetadataBeans = new HashMap();
studyEvents = seddao.findAllByStudy(study);
ArrayList finalStudyEvents = new ArrayList();
if (dataset.isShowSubjectGroupInformation()) {
// logger.info("found study id for maps: "+study.getId());
studyGroupMaps = studygroupDAO.findSubjectGroupMaps(study.getId());
// below is for a given subject; we need a data structure for
// all subjects
// studyGroupMap = studygroupDAO.findByStudySubject(currentSubject);
// problem: can't use currentSubject here, since it's not 'set up'
// properly
// how to get the current subject?
logger.info("found subject group ids: " + dataset.getSubjectGroupIds().toString());
// studyGroupClasses = dataset.getSubjectGroupIds();
for (int h = 0; h < dataset.getSubjectGroupIds().size(); h++) {
Integer groupId = (Integer) dataset.getSubjectGroupIds().get(h);
StudyGroupClassBean sgclass = (StudyGroupClassBean) studygroupclassDAO.findByPK(groupId.intValue());
// logger.info();
// hmm how to link groups to subjects though? only through
// subject group map
logger.info("found a studygroupclass bean: " + sgclass.getName());
studyGroupClasses.add(sgclass);
}
}
for (int i = 0; i < studyEvents.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) studyEvents.get(i);
if (!selectedSED(sed)) {
continue;
}
ArrayList CRFs = (ArrayList) cdao.findAllActiveByDefinition(sed);
ArrayList CRFsDisplayedInThisSED = new ArrayList();
for (int j = 0; j < CRFs.size(); j++) {
CRFBean cb = (CRFBean) CRFs.get(j);
if (!selectedSEDCRF(sed, cb)) {
continue;
} else {
CRFsDisplayedInThisSED.add(cb);
ArrayList CRFVersions = cvdao.findAllByCRFId(cb.getId());
for (int k = 0; k < CRFVersions.size(); k++) {
CRFVersionBean cvb = (CRFVersionBean) CRFVersions.get(k);
ArrayList Items = idao.findAllItemsByVersionId(cvb.getId());
// sort by ordinal/name
Collections.sort(Items);
for (int l = 0; l < Items.size(); l++) {
ItemBean ib = (ItemBean) Items.get(l);
if (selected(ib) && !getDisplayed(sed, cb, ib)) {
// logger.info("found at
// itemformmetadatadao: "+ib.getId()+",
// "+cvb.getId());
ItemFormMetadataBean ifmb = ifmDAO.findByItemIdAndCRFVersionId(ib.getId(), cvb.getId());
addColumn(sed, cb, ib);
addItemFormMetadataBeans(sed, cb, ifmb);
markDisplayed(sed, cb, ib);
}
}
}
}
// else
}
// for
sed.setCrfs(CRFsDisplayedInThisSED);
// make the setCrfs call "stick"
finalStudyEvents.add(sed);
}
this.studyEvents = finalStudyEvents;
}
use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ExtractCRFVersionBean method addItem.
public ItemBean addItem(Integer itemId, String itemName) {
if (itemId == null || itemName == null) {
logger.info("item null!");
return new ItemBean();
}
ItemBean ib = new ItemBean();
ib.setId(itemId.intValue());
ib.setName(itemName);
if (!items.contains(ib)) {
// logger.info("adding item: " + itemId.intValue() + "-" +
// itemName);
}
return (ItemBean) items.add(ib);
}
use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class CRFVersionDAO method findItemUsedByOtherVersion.
public Collection findItemUsedByOtherVersion(int versionId) {
this.unsetTypeExpected();
this.setTypeExpected(1, TypeNames.INT);
this.setTypeExpected(2, TypeNames.STRING);
this.setTypeExpected(3, TypeNames.INT);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(versionId));
String sql = digester.getQuery("findItemUsedByOtherVersion");
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
ItemBean eb = new ItemBean();
HashMap hm = (HashMap) it.next();
eb.setId(((Integer) hm.get("item_id")).intValue());
eb.setName((String) hm.get("name"));
eb.setOwnerId(((Integer) hm.get("owner_id")).intValue());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ItemDAO method findByOid.
public List<ItemBean> findByOid(String oid) {
this.setTypesExpected();
HashMap<Integer, String> variables = new HashMap<Integer, String>();
variables.put(1, oid);
List listofMaps = this.select(digester.getQuery("findItemByOid"), variables);
List<ItemBean> beanList = new ArrayList<ItemBean>();
ItemBean bean;
for (Object map : listofMaps) {
bean = (ItemBean) this.getEntityFromHashMap((HashMap) map);
beanList.add(bean);
}
return beanList;
}
use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ItemDAO method update.
public EntityBean update(EntityBean eb) {
ItemBean ib = (ItemBean) eb;
HashMap variables = new HashMap();
variables.put(new Integer(1), ib.getName());
variables.put(new Integer(2), ib.getDescription());
variables.put(new Integer(3), ib.getUnits());
variables.put(new Integer(4), new Boolean(ib.isPhiStatus()));
variables.put(new Integer(5), new Integer(ib.getItemDataTypeId()));
variables.put(new Integer(6), new Integer(ib.getItemReferenceTypeId()));
variables.put(new Integer(7), new Integer(ib.getStatus().getId()));
variables.put(new Integer(8), new Integer(ib.getUpdaterId()));
variables.put(new Integer(9), new Integer(ib.getId()));
this.execute(digester.getQuery("update"), variables);
return eb;
}
Aggregations