Search in sources :

Example 76 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class PrintAllEventCRFServlet method processRequest.

@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormProcessor fp = new FormProcessor(request);
    SessionManager sm = (SessionManager) request.getSession().getAttribute("sm");
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
    ArrayList<SectionBean> allSectionBeans;
    // The PrintDataEntry servlet handles this parameter
    boolean isSubmitted = false;
    StudyEventDefinitionDAO sedao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    seds = sedao.findAllByStudy(currentStudy);
    //        ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByStudy(site);
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> edcs = new ArrayList();
    for (StudyEventDefinitionBean sed : seds) {
        int defId = sed.getId();
        edcs.addAll(edcdao.findAllByDefinition(currentStudy, defId));
    }
    Map eventDefinitionDefaultVersions = new LinkedHashMap();
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edc = edcs.get(i);
        ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
        edc.setVersions(versions);
        CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
        // edc.setCrfLabel(crf.getLabel());
        edc.setCrfName(crf.getName());
        // to show/hide edit action on jsp page
        if (crf.getStatus().equals(Status.AVAILABLE)) {
            edc.setOwner(crf.getOwner());
        }
        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
        StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) sedao.findByPK(edc.getStudyEventDefinitionId());
        edc.setDefaultVersionName(defaultVersion.getName());
        if (defaultVersion.getStatus().isAvailable()) {
            List list = (ArrayList) eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
            if (list == null)
                list = new ArrayList();
            list.add(defaultVersion);
            eventDefinitionDefaultVersions.put(studyEventDefinitionBean, list);
        }
    }
    // Whether IE6 or IE7 is involved
    String isIE = fp.getString("ie");
    if ("y".equalsIgnoreCase(isIE)) {
        request.setAttribute("isInternetExplorer", "true");
    }
    SectionDAO sdao = new SectionDAO(sm.getDataSource());
    CRFVersionDAO crfVersionDAO = new CRFVersionDAO(sm.getDataSource());
    CRFDAO crfDao = new CRFDAO(sm.getDataSource());
    Map sedCrfBeans = null;
    for (Iterator it = eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
        if (sedCrfBeans == null)
            sedCrfBeans = new LinkedHashMap();
        StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) it.next();
        List crfVersions = (ArrayList) eventDefinitionDefaultVersions.get(sedBean);
        for (Iterator crfIt = crfVersions.iterator(); crfIt.hasNext(); ) {
            CRFVersionBean crfVersionBean = (CRFVersionBean) crfIt.next();
            allSectionBeans = new ArrayList<SectionBean>();
            ArrayList sectionBeans = new ArrayList();
            ItemGroupDAO itemGroupDao = new ItemGroupDAO(sm.getDataSource());
            // Find truely grouped tables, not groups with a name of 'Ungrouped'
            List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
            CRFBean crfBean = crfDao.findByVersionId(crfVersionBean.getId());
            if (itemGroupBeans.size() > 0) {
                // get a DisplaySectionBean for each section of the CRF, sort
                // them, then
                // dispatch the request to a print JSP. The constructor for this
                // handler takes
                // a boolean value depending on whether data is involved or not
                // ('false' in terms of this
                // servlet; see PrintDataEntryServlet).
                DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
                handler.setCrfVersionId(crfVersionBean.getId());
                //handler.setEventCRFId(eventCRFId);
                List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
                request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
                // Make available the CRF names and versions for
                // the web page's header
                CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
                request.setAttribute("crfVersionBean", crfverBean);
                request.setAttribute("crfBean", crfBean);
                // Set an attribute signaling that data is not involved
                request.setAttribute("dataInvolved", "false");
                PrintCRFBean printCrfBean = new PrintCRFBean();
                printCrfBean.setDisplaySectionBeans(displaySectionBeans);
                printCrfBean.setCrfVersionBean(crfVersionBean);
                printCrfBean.setCrfBean(crfBean);
                printCrfBean.setEventCrfBean(ecb);
                printCrfBean.setGrouped(true);
                List list = (ArrayList) sedCrfBeans.get(sedBean);
                if (list == null)
                    list = new ArrayList();
                list.add(printCrfBean);
                sedCrfBeans.put(sedBean, list);
                continue;
            }
            ecb = new EventCRFBean();
            ecb.setCRFVersionId(crfVersionBean.getId());
            CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
            ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
            for (int i = 0; i < sects.size(); i++) {
                sb = (SectionBean) sects.get(i);
                //                    super.sb = sb;
                int sectId = sb.getId();
                if (sectId > 0) {
                    allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
                }
            }
            request.setAttribute(INPUT_EVENT_CRF, ecb);
            request.setAttribute(SECTION_BEAN, sb);
            request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
            sectionBeans = super.getAllDisplayBeans(request);
            DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
            PrintCRFBean printCrfBean = new PrintCRFBean();
            printCrfBean.setAllSections(sectionBeans);
            printCrfBean.setDisplaySectionBean(dsb);
            printCrfBean.setEventCrfBean(ecb);
            printCrfBean.setCrfVersionBean(crfVersionBean);
            printCrfBean.setCrfBean(crfBean);
            printCrfBean.setGrouped(false);
            List list = (ArrayList) sedCrfBeans.get(sedBean);
            if (list == null)
                list = new ArrayList();
            list.add(printCrfBean);
            sedCrfBeans.put(sedBean, list);
        }
    }
    request.setAttribute("sedCrfBeans", sedCrfBeans);
    request.setAttribute("studyName", currentStudy.getName());
    forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT, request, response);
}
Also used : ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) PrintCRFBean(org.akaza.openclinica.bean.managestudy.PrintCRFBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) LinkedHashMap(java.util.LinkedHashMap) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) DisplaySectionBeanHandler(org.akaza.openclinica.view.display.DisplaySectionBeanHandler) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) SessionManager(org.akaza.openclinica.core.SessionManager) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) PrintCRFBean(org.akaza.openclinica.bean.managestudy.PrintCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 77 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class RemoveEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // eventCRFId
    int eventCRFId = fp.getInt("id");
    // studySubjectId
    int studySubId = fp.getInt("studySubId");
    checkStudyLocked("ViewStudySubject?id" + studySubId, respage.getString("current_study_locked"));
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_remove"));
        request.setAttribute("id", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    } else {
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        // construct info needed on view event crf page
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
        int crfVersionId = eventCRF.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        eventCRF.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        eventCRF.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = eventCRF.getStudyEventId();
        StudyEventBean event = (StudyEventBean) sedao.findByPK(studyEventId);
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(studyEventDefinitionId);
        event.setStudyEventDefinition(sed);
        request.setAttribute("event", event);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        StudyBean study = (StudyBean) sdao.findByPK(studySub.getStudyId());
        EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
        DisplayEventCRFBean dec = new DisplayEventCRFBean();
        dec.setEventCRF(eventCRF);
        dec.setFlags(eventCRF, ub, currentRole, edc.isDoubleEntry());
        // find all item data
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ArrayList itemData = iddao.findAllByEventCRFId(eventCRF.getId());
        request.setAttribute("items", itemData);
        String action = request.getParameter("action");
        if ("confirm".equalsIgnoreCase(action)) {
            if (eventCRF.getStatus().equals(Status.DELETED) || eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
                addPageMessage(respage.getString("this_event_CRF_is_removed_for_this_study") + " " + respage.getString("please_contact_sysadmin_for_more_information"));
                request.setAttribute("id", new Integer(studySubId).toString());
                forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
                return;
            }
            request.setAttribute("displayEventCRF", dec);
            forwardPage(Page.REMOVE_EVENT_CRF);
        } else {
            logger.info("submit to remove the event CRF from study");
            eventCRF.setStatus(Status.DELETED);
            eventCRF.setUpdater(ub);
            eventCRF.setUpdatedDate(new Date());
            ecdao.update(eventCRF);
            // remove all the item data
            for (int a = 0; a < itemData.size(); a++) {
                ItemDataBean item = (ItemDataBean) itemData.get(a);
                if (!item.getStatus().equals(Status.DELETED)) {
                    item.setStatus(Status.AUTO_DELETED);
                    item.setUpdater(ub);
                    item.setUpdatedDate(new Date());
                    iddao.update(item);
                    DiscrepancyNoteDAO dnDao = new DiscrepancyNoteDAO(sm.getDataSource());
                    List dnNotesOfRemovedItem = dnDao.findExistingNotesForItemData(item.getId());
                    if (!dnNotesOfRemovedItem.isEmpty()) {
                        DiscrepancyNoteBean itemParentNote = null;
                        for (Object obj : dnNotesOfRemovedItem) {
                            if (((DiscrepancyNoteBean) obj).getParentDnId() == 0) {
                                itemParentNote = (DiscrepancyNoteBean) obj;
                            }
                        }
                        DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
                        if (itemParentNote != null) {
                            dnb.setParentDnId(itemParentNote.getId());
                            dnb.setDiscrepancyNoteTypeId(itemParentNote.getDiscrepancyNoteTypeId());
                        }
                        dnb.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
                        dnb.setStudyId(currentStudy.getId());
                        dnb.setAssignedUserId(ub.getId());
                        dnb.setOwner(ub);
                        dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
                        dnb.setEntityId(item.getId());
                        dnb.setColumn("value");
                        dnb.setCreatedDate(new Date());
                        dnb.setDescription("The item has been removed, this Discrepancy Note has been Closed.");
                        dnDao.create(dnb);
                        dnDao.createMapping(dnb);
                        itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
                        dnDao.update(itemParentNote);
                    }
                }
            }
            String emailBody = respage.getString("the_event_CRF") + " " + cb.getName() + " " + respage.getString("has_been_removed_from_the_event") + event.getStudyEventDefinition().getName() + ". " + respage.getString("has_been_removed_from_the_event_cont");
            addPageMessage(emailBody);
            sendEmail(emailBody);
            request.setAttribute("id", new Integer(studySubId).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) List(java.util.List) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Example 78 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ListSubjectGroupClassServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    // YW <<
    StudyDAO stdao = new StudyDAO(sm.getDataSource());
    int parentStudyId = currentStudy.getParentStudyId();
    ArrayList groups = new ArrayList();
    if (parentStudyId > 0) {
        StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId);
        groups = sgcdao.findAllByStudy(parentStudy);
    } else {
        groups = sgcdao.findAllByStudy(currentStudy);
    }
    // YW >>
    String isReadOnly = request.getParameter("read");
    StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
    for (int i = 0; i < groups.size(); i++) {
        StudyGroupClassBean group = (StudyGroupClassBean) groups.get(i);
        ArrayList studyGroups = sgdao.findAllByGroupClass(group);
        group.setStudyGroups(studyGroups);
    }
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList allGroupRows = StudyGroupClassRow.generateRowsFromBeans(groups);
    boolean isParentStudy = currentStudy.getParentStudyId() > 0 ? false : true;
    request.setAttribute("isParentStudy", isParentStudy);
    String[] columns = { resword.getString("subject_group_class"), resword.getString("type"), resword.getString("subject_assignment"), resword.getString("study_name"), resword.getString("subject_groups"), resword.getString("status"), resword.getString("actions") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(4);
    table.hideColumnLink(6);
    table.setQuery("ListSubjectGroupClass", new HashMap());
    // if (isParentStudy && (!currentStudy.getStatus().isLocked())) {
    // table.addLink(resword.getString("create_a_subject_group_class"),
    // "CreateSubjectGroupClass");
    // }
    table.setRows(allGroupRows);
    table.computeDisplay();
    request.setAttribute("table", table);
    if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
        request.setAttribute("readOnly", true);
    }
    forwardPage(Page.SUBJECT_GROUP_CLASS_LIST);
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 79 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class LockCRFVersionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int crfVersionId = fp.getInt("id", true);
    String action = fp.getString("action");
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    if (crfVersionId == 0) {
        addPageMessage(respage.getString("choose_valid_crf_version"));
        forwardPage(Page.CRF_LIST_SERVLET);
        return;
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(crfVersionId);
    //System.out.println("crf version found:" + version.getName());
    CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId());
    if (!ub.isSysAdmin() && (version.getOwnerId() != ub.getId())) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList eventCRFs = ecdao.findAllStudySubjectByCRFVersion(crfVersionId);
    if (StringUtil.isBlank(action)) {
        request.setAttribute("crfVersionToLock", version);
        request.setAttribute("crf", crf);
        request.setAttribute("eventSubjectsUsingVersion", eventCRFs);
        forwardPage(Page.CONFIRM_LOCKING_CRF_VERSION);
    } else if ("confirm".equalsIgnoreCase(action)) {
        version.setStatus(Status.LOCKED);
        version.setUpdater(ub);
        cvdao.update(version);
        ArrayList versionList = (ArrayList) cvdao.findAllByCRF(version.getCrfId());
        if (versionList.size() > 0) {
            EventDefinitionCRFDAO edCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
            ArrayList edcList = (ArrayList) edCRFDao.findAllByCRF(version.getCrfId());
            for (int i = 0; i < edcList.size(); i++) {
                EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcList.get(i);
                // @pgawade 18-May-2011 #5414 - Changes for setting the correct
                // default crf version Id to event
                // when existing default version is locked
                // RemoveCRFVersionServlet.updateEventDef(edcBean, edCRFDao,
                // versionList);
                RemoveCRFVersionServlet.updateEventDef(edcBean, edCRFDao, versionList, crfVersionId);
            }
        }
        addPageMessage(respage.getString("crf_version_archived_successfully"));
        forwardPage(Page.CRF_LIST_SERVLET);
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 80 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class RestoreStudyUserRoleServlet method processRequest.

@Override
public void processRequest() throws Exception {
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    String name = request.getParameter("name");
    String studyIdString = request.getParameter("studyId");
    if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
        addPageMessage(respage.getString("please_choose_a_user_to_restore_his_role"));
        forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
    } else {
        String action = request.getParameter("action");
        UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
        if ("confirm".equalsIgnoreCase(action)) {
            int studyId = Integer.valueOf(studyIdString.trim()).intValue();
            request.setAttribute("user", user);
            StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
            request.setAttribute("uRole", uRole);
            StudyDAO sdao = new StudyDAO(sm.getDataSource());
            StudyBean study = (StudyBean) sdao.findByPK(studyId);
            request.setAttribute("uStudy", study);
            forwardPage(Page.RESTORE_USER_ROLE_IN_STUDY);
        } else {
            // restore role
            FormProcessor fp = new FormProcessor(request);
            String userName = fp.getString("name");
            int studyId = fp.getInt("studyId");
            int roleId = fp.getInt("roleId");
            StudyUserRoleBean sur = new StudyUserRoleBean();
            sur.setName(userName);
            sur.setRole(Role.get(roleId));
            sur.setStudyId(studyId);
            sur.setStatus(Status.AVAILABLE);
            sur.setUpdater(ub);
            sur.setUpdatedDate(new Date());
            udao.updateStudyUserRole(sur, userName);
            addPageMessage(sendEmail(user, sur));
            forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Aggregations

FormProcessor (org.akaza.openclinica.control.form.FormProcessor)224 ArrayList (java.util.ArrayList)139 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)92 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)73 HashMap (java.util.HashMap)69 Date (java.util.Date)49 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)46 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 Validator (org.akaza.openclinica.control.form.Validator)44 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)44 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)42 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)41 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)41 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)40 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)36 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)36 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)35 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35