Search in sources :

Example 26 with StudyGroupBean

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

the class RemoveSubjectGroupClassServlet 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_remove"));
        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.DELETED)) {
                addPageMessage(respage.getString("this_subject_group_class_has_been_deleted_already"));
                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.REMOVE_SUBJECT_GROUP_CLASS);
        } else if (action.equalsIgnoreCase("submit")) {
            StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
            group.setStatus(Status.DELETED);
            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.DELETED)) {
                    sgmb.setStatus(Status.AUTO_DELETED);
                    sgmb.setUpdater(ub);
                    sgmdao.update(sgmb);
                }
            }
            addPageMessage(respage.getString("this_subject_group_class_was_removed_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)

Aggregations

StudyGroupBean (org.akaza.openclinica.bean.managestudy.StudyGroupBean)26 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)12 Iterator (java.util.Iterator)10 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)10 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)9 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)6 StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)6 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)5 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)5 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)5 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)4 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)4 Date (java.util.Date)3 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)3 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)3 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)2 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)2 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)2