Search in sources :

Example 1 with StudyGroupClassBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.

the class ExtractBean method getMetadata.

/**
     * Implements the Column algorithm in "Dataset Export Algorithms" Must be
     * called after DatasetDAO.getDatasetData();
     */
public void getMetadata() {
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
    CRFDAO cdao = new CRFDAO(ds);
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    ItemDAO idao = new ItemDAO(ds);
    ItemFormMetadataDAO ifmDAO = new ItemFormMetadataDAO(this.ds);
    StudyGroupDAO studygroupDAO = new StudyGroupDAO(ds);
    StudyGroupClassDAO studygroupclassDAO = new StudyGroupClassDAO(ds);
    // SubjectGroupMapDAO subjectGroupMapDAO = new SubjectGroupMapDAO(ds);
    studyGroupClasses = new ArrayList();
    studyGroupMap = new HashMap();
    studyGroupMaps = new HashMap<Integer, ArrayList>();
    sedCrfColumns = new HashMap();
    displayed = new HashMap();
    sedCrfItemFormMetadataBeans = new HashMap();
    studyEvents = seddao.findAllByStudy(study);
    ArrayList finalStudyEvents = new ArrayList();
    if (dataset.isShowSubjectGroupInformation()) {
        // logger.info("found study id for maps: "+study.getId());
        studyGroupMaps = studygroupDAO.findSubjectGroupMaps(study.getId());
        // below is for a given subject; we need a data structure for
        // all subjects
        // studyGroupMap = studygroupDAO.findByStudySubject(currentSubject);
        // problem: can't use currentSubject here, since it's not 'set up'
        // properly
        // how to get the current subject?
        logger.info("found subject group ids: " + dataset.getSubjectGroupIds().toString());
        // studyGroupClasses = dataset.getSubjectGroupIds();
        for (int h = 0; h < dataset.getSubjectGroupIds().size(); h++) {
            Integer groupId = (Integer) dataset.getSubjectGroupIds().get(h);
            StudyGroupClassBean sgclass = (StudyGroupClassBean) studygroupclassDAO.findByPK(groupId.intValue());
            // logger.info();
            // hmm how to link groups to subjects though? only through
            // subject group map
            logger.info("found a studygroupclass bean: " + sgclass.getName());
            studyGroupClasses.add(sgclass);
        }
    }
    for (int i = 0; i < studyEvents.size(); i++) {
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) studyEvents.get(i);
        if (!selectedSED(sed)) {
            continue;
        }
        ArrayList CRFs = (ArrayList) cdao.findAllActiveByDefinition(sed);
        ArrayList CRFsDisplayedInThisSED = new ArrayList();
        for (int j = 0; j < CRFs.size(); j++) {
            CRFBean cb = (CRFBean) CRFs.get(j);
            if (!selectedSEDCRF(sed, cb)) {
                continue;
            } else {
                CRFsDisplayedInThisSED.add(cb);
                ArrayList CRFVersions = cvdao.findAllByCRFId(cb.getId());
                for (int k = 0; k < CRFVersions.size(); k++) {
                    CRFVersionBean cvb = (CRFVersionBean) CRFVersions.get(k);
                    ArrayList Items = idao.findAllItemsByVersionId(cvb.getId());
                    // sort by ordinal/name
                    Collections.sort(Items);
                    for (int l = 0; l < Items.size(); l++) {
                        ItemBean ib = (ItemBean) Items.get(l);
                        if (selected(ib) && !getDisplayed(sed, cb, ib)) {
                            // logger.info("found at
                            // itemformmetadatadao: "+ib.getId()+",
                            // "+cvb.getId());
                            ItemFormMetadataBean ifmb = ifmDAO.findByItemIdAndCRFVersionId(ib.getId(), cvb.getId());
                            addColumn(sed, cb, ib);
                            addItemFormMetadataBeans(sed, cb, ifmb);
                            markDisplayed(sed, cb, ib);
                        }
                    }
                }
            }
        // else
        }
        // for
        sed.setCrfs(CRFsDisplayedInThisSED);
        // make the setCrfs call "stick"
        finalStudyEvents.add(sed);
    }
    this.studyEvents = finalStudyEvents;
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 2 with StudyGroupClassBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.

the class RestoreSubjectGroupClassServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    FormProcessor fp = new FormProcessor(request);
    int classId = fp.getInt("id");
    if (classId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_group_class_to_restore"));
        forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
    } else {
        StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
        StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
        SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
        if (action.equalsIgnoreCase("confirm")) {
            StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
            if (sgcb.getStatus().equals(Status.AVAILABLE)) {
                addPageMessage(respage.getString("this_subject_group_class_is_available_cannot_restore"));
                forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
                return;
            }
            ArrayList groups = sgdao.findAllByGroupClass(sgcb);
            for (int i = 0; i < groups.size(); i++) {
                StudyGroupBean sg = (StudyGroupBean) groups.get(i);
                ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
                sg.setSubjectMaps(subjectMaps);
            }
            session.setAttribute("group", sgcb);
            session.setAttribute("studyGroups", groups);
            forwardPage(Page.RESTORE_SUBJECT_GROUP_CLASS);
        } else if (action.equalsIgnoreCase("submit")) {
            StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
            group.setStatus(Status.AVAILABLE);
            group.setUpdater(ub);
            sgcdao.update(group);
            ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassId(group.getId());
            for (int i = 0; i < subjectMaps.size(); i++) {
                SubjectGroupMapBean sgmb = (SubjectGroupMapBean) subjectMaps.get(i);
                if (sgmb.getStatus().equals(Status.AUTO_DELETED)) {
                    sgmb.setStatus(Status.AVAILABLE);
                    sgmb.setUpdater(ub);
                    sgmdao.update(sgmb);
                }
            }
            addPageMessage(respage.getString("this_subject_group_class_was_restored_succesfully"));
            forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
        } else {
            addPageMessage(respage.getString("no_action_specified"));
            forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
        }
    }
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) ArrayList(java.util.ArrayList) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 3 with StudyGroupClassBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.

the class UpdateSubjectGroupClassServlet method confirmGroup.

/**
     * Validates the first section of study and save it into study bean
     *
     * @param request
     * @param response
     * @throws Exception
     */
private void confirmGroup() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    v.addValidation("name", Validator.NO_BLANKS);
    // v.addValidation("groupClassTypeId", Validator.IS_AN_INTEGER);
    v.addValidation("subjectAssignment", Validator.NO_BLANKS);
    v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
    v.addValidation("subjectAssignment", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
    ArrayList studyGroups = new ArrayList();
    for (int i = 0; i < 10; i++) {
        String name = fp.getString("studyGroup" + i);
        int studyGroupId = fp.getInt("studyGroupId" + i);
        String description = fp.getString("studyGroupDescription" + i);
        if (!StringUtil.isBlank(name)) {
            StudyGroupBean g = new StudyGroupBean();
            g.setName(name);
            g.setDescription(description);
            g.setId(studyGroupId);
            studyGroups.add(g);
            if (name.length() > 255) {
                request.setAttribute("studyGroupError", resexception.getString("group_name_cannot_be_more_255"));
                break;
            }
            if (description.length() > 1000) {
                request.setAttribute("studyGroupError", resexception.getString("group_description_cannot_be_more_100"));
                break;
            }
        }
    }
    errors = v.validate();
    if (fp.getInt("groupClassTypeId") == 0) {
        Validator.addError(errors, "groupClassTypeId", "Group Class Type is required.");
    }
    StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
    group.setName(fp.getString("name"));
    group.setGroupClassTypeId(fp.getInt("groupClassTypeId"));
    group.setSubjectAssignment(fp.getString("subjectAssignment"));
    session.setAttribute("group", group);
    session.setAttribute("studyGroups", studyGroups);
    if (errors.isEmpty()) {
        logger.info("no errors in the first section");
        group.setGroupClassTypeName(GroupClassType.get(group.getGroupClassTypeId()).getName());
        forwardPage(Page.UPDATE_SUBJECT_GROUP_CLASS_CONFIRM);
    } else {
        logger.info("has validation errors in the first section");
        request.setAttribute("formMessages", errors);
        request.setAttribute("groupTypes", GroupClassType.toArrayList());
        forwardPage(Page.UPDATE_SUBJECT_GROUP_CLASS);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) Validator(org.akaza.openclinica.control.form.Validator) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 4 with StudyGroupClassBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.

the class StudyGroupClassDAO method update.

/**
     * Updates a StudyGroupClass
     */
public EntityBean update(EntityBean eb) {
    StudyGroupClassBean sb = (StudyGroupClassBean) eb;
    HashMap variables = new HashMap();
    // UPDATE study_group_class SET NAME=?,STUDY_ID=?,
    // GROUP_class_TYPE_ID=?,
    // STATUS_ID=?, DATE_UPDATED=?,UPDATE_ID=?,
    // subject_assignment=? WHERE STUDY_GROUP_class_ID=?
    variables.put(new Integer(1), sb.getName());
    variables.put(new Integer(2), new Integer(sb.getStudyId()));
    variables.put(new Integer(3), new Integer(sb.getGroupClassTypeId()));
    variables.put(new Integer(4), new Integer(sb.getStatus().getId()));
    variables.put(new Integer(5), new java.util.Date());
    variables.put(new Integer(6), new Integer(sb.getUpdater().getId()));
    variables.put(new Integer(7), sb.getSubjectAssignment());
    variables.put(new Integer(8), new Integer(sb.getId()));
    String sql = digester.getQuery("update");
    this.execute(sql, variables);
    return sb;
}
Also used : HashMap(java.util.HashMap) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)

Example 5 with StudyGroupClassBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.

the class StudyGroupClassDAO method findByStudyId.

public EntityBean findByStudyId(int studyId) {
    StudyGroupClassBean eb = new StudyGroupClassBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(studyId));
    String sql = digester.getQuery("findByStudyId");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (StudyGroupClassBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)44 ArrayList (java.util.ArrayList)35 StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)21 HashMap (java.util.HashMap)17 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)16 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyGroupBean (org.akaza.openclinica.bean.managestudy.StudyGroupBean)10 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)9 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)9 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)9 Iterator (java.util.Iterator)8 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)7 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)6 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)6 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)6 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)5 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)5