use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class DatasetDAO method findAllOrderByStudyIdAndName.
public Collection findAllOrderByStudyIdAndName() {
this.setTypesExpected();
ArrayList alist = this.select(digester.getQuery("findAllOrderByStudyIdAndName"));
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
DatasetBean eb = (DatasetBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class DatasetDAO method findByOwnerId.
/**
* find by owner id, reports a list of datasets by user account id.
*
* @param ownerId
* studyId
*/
public Collection findByOwnerId(int ownerId, int studyId) {
// TODO add an findbyadminownerid?
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(Integer.valueOf(1), Integer.valueOf(studyId));
variables.put(Integer.valueOf(2), Integer.valueOf(studyId));
variables.put(Integer.valueOf(3), Integer.valueOf(ownerId));
ArrayList alist = this.select(digester.getQuery("findByOwnerId"), variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
DatasetBean eb = (DatasetBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class DatasetDAO method findTopFive.
public Collection findTopFive(StudyBean currentStudy) {
int studyId = currentStudy.getId();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(Integer.valueOf(1), Integer.valueOf(studyId));
variables.put(Integer.valueOf(2), Integer.valueOf(studyId));
ArrayList alist = this.select(digester.getQuery("findTopFive"), variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
DatasetBean eb = (DatasetBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class StudyInfoPanel method setData.
/**
* setData, the external function which creates data for the panel to
* reflect.
*
* @param page
* @param session
* @param request
*/
public void setData(Page page, HttpSession session, HttpServletRequest request) {
Locale locale = request.getLocale();
resword = ResourceBundleProvider.getWordsBundle();
local_sdf = new SimpleDateFormat(ResourceBundleProvider.getFormatBundle(locale).getString("date_format_string"));
try {
// defaults, can be reset by mistake by running through one page,
// tbh
this.setStudyInfoShown(true);
this.setOrderedData(false);
// try to avoid errors, tbh
if (page.equals(Page.CREATE_DATASET_1)) {
this.reset();
// this.setData("Number of Steps", "5");
} else if (page.equals(Page.CREATE_DATASET_2) || page.equals(Page.CREATE_DATASET_EVENT_ATTR) || page.equals(Page.CREATE_DATASET_SUB_ATTR) || page.equals(Page.CREATE_DATASET_CRF_ATTR) || page.equals(Page.CREATE_DATASET_GROUP_ATTR) || page.equals(Page.CREATE_DATASET_VIEW_SELECTED)) {
HashMap eventlist = (HashMap) request.getAttribute("eventlist");
ArrayList displayData = generateEventTree(eventlist);
this.reset();
this.setUserOrderedData(displayData);
this.setStudyInfoShown(false);
this.setOrderedData(true);
this.setCreateDataset(true);
this.setSubmitDataModule(false);
this.setExtractData(false);
} else if (page.equals(Page.CREATE_DATASET_3)) {
this.reset();
this.setStudyInfoShown(false);
this.setOrderedData(false);
this.setCreateDataset(true);
this.setSubmitDataModule(false);
this.setExtractData(false);
DatasetBean dsb = (DatasetBean) session.getAttribute("newDataset");
int ev_count = dsb.getItemIds().size();
this.setData(resword.getString("items_selected"), new Integer(ev_count).toString());
} else if (page.equals(Page.CREATE_DATASET_4)) {
this.reset();
this.setStudyInfoShown(false);
this.setOrderedData(false);
this.setCreateDataset(true);
this.setSubmitDataModule(false);
this.setExtractData(false);
this.removeData(resword.getString("beginning_date"));
this.removeData(resword.getString("ending_date"));
DatasetBean dsb = (DatasetBean) session.getAttribute("newDataset");
int ev_count = dsb.getItemIds().size();
this.setData(resword.getString("items_selected"), new Integer(ev_count).toString());
if ("01/01/1900".equals(english_sdf.format(dsb.getDateStart()))) {
this.setData(resword.getString("beginning_date"), resword.getString("not_specified"));
} else {
this.setData(resword.getString("beginning_date"), local_sdf.format(dsb.getDateStart()));
}
if ("12/31/2100".equals(english_sdf.format(dsb.getDateEnd()))) {
this.setData(resword.getString("ending_date"), resword.getString("not_specified"));
} else {
this.setData(resword.getString("ending_date"), local_sdf.format(dsb.getDateEnd()));
}
FilterBean fb = (FilterBean) session.getAttribute("newFilter");
if (fb != null) {
this.setData("Added Filter", fb.getName());
}
} else if (page.equals(Page.APPLY_FILTER)) {
DatasetBean dsb = (DatasetBean) session.getAttribute("newDataset");
this.setData(resword.getString("beginning_date"), local_sdf.format(dsb.getDateStart()));
this.setData(resword.getString("ending_date"), local_sdf.format(dsb.getDateEnd()));
} else if (page.equals(Page.CONFIRM_DATASET)) {
this.reset();
this.setStudyInfoShown(false);
this.setOrderedData(false);
this.setCreateDataset(true);
this.setSubmitDataModule(false);
this.setExtractData(false);
DatasetBean dsb = (DatasetBean) session.getAttribute("newDataset");
this.setData(resword.getString("dataset_name"), dsb.getName());
this.setData(resword.getString("dataset_description"), dsb.getDescription());
int ev_count = dsb.getItemIds().size();
this.setData(resword.getString("items_selected"), new Integer(ev_count).toString());
if ("01/01/1900".equals(english_sdf.format(dsb.getDateStart()))) {
this.setData(resword.getString("beginning_date"), resword.getString("not_specified"));
} else {
this.setData(resword.getString("beginning_date"), local_sdf.format(dsb.getDateStart()));
}
if ("12/31/2100".equals(english_sdf.format(dsb.getDateEnd()))) {
this.setData(resword.getString("ending_date"), resword.getString("not_specified"));
} else {
this.setData(resword.getString("ending_date"), local_sdf.format(dsb.getDateEnd()));
}
FilterBean fb = (FilterBean) session.getAttribute("newFilter");
if (fb != null) {
this.setData(resword.getString("added_filter"), fb.getName());
}
} else if (page.equals(Page.CREATE_FILTER_SCREEN_3_1)) {
CRFVersionBean cvBean = (CRFVersionBean) session.getAttribute("cvBean");
this.setData(resword.getString("CRF_version_selected"), cvBean.getName());
} else if (page.equals(Page.CREATE_FILTER_SCREEN_3_2)) {
SectionBean secBean = (SectionBean) session.getAttribute("secBean");
this.setData(resword.getString("section_selected"), secBean.getName());
Collection metadatas = (Collection) request.getAttribute("metadatas");
this.setData(resword.getString("number_of_questions"), new Integer(metadatas.size()).toString());
} else if (page.equals(Page.CREATE_FILTER_SCREEN_4)) {
} else if (page.equals(Page.CREATE_FILTER_SCREEN_5)) {
// blank here to prevent data reset, tbh
} else if (page.equals(Page.ADMIN_SYSTEM)) {
// blank here , info set in servlet itself
} else if (page.equals(Page.VIEW_STUDY_SUBJECT) || page.equals(Page.LIST_EVENTS_FOR_SUBJECT)) {
// special case, unlocks study name, subject name, and
// visits
// TODO set all this up, tbh
/*
* set up the side info panel to create the following upon entry
* from the ViewStudyServlet Study X Subject Y StudyEventDef Z1
* StudyEventDef Z2 <status-tag> CRF A1 <status-tag> CRF A2 Z1
* should be collapsible/expandible, etc.
*
* We can pull things from the session and the request:
*/
/*
* StudyBean study = (StudyBean) request.getAttribute("study");
* StudySubjectBean studySubject = (StudySubjectBean)
* request.getAttribute("studySub"); EntityBeanTable table =
* (EntityBeanTable) request.getAttribute("table"); EventCRFBean
* ecb = (EventCRFBean)request.getAttribute("eventCRF");
* this.reset(); ArrayList rows = table.getRows(); ArrayList
* beans = DisplayStudyEventBean.generateBeansFromRows(rows);
*
*
* addStudyEventTree(study, studySubject, beans, ecb);
*/
// this.setIconInfoShown(false);
// this.setManageSubject(true);
this.reset();
this.setStudyInfoShown(true);
this.setOrderedData(true);
this.setExtractData(false);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
this.setIconInfoShown(false);
this.setManageSubject(true);
request.setAttribute("showDDEIcon", Boolean.TRUE);
} else if (page.equals(Page.ENTER_DATA_FOR_STUDY_EVENT) || page.equals(Page.ENTER_DATA_FOR_STUDY_EVENT_SERVLET)) {
StudyBean study = (StudyBean) session.getAttribute("study");
StudySubjectBean studySubject = (StudySubjectBean) request.getAttribute("studySubject");
ArrayList beans = (ArrayList) request.getAttribute("beans");
EventCRFBean ecb = (EventCRFBean) request.getAttribute("eventCRF");
this.reset();
addStudyEventTree(study, studySubject, beans, ecb, true);
this.setStudyInfoShown(false);
this.setOrderedData(true);
this.setSubmitDataModule(true);
this.setExtractData(false);
this.setCreateDataset(false);
this.setIconInfoShown(false);
} else if (page.equals(Page.INTERVIEWER) || page.equals(Page.TABLE_OF_CONTENTS) || page.equals(Page.TABLE_OF_CONTENTS_SERVLET) || page.equals(Page.INITIAL_DATA_ENTRY) || page.equals(Page.INITIAL_DATA_ENTRY_SERVLET) || page.equals(Page.DOUBLE_DATA_ENTRY) || page.equals(Page.DOUBLE_DATA_ENTRY_SERVLET) || page.equals(Page.ADMIN_EDIT) || page.equals(Page.ADMIN_EDIT_SERVLET)) {
/*
* pages designed to also follow the above format; check to see
* if they are in the session already, and does not refresh.
* TODO refine and test
*/
StudyBean study = (StudyBean) session.getAttribute("study");
StudySubjectBean studySubject = (StudySubjectBean) request.getAttribute("studySubject");
ArrayList beans = (ArrayList) request.getAttribute("beans");
EventCRFBean ecb = (EventCRFBean) request.getAttribute("eventCRF");
this.reset();
addStudyEventTree(study, studySubject, beans, ecb, false);
this.setStudyInfoShown(false);
this.setOrderedData(true);
this.setSubmitDataModule(true);
this.setExtractData(false);
this.setCreateDataset(false);
this.setIconInfoShown(true);
} else if (page.equals(Page.EDIT_DATASET)) {
this.reset();
// HashMap eventlist = (HashMap)
// request.getAttribute("eventlist");
HashMap eventlist = (LinkedHashMap) session.getAttribute("eventsForCreateDataset");
ArrayList displayData = generateEventTree(eventlist);
this.setCreateDataset(true);
this.setOrderedData(true);
this.setUserOrderedData(displayData);
this.setStudyInfoShown(true);
this.setSubmitDataModule(false);
this.setExtractData(false);
DatasetBean dsb = (DatasetBean) request.getAttribute("dataset");
this.setData(resword.getString("dataset_name"), dsb.getName());
this.setData(resword.getString("date_created"), local_sdf.format(dsb.getCreatedDate()));
this.setData(resword.getString("dataset_owner"), dsb.getOwner().getName());
this.setData(resword.getString("date_last_run"), local_sdf.format(dsb.getDateLastRun()));
} else if (page.equals(Page.EXPORT_DATASETS)) {
this.setCreateDataset(false);
} else if (page.equals(Page.GENERATE_DATASET_HTML)) {
DatasetBean db = (DatasetBean) request.getAttribute("dataset");
ExtractBean exbean = (ExtractBean) request.getAttribute("extractBean");
this.reset();
ArrayList displayData = new ArrayList();
displayData = generateDatasetTree(exbean, db);
this.setUserOrderedData(displayData);
this.setStudyInfoShown(false);
this.setOrderedData(true);
this.setExtractData(true);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
} else if (page.equals(Page.LIST_STUDY_SUBJECT) || page.equals(Page.LIST_STUDY_SUBJECTS) || page.equals(Page.SUBMIT_DATA) || page.equals(Page.SUBMIT_DATA_SERVLET)) {
this.reset();
this.setStudyInfoShown(true);
this.setOrderedData(true);
this.setExtractData(false);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
this.setIconInfoShown(false);
this.setManageSubject(true);
// don't want to show DDE icon key for subject matrix page
request.setAttribute("showDDEIcon", Boolean.FALSE);
} else if (page.equals(Page.VIEW_SECTION_DATA_ENTRY) || page.equals(Page.VIEW_SECTION_DATA_ENTRY_SERVLET)) {
this.reset();
this.setStudyInfoShown(true);
this.setOrderedData(true);
this.setExtractData(false);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
this.setIconInfoShown(true);
this.setManageSubject(false);
} else if (page.equals(Page.CREATE_SUBJECT_GROUP_CLASS) || page.equals(Page.CREATE_SUBJECT_GROUP_CLASS_CONFIRM) || page.equals(Page.UPDATE_SUBJECT_GROUP_CLASS) || page.equals(Page.UPDATE_SUBJECT_GROUP_CLASS_CONFIRM)) {
this.reset();
this.setStudyInfoShown(true);
this.setOrderedData(true);
this.setExtractData(false);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
this.setIconInfoShown(true);
this.setManageSubject(false);
} else {
// automatically reset if we don't know what's happening
this.reset();
this.setStudyInfoShown(true);
this.setOrderedData(true);
this.setExtractData(false);
this.setSubmitDataModule(false);
this.setCreateDataset(false);
this.setIconInfoShown(true);
this.setManageSubject(false);
}
} catch (Exception e) {
this.reset();
}
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class SelectItemsServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int crfId = fp.getInt("crfId");
int defId = fp.getInt("defId");
int eventAttr = fp.getInt("eventAttr");
int subAttr = fp.getInt("subAttr");
int CRFAttr = fp.getInt("CRFAttr");
int groupAttr = fp.getInt("groupAttr");
int discAttr = fp.getInt("discAttr");
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
HashMap events = (HashMap) session.getAttribute(CreateDatasetServlet.EVENTS_FOR_CREATE_DATASET);
if (events == null) {
events = new HashMap();
}
request.setAttribute("eventlist", events);
logger.info("found dob setting: " + currentStudy.getStudyParameterConfig().getCollectDob());
if (crfId == 0) {
// no crf selected
if (eventAttr == 0 && subAttr == 0 && CRFAttr == 0 && groupAttr == 0 && discAttr == 0) {
forwardPage(Page.CREATE_DATASET_2);
} else if (eventAttr > 0) {
request.setAttribute("subjectAgeAtEvent", "1");
if (currentStudy.getStudyParameterConfig().getCollectDob().equals("3")) {
request.setAttribute("subjectAgeAtEvent", "0");
logger.info("dob not collected, setting age at event to 0");
}
forwardPage(Page.CREATE_DATASET_EVENT_ATTR);
} else if (subAttr > 0) {
if (currentStudy.getStudyParameterConfig().getCollectDob().equals("3")) {
logger.info("dob not collected, setting age at event to 0");
}
forwardPage(Page.CREATE_DATASET_SUB_ATTR);
} else if (CRFAttr > 0) {
forwardPage(Page.CREATE_DATASET_CRF_ATTR);
} else if (groupAttr > 0) {
// TODO set up subject group classes here?
setUpStudyGroupPage();
forwardPage(Page.CREATE_DATASET_GROUP_ATTR);
} else // else if (discAttr > 0) {
// forwardPage(Page.CREATE_DATASET_DISC_ATTR);
// }
{
forwardPage(Page.CREATE_DATASET_2);
}
return;
}
CRFBean crf = (CRFBean) crfdao.findByPK(crfId);
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(defId);
session.setAttribute("crf", crf);
session.setAttribute("definition", sed);
DatasetBean db = (DatasetBean) session.getAttribute("newDataset");
if (db == null) {
db = new DatasetBean();
}
session.setAttribute("newDataset", db);
// save current def id in the seesion to avoid duplicated def id in
// dataset
// bean
// session.setAttribute(CURRENT_DEF_ID, new Integer(defId));
ArrayList items = idao.findAllActiveByCRF(crf);
for (int i = 0; i < items.size(); i++) {
ItemBean item = (ItemBean) items.get(i);
/*
* logger.info("testing on item id "+ item.getId()+ " crf version id "+
* item.getItemMeta().getCrfVersionId());
*/
ItemFormMetadataBean meta = imfdao.findByItemIdAndCRFVersionId(item.getId(), item.getItemMeta().getCrfVersionId());
// TODO change the above data access function, tbh
// ArrayList metas = imfdao.findAllByItemId(item.getId());
meta.setCrfVersionName(item.getItemMeta().getCrfVersionName());
// logger.info("crf versionname" + meta.getCrfVersionName());
item.getItemMetas().add(meta);
// item.setItemMetas(metas);
}
HashMap itemMap = new HashMap();
for (int i = 0; i < items.size(); i++) {
ItemBean item = (ItemBean) items.get(i);
if (!itemMap.containsKey(defId + "_" + item.getId())) {
if (db.getItemMap().containsKey(defId + "_" + item.getId())) {
item.setSelected(true);
item.setDatasetItemMapKey(defId + "_" + item.getId());
// logger.info("Item got selected already11");
}
// itemMap.put(new Integer(item.getId()), item);
itemMap.put(defId + "_" + item.getId(), item);
} else {
// same item,combine the metadata
ItemBean uniqueItem = (ItemBean) itemMap.get(defId + "_" + item.getId());
uniqueItem.getItemMetas().add(item.getItemMetas().get(0));
if (db.getItemMap().containsKey(defId + "_" + uniqueItem.getId())) {
uniqueItem.setSelected(true);
// logger.info("Item got selected already22");
}
}
}
ArrayList itemArray = new ArrayList(itemMap.values());
// now sort them by ordinal/name
Collections.sort(itemArray);
session.setAttribute("allItems", itemArray);
forwardPage(Page.CREATE_DATASET_2);
}
Aggregations