use of org.akaza.openclinica.view.form.ViewPersistanceHandler in project OpenClinica by OpenClinica.
the class DisplaySectionBeanHandler method getDisplaySectionBeans.
/**
* This method creates a List of DisplaySectionBeans, returning them in the
* order that the sections appear in a CRF. This List is "lazily"
* initialized the first time it is requested.
*
* @return A List of DisplaySectionBeans.
* @see org.akaza.openclinica.control.managestudy.PrintCRFServlet
* @see org.akaza.openclinica.control.managestudy.PrintDataEntryServlet
*/
public List<DisplaySectionBean> getDisplaySectionBeans() {
FormBeanUtil formBeanUtil;
ViewPersistanceHandler persistanceHandler;
ArrayList<SectionBean> allCrfSections;
// DAO classes for getting item definitions
SectionDAO sectionDao;
CRFVersionDAO crfVersionDao;
if (displaySectionBeans == null) {
displaySectionBeans = new ArrayList<DisplaySectionBean>();
formBeanUtil = new FormBeanUtil();
if (hasStoredData)
persistanceHandler = new ViewPersistanceHandler();
// We need a CRF version id to populate the form display
if (this.crfVersionId == 0) {
return displaySectionBeans;
}
sectionDao = new SectionDAO(dataSource);
allCrfSections = (ArrayList) sectionDao.findByVersionId(this.crfVersionId);
// for the purposes of null values, try to obtain a valid
// eventCrfDefinition id
EventDefinitionCRFBean eventDefBean = null;
EventCRFBean eventCRFBean = new EventCRFBean();
if (eventCRFId > 0) {
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
eventCRFBean = (EventCRFBean) ecdao.findByPK(eventCRFId);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
StudyEventBean studyEvent = (StudyEventBean) sedao.findByPK(eventCRFBean.getStudyEventId());
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
StudyDAO sdao = new StudyDAO(dataSource);
StudyBean study = sdao.findByStudySubjectId(eventCRFBean.getStudySubjectId());
eventDefBean = eventDefinitionCRFDAO.findByStudyEventIdAndCRFVersionId(study, studyEvent.getId(), this.crfVersionId);
}
eventDefBean = eventDefBean == null ? new EventDefinitionCRFBean() : eventDefBean;
// Create an array or List of DisplaySectionBeans representing each
// section
// for printing
DisplaySectionBean displaySectionBean;
for (SectionBean sectionBean : allCrfSections) {
displaySectionBean = formBeanUtil.createDisplaySectionBWithFormGroupsForPrint(sectionBean.getId(), this.crfVersionId, dataSource, eventDefBean.getId(), eventCRFBean, context);
displaySectionBeans.add(displaySectionBean);
}
}
return displaySectionBeans;
}
Aggregations