Search in sources :

Example 6 with StudyGroupClassDAO

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

the class SecureController method getStudyGroupClassesByCurrentStudy.

public ArrayList getStudyGroupClassesByCurrentStudy() {
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(sm.getDataSource());
    StudyGroupDAO studyGroupDAO = new StudyGroupDAO(sm.getDataSource());
    int parentStudyId = currentStudy.getParentStudyId();
    ArrayList studyGroupClasses = new ArrayList();
    if (parentStudyId > 0) {
        StudyBean parentStudy = (StudyBean) studyDAO.findByPK(parentStudyId);
        studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(parentStudy);
    } else {
        parentStudyId = currentStudy.getId();
        studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(currentStudy);
    }
    for (int i = 0; i < studyGroupClasses.size(); i++) {
        StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
        ArrayList groups = studyGroupDAO.findAllByGroupClass(sgc);
        sgc.setStudyGroups(groups);
    }
    return studyGroupClasses;
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 7 with StudyGroupClassDAO

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

the class CreateDatasetServlet method setUpStudyGroups.

/*
     * public void setUpStudyGroups() { StudyDAO studydao = new
     * StudyDAO(sm.getDataSource()); StudyGroupClassDAO sgclassdao = new
     * StudyGroupClassDAO(sm.getDataSource()); StudyBean theStudy =
     * (StudyBean)studydao.findByPK(sm.getUserBean().getActiveStudyId());
     * ArrayList sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
     * //StudyGroupClassBean sgclass = (StudyGroupClassBean)sgclasses.get(0);
     * //get the first one and test its name //logger.info("found study class
     * "+sgclass.getName()); request.setAttribute("sgclasses", sgclasses); }
     */
public ArrayList setUpStudyGroups() {
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
    StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
    ArrayList sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
    // logger.info("found study class "+sgclass.getName());
    return 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 8 with StudyGroupClassDAO

use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO 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 9 with StudyGroupClassDAO

use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO 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 10 with StudyGroupClassDAO

use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO 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)

Aggregations

StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)27 ArrayList (java.util.ArrayList)23 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)21 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)20 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)19 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)17 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)12 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)10 HashMap (java.util.HashMap)8 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)8 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)8 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)7 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)7 StudyGroupBean (org.akaza.openclinica.bean.managestudy.StudyGroupBean)6 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)5 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)5 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)5 Date (java.util.Date)4 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)4 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)4