use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class CreateOneDiscrepancyNoteServlet method processRequest.
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
int eventCRFId = fp.getInt(CreateDiscrepancyNoteServlet.EVENT_CRF_ID);
request.setAttribute(CreateDiscrepancyNoteServlet.EVENT_CRF_ID, new Integer(eventCRFId));
int parentId = fp.getInt(PARENT_ID);
DiscrepancyNoteBean parent = parentId > 0 ? (DiscrepancyNoteBean) dndao.findByPK(parentId) : new DiscrepancyNoteBean();
HashMap<Integer, DiscrepancyNoteBean> boxDNMap = (HashMap<Integer, DiscrepancyNoteBean>) session.getAttribute(BOX_DN_MAP);
boxDNMap = boxDNMap == null ? new HashMap<Integer, DiscrepancyNoteBean>() : boxDNMap;
DiscrepancyNoteBean dn = boxDNMap.size() > 0 && boxDNMap.containsKey(Integer.valueOf(parentId)) ? boxDNMap.get(Integer.valueOf(parentId)) : new DiscrepancyNoteBean();
int entityId = fp.getInt(ENTITY_ID, true);
entityId = entityId > 0 ? entityId : parent.getEntityId();
if (entityId == 0) {
Validator.addError(errors, "newChildAdded" + parentId, respage.getString("note_cannot_be_saved"));
logger.info("entityId is 0. Note saving can not be started.");
}
String entityType = fp.getString(ENTITY_TYPE, true);
FormDiscrepancyNotes noteTree = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
if (noteTree == null) {
noteTree = new FormDiscrepancyNotes();
}
String ypos = fp.getString("ypos" + parentId);
int refresh = 0;
String field = fp.getString(ENTITY_FIELD, true);
String description = fp.getString("description" + parentId);
int typeId = fp.getInt("typeId" + parentId);
String detailedDes = fp.getString("detailedDes" + parentId);
int resStatusId = fp.getInt(RES_STATUS_ID + parentId);
int assignedUserAccountId = fp.getInt(SUBMITTED_USER_ACCOUNT_ID + parentId);
String viewNoteLink = fp.getString("viewDNLink" + parentId);
viewNoteLink = this.appendPageFileName(viewNoteLink, "fromBox", "1");
Validator v = new Validator(request);
v.addValidation("description" + parentId, Validator.NO_BLANKS);
v.addValidation("description" + parentId, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("detailedDes" + parentId, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
v.addValidation("typeId" + parentId, Validator.NO_BLANKS);
HashMap errors = v.validate();
dn.setParentDnId(parentId);
dn.setDescription(description);
dn.setDiscrepancyNoteTypeId(typeId);
dn.setDetailedNotes(detailedDes);
dn.setResolutionStatusId(resStatusId);
if (typeId != DiscrepancyNoteType.ANNOTATION.getId() && typeId != DiscrepancyNoteType.REASON_FOR_CHANGE.getId()) {
dn.setAssignedUserId(assignedUserAccountId);
}
if (DiscrepancyNoteType.ANNOTATION.getId() == dn.getDiscrepancyNoteTypeId()) {
updateStudyEvent(entityType, entityId);
updateStudySubjectStatus(entityType, entityId);
}
if (DiscrepancyNoteType.ANNOTATION.getId() == dn.getDiscrepancyNoteTypeId() || DiscrepancyNoteType.REASON_FOR_CHANGE.getId() == dn.getDiscrepancyNoteTypeId()) {
dn.setResStatus(ResolutionStatus.NOT_APPLICABLE);
dn.setResolutionStatusId(ResolutionStatus.NOT_APPLICABLE.getId());
}
if (DiscrepancyNoteType.FAILEDVAL.getId() == dn.getDiscrepancyNoteTypeId() || DiscrepancyNoteType.QUERY.getId() == dn.getDiscrepancyNoteTypeId()) {
if (ResolutionStatus.NOT_APPLICABLE.getId() == dn.getResolutionStatusId()) {
Validator.addError(errors, RES_STATUS_ID + parentId, restext.getString("not_valid_res_status"));
}
}
if (errors.isEmpty()) {
HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
ArrayList<String> mess = new ArrayList<String>();
String column = fp.getString(ENTITY_COLUMN, true);
dn.setOwner(ub);
dn.setStudyId(currentStudy.getId());
dn.setEntityId(entityId);
dn.setEntityType(entityType);
dn.setColumn(column);
dn.setField(field);
if (parentId > 0) {
if (dn.getResolutionStatusId() != parent.getResolutionStatusId()) {
parent.setResolutionStatusId(dn.getResolutionStatusId());
dndao.update(parent);
if (!parent.isActive()) {
logger.info("Failed to update resolution status ID for the parent dn ID = " + parentId + ". ");
}
}
if (dn.getAssignedUserId() != parent.getAssignedUserId()) {
parent.setAssignedUserId(dn.getAssignedUserId());
if (parent.getAssignedUserId() > 0) {
dndao.updateAssignedUser(parent);
} else {
dndao.updateAssignedUserToNull(parent);
}
if (!parent.isActive()) {
logger.info("Failed to update assigned user ID for the parent dn ID= " + parentId + ". ");
}
}
} else {
ypos = "0";
}
dn = (DiscrepancyNoteBean) dndao.create(dn);
boolean success = dn.getId() > 0 ? true : false;
if (success) {
refresh = 1;
dndao.createMapping(dn);
success = dndao.isQuerySuccessful();
if (success == false) {
mess.add(restext.getString("failed_create_dn_mapping_for_dnId") + dn.getId() + ". ");
}
noteTree.addNote(eventCRFId + "_" + field, dn);
noteTree.addIdNote(dn.getEntityId(), field);
session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, noteTree);
if (dn.getParentDnId() == 0) {
// see issue 2659 this is a new thread, we will create
// two notes in this case,
// This way one can be the parent that updates as the
// status changes, but one also stays as New.
dn.setParentDnId(dn.getId());
dn = (DiscrepancyNoteBean) dndao.create(dn);
if (dn.getId() > 0) {
dndao.createMapping(dn);
if (!dndao.isQuerySuccessful()) {
mess.add(restext.getString("failed_create_dn_mapping_for_dnId") + dn.getId() + ". ");
}
noteTree.addNote(eventCRFId + "_" + field, dn);
noteTree.addIdNote(dn.getEntityId(), field);
session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, noteTree);
} else {
mess.add(restext.getString("failed_create_child_dn_for_new_parent_dnId") + dn.getId() + ". ");
}
}
} else {
mess.add(restext.getString("failed_create_new_dn") + ". ");
}
if (success) {
if (boxDNMap.size() > 0 && boxDNMap.containsKey(parentId)) {
boxDNMap.remove(parentId);
}
session.removeAttribute(BOX_TO_SHOW);
/*
* Copied from CreateDiscrepancyNoteServlet
* Setting a marker to check
* later while saving administrative edited data. This is needed to
* make sure the system flags error while changing data for items
* which already has a DiscrepanyNote
*/
manageReasonForChangeState(session, eventCRFId + "_" + field);
String email = fp.getString(EMAIL_USER_ACCOUNT + parentId);
if (dn.getAssignedUserId() > 0 && "1".equals(email.trim())) {
logger.info("++++++ found our way here");
// generate email for user here
StringBuffer message = new StringBuffer();
dn = getNoteInfo(dn);
// generate message here
EmailEngine em = new EmailEngine(EmailEngine.getSMTPHost());
UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
ItemDAO itemDAO = new ItemDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemBean item = new ItemBean();
ItemDataBean itemData = new ItemDataBean();
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
UserAccountBean assignedUser = (UserAccountBean) userAccountDAO.findByPK(dn.getAssignedUserId());
String alertEmail = assignedUser.getEmail();
message.append(MessageFormat.format(respage.getString("mailDNHeader"), assignedUser.getFirstName(), assignedUser.getLastName()));
message.append("<A HREF='" + SQLInitServlet.getField("sysURL.base") + "ViewNotes?module=submit&listNotes_f_discrepancyNoteBean.user=" + assignedUser.getName() + "&listNotes_f_entityName=" + dn.getEntityName() + "'>" + SQLInitServlet.getField("sysURL.base") + "</A><BR/>");
message.append(respage.getString("you_received_this_from"));
StudyBean study = (StudyBean) studyDAO.findByPK(dn.getStudyId());
if ("itemData".equalsIgnoreCase(entityType)) {
itemData = (ItemDataBean) iddao.findByPK(dn.getEntityId());
item = (ItemBean) itemDAO.findByPK(itemData.getItemId());
}
message.append(respage.getString("email_body_separator"));
message.append(respage.getString("disc_note_info"));
message.append(respage.getString("email_body_separator"));
message.append(MessageFormat.format(respage.getString("mailDNParameters1"), dn.getDescription(), dn.getDetailedNotes(), ub.getName()));
message.append(respage.getString("email_body_separator"));
message.append(respage.getString("entity_information"));
message.append(respage.getString("email_body_separator"));
message.append(MessageFormat.format(respage.getString("mailDNParameters2"), study.getName(), dn.getSubjectName()));
if (!("studySub".equalsIgnoreCase(entityType) || "subject".equalsIgnoreCase(entityType))) {
message.append(MessageFormat.format(respage.getString("mailDNParameters3"), dn.getEventName()));
if (!"studyEvent".equalsIgnoreCase(dn.getEntityType())) {
message.append(MessageFormat.format(respage.getString("mailDNParameters4"), dn.getCrfName()));
if (!"eventCrf".equalsIgnoreCase(dn.getEntityType())) {
message.append(MessageFormat.format(respage.getString("mailDNParameters6"), item.getName()));
}
}
}
message.append(respage.getString("email_body_separator"));
message.append(MessageFormat.format(respage.getString("mailDNThanks"), study.getName()));
message.append(respage.getString("email_body_separator"));
message.append(respage.getString("disclaimer"));
message.append(respage.getString("email_body_separator"));
message.append(respage.getString("email_footer"));
/*
*
*
*
* Please select the link below to view the information
* provided. You may need to login to
* OpenClinica_testbed with your user name and password
* after selecting the link. If you receive a page
* cannot be displayed message, please make sure to
* select the Change Study/Site link in the upper right
* table of the page, select the study referenced above,
* and select the link again.
*
* https://openclinica.s-3.com/OpenClinica_testbed/
* ViewSectionDataEntry ?ecId=117§ionId=142&tabId=2
*/
String emailBodyString = message.toString();
sendEmail(alertEmail.trim(), EmailEngine.getAdminEmail(), MessageFormat.format(respage.getString("mailDNSubject"), study.getName(), dn.getEntityName()), emailBodyString, true, null, null, true);
}
String close = fp.getString("close" + parentId);
// session.setAttribute(CLOSE_WINDOW, "true".equals(close)?"true":"");
if ("true".equals(close)) {
addPageMessage(respage.getString("note_saved_into_db"));
addPageMessage(respage.getString("page_close_automatically"));
forwardPage(Page.ADD_DISCREPANCY_NOTE_SAVE_DONE);
logger.info("Should forwardPage to ADD_DISCREPANCY_NOTE_SAVE_DONE.");
} else {
if (parentId == dn.getParentDnId()) {
mess.add(restext.getString("a_new_child_dn_added"));
results.put("newChildAdded" + parentId, mess);
setInputMessages(results);
} else {
addPageMessage(restext.getString("a_new_dn_thread_added"));
}
}
} else {
session.setAttribute(BOX_TO_SHOW, parentId + "");
}
} else {
setInputMessages(errors);
boxDNMap.put(Integer.valueOf(parentId), dn);
session.setAttribute(BOX_TO_SHOW, parentId + "");
}
session.setAttribute(BOX_DN_MAP, boxDNMap);
viewNoteLink = this.appendPageFileName(viewNoteLink, "refresh", refresh + "");
viewNoteLink = this.appendPageFileName(viewNoteLink, "y", ypos != null && ypos.length() > 0 ? ypos : "0");
getServletContext().getRequestDispatcher(viewNoteLink).forward(request, response);
// forwardPage(Page.setNewPage(viewNoteLink, Page.VIEW_DISCREPANCY_NOTE.getTitle()));
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class CreateOneDiscrepancyNoteServlet method updateStudySubjectStatus.
private void updateStudySubjectStatus(String entityType, int entityId) {
if ("itemData".equalsIgnoreCase(entityType)) {
int itemDataId = entityId;
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(event.getStudySubjectId());
if (studySubject.getStatus() != null && studySubject.getStatus().equals(Status.SIGNED)) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
}
if (ec.isSdvStatus()) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
ec.setSdvStatus(false);
ecdao.update(ec);
}
}
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method getDisplayEventCRFs.
/**
* Each of the event CRFs with its corresponding CRFBean. Then generates a
* list of DisplayEventCRFBeans, one for each event CRF.
*
* @param eventCRFs
* The list of event CRFs for this study event.
* @param eventDefinitionCRFs
* The list of event definition CRFs for this study event.
* @return The list of DisplayEventCRFBeans for this study event.
*/
public static ArrayList getDisplayEventCRFs(DataSource ds, ArrayList eventCRFs, ArrayList eventDefinitionCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status, StudyBean study) {
ArrayList answer = new ArrayList();
// HashMap definitionsById = new HashMap();
int i;
/*
* for (i = 0; i < eventDefinitionCRFs.size(); i++) {
* EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
* eventDefinitionCRFs.get(i); definitionsById.put(new
* Integer(edc.getStudyEventDefinitionId()), edc); }
*/
StudyEventDAO sedao = new StudyEventDAO(ds);
CRFDAO cdao = new CRFDAO(ds);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
// populate the event CRF with its crf bean
int crfVersionId = ecb.getCRFVersionId();
CRFBean cb = cdao.findByVersionId(crfVersionId);
ecb.setCrf(cb);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
ecb.setCrfVersion(cvb);
// then get the definition so we can call
// DisplayEventCRFBean.setFlags
int studyEventId = ecb.getStudyEventId();
int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
// EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
// definitionsById.get(new Integer(
// studyEventDefinitionId));
// fix problem of the above code(commented out), find the correct
// edc, note that on definitionId can be related to multiple
// eventdefinitioncrfBeans
EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
// rules updated 112007 tbh
if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
ecb.setStage(DataEntryStage.LOCKED);
// we need to set a SED-wide flag here, because other edcs
// in this event can be filled in and change the status, tbh
} else if (status.equals(SubjectEventStatus.INVALID)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!cb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!cvb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
}
// TODO need to refactor since this is similar to other code, tbh
if (edc != null) {
// System.out.println("edc is not null, need to set flags");
DisplayEventCRFBean dec = new DisplayEventCRFBean();
dec.setEventDefinitionCRF(edc);
// System.out.println("edc.isDoubleEntry()" +
// edc.isDoubleEntry() + ecb.getId());
dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
if (dec.isLocked()) {
// System.out.println("*** found a locked DEC:
// "+edc.getCrfName());
}
ArrayList idata = iddao.findAllByEventCRFId(ecb.getId());
if (!idata.isEmpty()) {
// consider an event crf started only if item data get
// created
answer.add(dec);
}
}
}
return answer;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method isEachRequiredFieldFillout.
protected boolean isEachRequiredFieldFillout(HttpServletRequest request) {
HttpSession session = request.getSession();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
// need to update this method to accomodate dynamics, tbh
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ItemDAO idao = new ItemDAO(getDataSource());
ItemFormMetadataDAO itemFormMetadataDao = new ItemFormMetadataDAO(getDataSource());
// Below code will iterate all shown and hidden required fields/items in a crf version and verify if the data field is filled up with value or if not , then it is a hidden field with no show rule triggered for the item.
ArrayList<ItemFormMetadataBean> shownRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndShownByCrfVersionId(ecb.getCRFVersionId());
ArrayList<ItemFormMetadataBean> hiddenRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndHiddenByCrfVersionId(ecb.getCRFVersionId());
ItemGroupMetadataDAO<String, ArrayList> igdao = new ItemGroupMetadataDAO<String, ArrayList>(dataSource);
ArrayList<ItemDataBean> itemdatas = null;
for (ItemFormMetadataBean shownItemMeta : shownRequiredAllItemsInCrfVersion) {
ItemGroupMetadataBean igBean = (ItemGroupMetadataBean) igdao.findByItemAndCrfVersion(shownItemMeta.getItemId(), ecb.getCRFVersionId());
// verifies if the group that the item belongs to is not hidden.
if (igBean != null && igBean.isShowGroup()) {
itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), shownItemMeta.getItemId());
if (itemdatas == null || itemdatas.size() == 0)
return false;
for (ItemDataBean itemdata : itemdatas) {
System.out.println(itemdata.getItemId() + " : " + itemdata.getValue());
if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1) {
return false;
}
}
}
ArrayList<DynamicsItemFormMetadataBean> dynamicsItemFormMetadataBeans = null;
for (ItemFormMetadataBean hiddenItemMeta : hiddenRequiredAllItemsInCrfVersion) {
itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), hiddenItemMeta.getItemId());
dynamicsItemFormMetadataBeans = getItemMetadataService().getDynamicsItemFormMetadataDao().findByItemAndEventCrfShown(ecb, hiddenItemMeta.getItemId());
if (itemdatas.size() == 0 && dynamicsItemFormMetadataBeans.size() > 0) {
return false;
}
for (ItemDataBean itemdata : itemdatas) {
if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1 && dynamicsItemFormMetadataBeans.size() > 0) {
return false;
}
}
}
}
// had to change the query below to allow for hidden items here, tbh 04/2010
ArrayList allFilled = iddao.findAllBlankRequiredByEventCRFId(ecb.getId(), ecb.getCRFVersionId());
int numNotes = 0;
if (!allFilled.isEmpty()) {
LOGGER.trace("allFilled is not empty");
FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
HashMap idNotes = fdn.getIdNotes();
for (int i = 0; i < allFilled.size(); i++) {
ItemDataBean idb = (ItemDataBean) allFilled.get(i);
int exsitingNotes = dndao.findNumExistingNotesForItem(idb.getId());
if (exsitingNotes > 0) {
LOGGER.trace("has existing note");
numNotes++;
} else if (idNotes.containsKey(idb.getId())) {
LOGGER.trace("has note in session");
numNotes++;
}
}
LOGGER.trace("numNotes allFilled.size:" + numNotes + " " + allFilled.size());
if (numNotes >= allFilled.size()) {
LOGGER.trace("all required are filled out");
return true;
} else {
LOGGER.debug("numNotes < allFilled.size() " + numNotes + ": " + allFilled.size());
return false;
}
}
return true;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method getAllDisplayBeans.
/**
* Retrieve the DisplaySectionBean which will be used to display the Event CRF Section on the JSP, and also is used to controll processRequest.
* @param request TODO
*/
protected ArrayList getAllDisplayBeans(HttpServletRequest request) throws Exception {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ArrayList sections = new ArrayList();
HttpSession session = request.getSession();
StudyBean study = (StudyBean) session.getAttribute("study");
SectionDAO sdao = new SectionDAO(getDataSource());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
// ALL_SECTION_BEANS
ArrayList<SectionBean> allSectionBeans = (ArrayList<SectionBean>) request.getAttribute(ALL_SECTION_BEANS);
for (int j = 0; j < allSectionBeans.size(); j++) {
SectionBean sb = allSectionBeans.get(j);
DisplaySectionBean section = new DisplaySectionBean();
section.setEventCRF(ecb);
if (sb.getParentId() > 0) {
SectionBean parent = (SectionBean) sdao.findByPK(sb.getParentId());
sb.setParent(parent);
}
section.setSection(sb);
CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
section.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(getDataSource());
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
section.setCrf(cb);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
EventDefinitionCRFBean edcb = edcdao.findByStudyEventIdAndCRFVersionId(study, ecb.getStudyEventId(), cvb.getId());
section.setEventDefinitionCRF(edcb);
// setup DAO's here to avoid creating too many objects
ItemDAO idao = new ItemDAO(getDataSource());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
iddao = new ItemDataDAO(getDataSource(), locale);
// get all the display item beans
ArrayList displayItems = getParentDisplayItems(false, sb, edcb, idao, ifmdao, iddao, false, request);
LOGGER.debug("222 just ran get parent display, has group " + " FALSE has ungrouped FALSE");
// now sort them by ordinal
Collections.sort(displayItems);
// now get the child DisplayItemBeans
for (int i = 0; i < displayItems.size(); i++) {
DisplayItemBean dib = (DisplayItemBean) displayItems.get(i);
dib.setChildren(getChildrenDisplayItems(dib, edcb, request));
if (shouldLoadDBValues(dib)) {
LOGGER.trace("should load db values is true, set value");
dib.loadDBValue();
}
displayItems.set(i, dib);
}
section.setItems(displayItems);
sections.add(section);
}
return sections;
}
Aggregations