use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ItemDAO method findAllActiveByCRF.
public ArrayList findAllActiveByCRF(CRFBean crf) {
HashMap variables = new HashMap();
this.setTypesExpected();
// crf_version_id
this.setTypeExpected(14, TypeNames.INT);
// version name
this.setTypeExpected(15, TypeNames.STRING);
variables.put(new Integer(1), new Integer(crf.getId()));
String sql = digester.getQuery("findAllActiveByCRF");
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
ItemBean eb = (ItemBean) this.getEntityFromHashMap(hm);
Integer versionId = (Integer) hm.get("crf_version_id");
String versionName = (String) hm.get("cvname");
ItemFormMetadataBean imf = new ItemFormMetadataBean();
imf.setCrfVersionName(versionName);
// logger.info("versionName" + imf.getCrfVersionName());
imf.setCrfVersionId(versionId.intValue());
eb.setItemMeta(imf);
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.submit.ItemBean in project OpenClinica by OpenClinica.
the class ItemDAO method findAllItemsByGroupId.
public List<ItemBean> findAllItemsByGroupId(int id, int crfVersionId) {
this.setTypesExpected();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(1, id);
variables.put(2, crfVersionId);
String sql = digester.getQuery("findAllItemsByGroupId");
List listofMaps = this.select(sql, 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 findAllItemsByGroupIdAndSectionIdOrdered.
public List<ItemBean> findAllItemsByGroupIdAndSectionIdOrdered(int id, int crfVersionId, int sectionId) {
this.setTypesExpected();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(1, id);
variables.put(2, sectionId);
variables.put(3, crfVersionId);
String sql = digester.getQuery("findAllItemsByGroupIdAndSectionIdOrdered");
List listofMaps = this.select(sql, 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 GenerateExtractFileService method createSPSSFile.
/**
* createSPSSFile, added by tbh, 01/2009
*
* @param db
* @param eb
* @param currentstudyid
* @param parentstudy
* @return
*/
public HashMap<String, Integer> createSPSSFile(DatasetBean db, ExtractBean eb2, StudyBean currentStudy, StudyBean parentStudy, long sysTimeBegin, String generalFileDir, SPSSReportBean answer, String generalFileDirCopy, UserAccountBean userBean) {
setUpResourceBundles();
String SPSSFileName = db.getName() + "_data_spss.dat";
String DDLFileName = db.getName() + "_ddl_spss.sps";
String ZIPFileName = db.getName() + "_spss";
SPSSVariableNameValidator svnv = new SPSSVariableNameValidator();
answer.setDatFileName(SPSSFileName);
// DatasetDAO dsdao = new DatasetDAO(ds);
// create the extract bean here, tbh
// ExtractBean eb = this.generateExtractBean(db, currentStudy,
// parentStudy);
// eb = dsdao.getDatasetData(eb, currentStudy.getId(),
// parentStudy.getId());
// eb.getMetadata();
// eb.computeReport(answer);
// set up items here to get
answer.setItems(eb2.getItemNames());
// itemMetadata
// set up response sets for each item here
ItemDAO itemdao = new ItemDAO(ds);
ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(ds);
ArrayList items = answer.getItems();
for (int i = 0; i < items.size(); i++) {
DisplayItemHeaderBean dih = (DisplayItemHeaderBean) items.get(i);
ItemBean item = dih.getItem();
ArrayList metas = imfdao.findAllByItemId(item.getId());
// for (int h = 0; h < metas.size(); h++) {
// ItemFormMetadataBean ifmb = (ItemFormMetadataBean)
// metas.get(h);
// logger.info("group name found:
// "+ifmb.getGroupLabel());
// }
// logger.info("crf versionname" +
// meta.getCrfVersionName());
item.setItemMetas(metas);
}
HashMap eventDescs = new HashMap<String, String>();
eventDescs = eb2.getEventDescriptions();
eventDescs.put("SubjID", resword.getString("study_subject_ID"));
eventDescs.put("ProtocolID", resword.getString("protocol_ID_site_ID"));
eventDescs.put("DOB", resword.getString("date_of_birth"));
eventDescs.put("YOB", resword.getString("year_of_birth"));
eventDescs.put("Gender", resword.getString("gender"));
answer.setDescriptions(eventDescs);
ArrayList generatedReports = new ArrayList<String>();
try {
// YW <<
generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
generatedReports.add(answer.getDataFile().toString());
// YW >>
} catch (IndexOutOfBoundsException i) {
generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
logger.debug("throw the error here");
}
long sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
ArrayList titles = new ArrayList();
// YW <<
titles.add(DDLFileName);
titles.add(SPSSFileName);
// YW >>
// create new createFile method that accepts array lists to
// put into zip files
int fId = this.createFile(ZIPFileName, titles, generalFileDir, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, true, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = this.createFile(ZIPFileName, titles, generalFileDirCopy, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, false, userBean);
}
// return DDLFileName;
HashMap answerMap = new HashMap<String, Integer>();
answerMap.put(DDLFileName, new Integer(fId));
return answerMap;
}
use of org.akaza.openclinica.bean.submit.ItemBean 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);
}
}
}
}
}
}
}
Aggregations