Search in sources :

Example 1 with ViewPersistanceHandler

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;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormBeanUtil(org.akaza.openclinica.view.form.FormBeanUtil) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) ViewPersistanceHandler(org.akaza.openclinica.view.form.ViewPersistanceHandler) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Aggregations

EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)1 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)1 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)1 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)1 SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)1 FormBeanUtil (org.akaza.openclinica.view.form.FormBeanUtil)1 ViewPersistanceHandler (org.akaza.openclinica.view.form.ViewPersistanceHandler)1