Search in sources :

Example 46 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class EditDatasetServlet method initializeAttributes.

/**
 * Initialize data of a DatasetBean and set session attributes for displaying selected data of this DatasetBean
 *
 * @param db
 * @return
 */
// @author ywang (Feb, 2008)
public DatasetBean initializeAttributes(int datasetId) {
    DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
    DatasetBean db = dsdao.initialDatasetData(datasetId);
    session.setAttribute("newDataset", db);
    session.setAttribute("allItems", db.getItemDefCrf().clone());
    session.setAttribute("allSelectedItems", db.getItemDefCrf().clone());
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
    ArrayList<StudyGroupClassBean> allSelectedGroups = sgcdao.findAllActiveByStudy(theStudy);
    ArrayList<Integer> selectedSubjectGroupIds = db.getSubjectGroupIds();
    if (selectedSubjectGroupIds != null && allSelectedGroups != null) {
        for (Integer id : selectedSubjectGroupIds) {
            for (int i = 0; i < allSelectedGroups.size(); ++i) {
                if (allSelectedGroups.get(i).getId() == id) {
                    allSelectedGroups.get(i).setSelected(true);
                    break;
                }
            }
        }
    }
    session.setAttribute("allSelectedGroups", allSelectedGroups);
    return db;
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 47 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class EditSelectedServlet method setUpStudyGroups.

/*
     * TODO this function exists in four different places... needs to be added to an additional superclass for Submit Data Control Servlets, tbh July 2007
     */
public void setUpStudyGroups() {
    ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
    if (sgclasses == null || sgclasses.size() == 0) {
        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
        StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
        sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
    }
    session.setAttribute("allSelectedGroups", sgclasses);
    request.setAttribute("allSelectedGroups", sgclasses);
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 48 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class ViewDatasetsServlet method initializeAttributes.

/**
 * Initialize data of a DatasetBean and set session attributes for
 * displaying selected data of this DatasetBean
 *
 * @param db
 * @return
 */
// @author ywang (Feb, 2008)
public DatasetBean initializeAttributes(int datasetId) {
    DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
    DatasetBean db = dsdao.initialDatasetData(datasetId);
    session.setAttribute("newDataset", db);
    session.setAttribute("allItems", db.getItemDefCrf().clone());
    session.setAttribute("allSelectedItems", db.getItemDefCrf().clone());
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
    ArrayList<StudyGroupClassBean> allSelectedGroups = sgcdao.findAllActiveByStudy(theStudy);
    ArrayList<Integer> selectedSubjectGroupIds = db.getSubjectGroupIds();
    if (selectedSubjectGroupIds != null && allSelectedGroups != null) {
        for (Integer id : selectedSubjectGroupIds) {
            for (int i = 0; i < allSelectedGroups.size(); ++i) {
                if (allSelectedGroups.get(i).getId() == id) {
                    allSelectedGroups.get(i).setSelected(true);
                    break;
                }
            }
        }
    }
    session.setAttribute("allSelectedGroups", allSelectedGroups);
    return db;
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 49 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class ViewSelectedServlet method setUpStudyGroups.

/*
     * setup study groups, tbh, added july 2007 FIXME in general a repeated set
     * of code -- need to create a superclass which will contain this class, tbh
     */
public void setUpStudyGroups() {
    ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
    if (sgclasses == null || sgclasses.size() == 0) {
        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
        StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
        sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
    }
    session.setAttribute("allSelectedGroups", sgclasses);
    session.setAttribute("numberOfStudyGroups", sgclasses.size());
    request.setAttribute("allSelectedGroups", sgclasses);
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 50 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class ViewStudyServlet method processRequest.

@Override
public void processRequest() throws Exception {
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt("id");
    if (studyId == 0) {
        addPageMessage(respage.getString("please_choose_a_study_to_view"));
        forwardPage(Page.STUDY_LIST_SERVLET);
    } else {
        if (currentStudy.getId() != studyId && currentStudy.getParentStudyId() != studyId) {
            checkRoleByUserAndStudy(ub, studyId, 0);
        }
        String viewFullRecords = fp.getString("viewFull");
        StudyBean study = (StudyBean) sdao.findByPK(studyId);
        StudyConfigService scs = new StudyConfigService(sm.getDataSource());
        study = scs.setParametersForStudy(study);
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        String randomizationStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "randomization").getValue();
        String participantStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "participantPortal").getValue();
        if (participantStatusInOC == "")
            participantStatusInOC = "disabled";
        if (randomizationStatusInOC == "")
            randomizationStatusInOC = "disabled";
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid(), false);
        if (seRandomizationDTO != null && seRandomizationDTO.getStatus().equalsIgnoreCase("ACTIVE") && randomizationStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setRandomization("enabled");
        } else {
            study.getStudyParameterConfig().setRandomization("disabled");
        }
        ;
        ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
        String pStatus = participantPortalRegistrar.getCachedRegistrationStatus(study.getOid(), session);
        if (participantPortalRegistrar != null && pStatus.equalsIgnoreCase("ACTIVE") && participantStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setParticipantPortal("enabled");
        } else {
            study.getStudyParameterConfig().setParticipantPortal("disabled");
        }
        ;
        request.setAttribute("studyToView", study);
        if ("yes".equalsIgnoreCase(viewFullRecords)) {
            UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            ArrayList sites = new ArrayList();
            ArrayList userRoles = new ArrayList();
            ArrayList subjects = new ArrayList();
            if (this.currentStudy.getParentStudyId() > 0 && this.currentRole.getRole().getId() > 3) {
                sites.add(this.currentStudy);
                userRoles = udao.findAllUsersByStudy(currentStudy.getId());
                subjects = ssdao.findAllByStudy(currentStudy);
            } else {
                sites = (ArrayList) sdao.findAllByParent(studyId);
                userRoles = udao.findAllUsersByStudy(studyId);
                subjects = ssdao.findAllByStudy(study);
            }
            // find all subjects in the study, include ones in sites
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
            EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
            // StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
            // ArrayList displayStudySubs = new ArrayList();
            // for (int i = 0; i < subjects.size(); i++) {
            // StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
            // // find all events
            // ArrayList events = sedao.findAllByStudySubject(studySub);
            // 
            // // find all eventcrfs for each event
            // EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            // 
            // DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
            // dssb.setStudyEvents(events);
            // dssb.setStudySubject(studySub);
            // displayStudySubs.add(dssb);
            // }
            // find all events in the study, include ones in sites
            ArrayList definitions = seddao.findAllByStudy(study);
            for (int i = 0; i < definitions.size(); i++) {
                StudyEventDefinitionBean def = (StudyEventDefinitionBean) definitions.get(i);
                ArrayList crfs = (ArrayList) edcdao.findAllActiveParentsByEventDefinitionId(def.getId());
                def.setCrfNum(crfs.size());
            }
            String moduleManager = CoreResources.getField("moduleManager");
            request.setAttribute("moduleManager", moduleManager);
            String portalURL = CoreResources.getField("portalURL");
            request.setAttribute("portalURL", portalURL);
            request.setAttribute("config", study);
            request.setAttribute("sitesToView", sites);
            request.setAttribute("siteNum", sites.size() + "");
            request.setAttribute("userRolesToView", userRoles);
            request.setAttribute("userNum", userRoles.size() + "");
            // request.setAttribute("subjectsToView", displayStudySubs);
            // request.setAttribute("subjectNum", subjects.size() + "");
            request.setAttribute("definitionsToView", definitions);
            request.setAttribute("defNum", definitions.size() + "");
            forwardPage(Page.VIEW_FULL_STUDY);
        } else {
            forwardPage(Page.VIEW_STUDY);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)205 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)184 ArrayList (java.util.ArrayList)116 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)73 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)59 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)50 Date (java.util.Date)49 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)49 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)47 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)43 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)43 HashMap (java.util.HashMap)42 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)39 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)35 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)34 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)30