use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method getChildrenDisplayItems.
/**
* Get the DisplayItemBean objects corresponding to the items which are children of the specified parent.
*
* @param parent
* The item whose children are to be retrieved.
* @param request TODO
* @return An array of DisplayItemBean objects corresponding to the items which are children of parent, and are sorted by column number (ascending), then
* ordinal (ascending).
*/
private ArrayList getChildrenDisplayItems(DisplayItemBean parent, EventDefinitionCRFBean edcb, HttpServletRequest request) {
ArrayList answer = new ArrayList();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
int parentId = parent.getItem().getId();
ItemDAO idao = new ItemDAO(getDataSource());
ArrayList childItemBeans = idao.findAllByParentIdAndCRFVersionId(parentId, ecb.getCRFVersionId());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
for (int i = 0; i < childItemBeans.size(); i++) {
ItemBean child = (ItemBean) childItemBeans.get(i);
ItemDataBean data = iddao.findByItemIdAndEventCRFId(child.getId(), ecb.getId());
ItemFormMetadataBean metadata = ifmdao.findByItemIdAndCRFVersionId(child.getId(), ecb.getCRFVersionId());
DisplayItemBean dib = new DisplayItemBean();
dib.setEventDefinitionCRF(edcb);
dib.setItem(child);
// tbh
if (!getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
dib.setData(data);
}
// <<tbh 07/2009, bug #3883
// ItemDataBean dbData = iddao.findByItemIdAndEventCRFIdAndOrdinal(itemId, eventCRFId, ordinal)
dib.setDbData(data);
boolean showItem = getItemMetadataService().isShown(metadata.getItemId(), ecb, data);
if (getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
showItem = getItemMetadataService().hasPassedDDE(metadata, ecb, data);
}
// boolean passedDDE = getItemMetadataService().hasPassedDDE(data);
if (showItem) {
LOGGER.debug("set show item: " + metadata.getItemId() + " data " + data.getId());
// metadata.setShowItem(showItem);
metadata.setShowItem(true);
}
// logger.debug("did not catch NPE");
dib.setMetadata(metadata);
if (shouldLoadDBValues(dib)) {
LOGGER.trace("should load db values is true, set value");
dib.loadDBValue();
LOGGER.trace("just loaded the child value: " + dib.getData().getValue());
}
answer.add(dib);
}
// this is a pretty slow and memory intensive way to sort... see if we
// can
// have the db do this instead
Collections.sort(answer);
return answer;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method loadFormValueForItemGroup.
/**
* This methods will create an array of DisplayItemGroupBean, which contains multiple rows for an item group on the data entry form.
*
* @param digb
* The Item group which has multiple data rows
* @param dbGroups
* The original array got from DB which contains multiple data rows
* @param formGroups
* The new array got from front end which contains multiple data rows
* @param request
* FormProcessor holds the form data in a key-value pair with the following structure
* The first row of data points and new rows have a key that looks like GROUPOID_XinputITEMID
* example: IG_01REP_01REPEATING_0input3008
* The existing rows of data points have a key that looks like GROUPOID_manualXinputITEMID
* example: IG_01REP_01REPEATING_manual1input3008
* @return new constructed formGroups, compare to dbGroups, some rows are update, some new ones are added and some are removed
*/
protected List<DisplayItemGroupBean> loadFormValueForItemGroup(DisplayItemGroupBean digb, List<DisplayItemGroupBean> dbGroups, List<DisplayItemGroupBean> formGroups, int eventDefCRFId, HttpServletRequest request) {
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
int repeatMax = digb.getGroupMetaBean().getRepeatMax();
FormProcessor fp = new FormProcessor(request);
ItemDAO idao = new ItemDAO(getDataSource());
List<ItemBean> itBeans = idao.findAllItemsByGroupId(digb.getItemGroupBean().getId(), sb.getCRFVersionId());
LOGGER.debug("+++ starting to review groups: " + repeatMax);
long timeCheck = System.currentTimeMillis();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
// adding this code from below, since we want to pass a null values list
// in all cases of getDisplayBeansFromItems().
// For adding null values to display items
FormBeanUtil formBeanUtil = new FormBeanUtil();
List<String> nullValuesList = new ArrayList<String>();
// BWP>> Get a List<String> of any null values such as NA or NI
// method returns null values as a List<String>
nullValuesList = formBeanUtil.getNullValuesByEventCRFDefId(eventDefCRFId, getDataSource());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
int maxOrdinal = iddao.getMaxOrdinalForGroup(ecb, sb, digb.getItemGroupBean());
repeatMax = (repeatMax < maxOrdinal) ? maxOrdinal : repeatMax;
// //////////////////////////////////////////////////////////////////////////////////////////
// counter for rows preexisting data
int manualRows = 1;
// holds the ordinal of new data
int newDataRowOrdinal = 0;
// Size of existing repeating data retrieved from database
int existingGroupSize = dbGroups.size();
// Need to go through all of the rows of data
for (int i = 0; i < repeatMax; i++) {
DisplayItemGroupBean formGroup = new DisplayItemGroupBean();
formGroup.setItemGroupBean(digb.getItemGroupBean());
formGroup.setGroupMetaBean(runDynamicsCheck(digb.getGroupMetaBean(), request));
ItemGroupBean igb = digb.getItemGroupBean();
// want to do deep copy here, so always get a fresh copy for items,
// may use other better way to do, like clone
List<DisplayItemBean> dibs = FormBeanUtil.getDisplayBeansFromItems(itBeans, getDataSource(), ecb, sb.getId(), nullValuesList, getServletContext());
// Process preexisting data marked by the word "manual" from the UI
if (fp.getStartsWith(igb.getOid() + "_manual" + i + "input")) {
formGroup.setOrdinal(i);
formGroup.setFormInputOrdinal(i);
formGroup.setAuto(false);
formGroup.setInputId(igb.getOid() + "_manual" + i);
LOGGER.debug("1: set auto to false for " + igb.getOid() + " " + i);
dibs = processInputForGroupItem(fp, dibs, i, digb, false);
formGroup.setItems(dibs);
formGroups.add(formGroup);
manualRows++;
} else if (!StringUtil.isBlank(fp.getString(igb.getOid() + "_manual" + i + ".newRow"))) {
formGroup.setOrdinal(i);
formGroup.setFormInputOrdinal(i);
formGroup.setInputId(igb.getOid() + "_manual" + i + ".newRow");
formGroup.setAuto(false);
LOGGER.debug("2: set auto to false for " + igb.getOid() + " " + i);
dibs = processInputForGroupItem(fp, dibs, i, digb, false);
formGroup.setItems(dibs);
formGroups.add(formGroup);
manualRows++;
} else if (manualRows == existingGroupSize || isNewRepeatingDataPresent(fp, i, igb)) {
// process the new data of repeating group instances
if (i == 0) {
formGroup = processNewDataInRepeatingGroup(fp, igb, i, dibs, digb, formGroup);
} else {
formGroup = processNewDataInRepeatingGroup(fp, igb, newDataRowOrdinal, dibs, digb, formGroup);
}
// within the remaining data group displayed on the form
if (formGroup != null) {
if (formGroup.isAuto() && formGroup.getFormInputOrdinal() > 0) {
LOGGER.trace("+++ formInputOrdinal() " + formGroup.getFormInputOrdinal());
// rows included in the model: first row, last existing row and
// new rows
// the rows in between are manually added
// set the correct ordinal that will be saved into DB
// the rows generated by model starts from 0, need to add the
// number of manual rows to
// get the correct ordinals, otherwise, we will have duplicate
// ordinals like two ordinal 0
// formGroup.size() + 1 is the ordinal position of the new data point
formGroup.setOrdinal(formGroups.size() + 1);
}
formGroups.add(formGroup);
}
newDataRowOrdinal++;
}
}
request.setAttribute("manualRows", new Integer(manualRows));
LOGGER.debug(" manual rows " + manualRows + " formGroup size " + formGroups.size());
// sort all the rows by ordinal
Collections.sort(formGroups);
// to tell OC what is new data and what data needs to be updated
for (int j = 0; j < formGroups.size(); j++) {
DisplayItemGroupBean formItemGroup = formGroups.get(j);
LOGGER.trace("formGroup Ordinal:" + formItemGroup.getOrdinal());
// Ready new data group to be added or existing data edited, respectively
if (formItemGroup.getOrdinal() > dbGroups.size() - 1) {
formItemGroup.setEditFlag("add");
} else {
// match existing data with data from form to update at the correct position
DisplayItemGroupBean dbItemGroup = dbGroups.get(j);
if (formItemGroup.getOrdinal() == j) {
// display, so need to insert this row, not update
if ("initial".equalsIgnoreCase(dbItemGroup.getEditFlag())) {
formItemGroup.setEditFlag("add");
} else {
dbItemGroup.setEditFlag("edit");
// need to set up item data id in order to update
for (DisplayItemBean dib : dbItemGroup.getItems()) {
ItemDataBean data = dib.getData();
for (DisplayItemBean formDib : formItemGroup.getItems()) {
if (formDib.getItem().getId() == dib.getItem().getId()) {
formDib.getData().setId(data.getId());
// this will save the data from IDE
// complete, used only for DDE
formDib.setDbData(dib.getData());
// tbh removed below line so as not to
// log so much, 112007
LOGGER.debug("+++ +++ form dib get data set id " + data.getId());
break;
}
}
}
formItemGroup.setEditFlag("edit");
}
}
}
}
LOGGER.trace("+++ === DB group row:" + dbGroups.size());
LOGGER.trace("+++ === DB group contents: " + dbGroups.toString());
// cannot get it.-jxu
for (int i = 0; i < dbGroups.size(); i++) {
DisplayItemGroupBean dbItemGroup = dbGroups.get(i);
LOGGER.trace("+++ found edit flag of " + dbItemGroup.getEditFlag() + " for #" + dbItemGroup.getOrdinal());
// logger.debug("+++ found edit flag of " + dbItemGroup.getEditFlag() + " for #" + dbItemGroup.getOrdinal() + ": " + i);
if (!"edit".equalsIgnoreCase(dbItemGroup.getEditFlag()) && !"initial".equalsIgnoreCase(dbItemGroup.getEditFlag())) {
// >> tbh if the group is not shown, we should not touch it 05/2010
if (dbItemGroup.getGroupMetaBean().isShowGroup()) {
LOGGER.trace("+++ one row removed, edit flag was " + dbItemGroup.getEditFlag());
LOGGER.debug("+++ one row removed, edit flag was " + dbItemGroup.getEditFlag());
dbItemGroup.setEditFlag("remove");
}
// << tbh
}
}
LOGGER.debug("+++ about to return form groups: " + formGroups.toString());
for (int j = 0; j < formGroups.size(); j++) {
DisplayItemGroupBean formGroup = formGroups.get(j);
formGroup.setIndex(j);
}
return formGroups;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method createItemWithGroups.
// @pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method createItemWithGroups
protected List<DisplayItemWithGroupBean> createItemWithGroups(DisplaySectionBean dsb, boolean hasItemGroup, int eventCRFDefId, HttpServletRequest request, boolean isSubmitted) {
HttpSession session = request.getSession();
List<DisplayItemWithGroupBean> displayItemWithGroups = new ArrayList<DisplayItemWithGroupBean>();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ItemDAO idao = new ItemDAO(getDataSource());
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
// BWP>> Get a List<String> of any null values such as NA or NI
// method returns null values as a List<String>
// >>BWP
ArrayList items = dsb.getItems();
// For adding null values to display items
FormBeanUtil formBeanUtil = new FormBeanUtil();
List<String> nullValuesList = formBeanUtil.getNullValuesByEventCRFDefId(eventCRFDefId, getDataSource());
LOGGER.trace("single items size: " + items.size());
for (int i = 0; i < items.size(); i++) {
DisplayItemBean item = (DisplayItemBean) items.get(i);
DisplayItemWithGroupBean newOne = new DisplayItemWithGroupBean();
newOne.setSingleItem(runDynamicsItemCheck(item, null, request));
newOne.setOrdinal(item.getMetadata().getOrdinal());
newOne.setInGroup(false);
newOne.setPageNumberLabel(item.getMetadata().getPageNumberLabel());
displayItemWithGroups.add(newOne);
// logger.trace("just added on line 1979:
// "+newOne.getSingleItem().getData().getValue());
}
if (hasItemGroup) {
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ArrayList<ItemDataBean> data = iddao.findAllBySectionIdAndEventCRFId(sb.getId(), ecb.getId());
HashMap<String, ItemDataBean> dataMap = (HashMap<String, ItemDataBean>) getAllActive(data);
if (data != null && data.size() > 0) {
session.setAttribute(HAS_DATA_FLAG, true);
}
LOGGER.trace("found data: " + data.size());
LOGGER.trace("data.toString: " + data.toString());
for (DisplayItemGroupBean itemGroup : dsb.getDisplayFormGroups()) {
LOGGER.debug("found one itemGroup");
DisplayItemWithGroupBean newOne = new DisplayItemWithGroupBean();
// to arrange item groups and other single items, the ordinal of
// a item group will be the ordinal of the first item in this
// group
DisplayItemBean firstItem = itemGroup.getItems().get(0);
// so we are either checking the first or the last item, BUT ONLY ONCE
newOne.setPageNumberLabel(firstItem.getMetadata().getPageNumberLabel());
newOne.setItemGroup(itemGroup);
newOne.setInGroup(true);
newOne.setOrdinal(itemGroup.getGroupMetaBean().getOrdinal());
List<ItemBean> itBeans = idao.findAllItemsByGroupIdOrdered(itemGroup.getItemGroupBean().getId(), sb.getCRFVersionId());
List<DisplayItemBean> dibs = new ArrayList();
boolean hasData = false;
int checkAllColumns = 0;
if (data.size() > 0)
hasData = true;
// @pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
newOne = buildMatrixForRepeatingGroups(newOne, itemGroup, ecb, sb, itBeans, dataMap, nullValuesList, isSubmitted);
if (hasData) {
// TODO: fix the group_has_data flag on bean not on session
session.setAttribute(GROUP_HAS_DATA, Boolean.TRUE);
} else {
session.setAttribute(GROUP_HAS_DATA, Boolean.FALSE);
// no data, still add a blank row for displaying
if (nullValuesList != null && nullValuesList.size() > 0) {
LOGGER.trace("set with nullValuesList of : " + nullValuesList);
}
dibs = FormBeanUtil.getDisplayBeansFromItems(itBeans, getDataSource(), ecb, sb.getId(), nullValuesList, getServletContext());
DisplayItemGroupBean digb2 = new DisplayItemGroupBean();
digb2.setItems(dibs);
digb2.setEditFlag("initial");
}
displayItemWithGroups.add(newOne);
}
}
// if hasItemGroup
Collections.sort(displayItemWithGroups);
return displayItemWithGroups;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
public static ArrayList getUncompletedCRFs(DataSource ds, ArrayList eventDefinitionCRFs, ArrayList eventCRFs, SubjectEventStatus status) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
// System.out.println("########event crf id:" + ecrf.getId());
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
// System.out.println("added one into startedButIncompleted" + ecrf.getId());
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// System.out.println("created dedc with edcrf
// "+edcrf.getCrfName()+" default version "+
// edcrf.getDefaultVersionName()+", id
// "+edcrf.getDefaultVersionId());
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
// System.out.println("entered boolean loop with ev
// "+ev.getId()+" crf version id "+
// ev.getCRFVersionId());
dedc.setEventCRF(ev);
answer.add(dedc);
// System.out.println("just added dedc to answer");
// removed, tbh, since this is proving nothing, 11-2007
/*
* if (dedc.getEdc().getDefaultVersionId() !=
* dedc.getEventCRF().getId()) { System.out.println("ID
* MISMATCH: edc name "+dedc.getEdc().getName()+ ", default
* version id "+dedc.getEdc().getDefaultVersionId()+ " event crf
* id "+dedc.getEventCRF().getId()); }
*/
}
}
// System.out.println("size of answer" + answer.size());
return answer;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class ViewStudySubjectAuditLogServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
AuditDAO adao = new AuditDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyDAO studydao = new StudyDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
ArrayList studySubjectAudits = new ArrayList();
ArrayList eventCRFAudits = new ArrayList();
ArrayList studyEventAudits = new ArrayList();
ArrayList allDeletedEventCRFs = new ArrayList();
String attachedFilePath = Utils.getAttachedFilePath(currentStudy);
// studySubjectId
int studySubId = fp.getInt("id", true);
request.setAttribute("id", studySubId);
if (studySubId == 0) {
addPageMessage(respage.getString("please_choose_a_subject_to_view"));
forwardPage(Page.LIST_STUDY_SUBJECTS);
} else {
StudySubjectBean studySubject = (StudySubjectBean) subdao.findByPK(studySubId);
StudyBean study = (StudyBean) studydao.findByPK(studySubject.getStudyId());
// Check if this StudySubject would be accessed from the Current Study
if (studySubject.getStudyId() != currentStudy.getId()) {
if (currentStudy.getParentStudyId() > 0) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
} else {
// The SubjectStudy is not belong to currentstudy and current study is not a site.
Collection sites = studydao.findOlnySiteIdsByStudy(currentStudy);
if (!sites.contains(study.getId())) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
}
}
request.setAttribute("studySub", studySubject);
SubjectBean subject = (SubjectBean) sdao.findByPK(studySubject.getSubjectId());
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
study.getStudyParameterConfig().setCollectDob(spvdao.findByHandleAndStudy(study.getId(), "collectDob").getValue());
String collectdob = "used";
if (study.getStudyParameterConfig().getCollectDob().equals("2")) {
collectdob = "yearOnly";
} else if (study.getStudyParameterConfig().getCollectDob().equals("3")) {
collectdob = "notUsed";
} else if (study.getStudyParameterConfig().getCollectDob().equals("1")) {
collectdob = "used";
}
request.setAttribute("collectdob", collectdob);
request.setAttribute("subject", subject);
request.setAttribute("study", study);
/* Show both study subject and subject audit events together */
// Study subject value changed
Collection studySubjectAuditEvents = adao.findStudySubjectAuditEvents(studySubject.getId());
// integer values.
for (Iterator iterator = studySubjectAuditEvents.iterator(); iterator.hasNext(); ) {
AuditBean auditBean = (AuditBean) iterator.next();
if (auditBean.getAuditEventTypeId() == 3) {
auditBean.setOldValue(Status.get(Integer.parseInt(auditBean.getOldValue())).getName());
auditBean.setNewValue(Status.get(Integer.parseInt(auditBean.getNewValue())).getName());
}
}
studySubjectAudits.addAll(studySubjectAuditEvents);
// Global subject value changed
studySubjectAudits.addAll(adao.findSubjectAuditEvents(subject.getId()));
studySubjectAudits.addAll(adao.findStudySubjectGroupAssignmentAuditEvents(studySubject.getId()));
request.setAttribute("studySubjectAudits", studySubjectAudits);
// Get the list of events
ArrayList events = sedao.findAllByStudySubject(studySubject);
for (int i = 0; i < events.size(); i++) {
// Link study event definitions
StudyEventBean studyEvent = (StudyEventBean) events.get(i);
studyEvent.setStudyEventDefinition((StudyEventDefinitionBean) seddao.findByPK(studyEvent.getStudyEventDefinitionId()));
// Link event CRFs
studyEvent.setEventCRFs(ecdao.findAllByStudyEvent(studyEvent));
// Find deleted Event CRFs
List deletedEventCRFs = adao.findDeletedEventCRFsFromAuditEventByEventCRFStatus(studyEvent.getId());
allDeletedEventCRFs.addAll(deletedEventCRFs);
logger.info("deletedEventCRFs size[" + deletedEventCRFs.size() + "]");
}
for (int i = 0; i < events.size(); i++) {
StudyEventBean studyEvent = (StudyEventBean) events.get(i);
studyEventAudits.addAll(adao.findStudyEventAuditEvents(studyEvent.getId()));
ArrayList eventCRFs = studyEvent.getEventCRFs();
for (int j = 0; j < eventCRFs.size(); j++) {
// Link CRF and CRF Versions
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(j);
eventCRF.setCrfVersion((CRFVersionBean) cvdao.findByPK(eventCRF.getCRFVersionId()));
eventCRF.setCrf(cdao.findByVersionId(eventCRF.getCRFVersionId()));
// Get the event crf audits
eventCRFAudits.addAll(adao.findEventCRFAuditEventsWithItemDataType(eventCRF.getId()));
logger.info("eventCRFAudits size [" + eventCRFAudits.size() + "] eventCRF id [" + eventCRF.getId() + "]");
}
}
ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource());
for (Object o : eventCRFAudits) {
AuditBean ab = (AuditBean) o;
if (ab.getAuditTable().equalsIgnoreCase("item_data")) {
ItemDataBean idBean = (ItemDataBean) itemDataDao.findByPK(ab.getEntityId());
ab.setOrdinal(idBean.getOrdinal());
}
}
request.setAttribute("events", events);
request.setAttribute("eventCRFAudits", eventCRFAudits);
request.setAttribute("studyEventAudits", studyEventAudits);
request.setAttribute("allDeletedEventCRFs", allDeletedEventCRFs);
request.setAttribute("attachedFilePath", attachedFilePath);
forwardPage(Page.VIEW_STUDY_SUBJECT_AUDIT);
}
}
Aggregations