Search in sources :

Example 36 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class StudyModuleController method reactivateParticipate.

@RequestMapping(value = "/{study}/reactivate", method = RequestMethod.GET)
public String reactivateParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    spv.setStudyId(study.getId());
    spv.setParameter("participantPortal");
    spv.setValue("enabled");
    if (spv.getId() > 0)
        spvdao.update(spv);
    else
        spvdao.create(spv);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    currentStudy.getStudyParameterConfig().setParticipantPortal("enabled");
    return "redirect:/pages/studymodule";
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class SetUpStudyRole method setUp.

public void setUp(HttpSession httpSession, UserAccountBean userAccountBean) {
    StudyUserRoleBean currentRole = new StudyUserRoleBean();
    StudyBean currentStudy = new StudyBean();
    StudyInfoPanel panel = new StudyInfoPanel();
    StudyDAO sdao = new StudyDAO(dataSource);
    if (userAccountBean.getId() > 0 && userAccountBean.getActiveStudyId() > 0) {
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
        currentStudy = (StudyBean) sdao.findByPK(userAccountBean.getActiveStudyId());
        ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
        currentStudy.setStudyParameters(studyParameters);
        StudyConfigService scs = new StudyConfigService(dataSource);
        if (currentStudy.getParentStudyId() <= 0) {
            // top study
            scs.setParametersForStudy(currentStudy);
        } else {
            // YW <<
            currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
            // YW >>
            scs.setParametersForSite(currentStudy);
        }
        // set up the panel here, tbh
        panel.reset();
        /*
            * panel.setData("Study", currentStudy.getName());
            * panel.setData("Summary", currentStudy.getSummary());
            * panel.setData("Start Date",
            * sdf.format(currentStudy.getDatePlannedStart()));
            * panel.setData("End Date",
            * sdf.format(currentStudy.getDatePlannedEnd()));
            * panel.setData("Principal Investigator",
            * currentStudy.getPrincipalInvestigator());
            */
        httpSession.setAttribute(STUDY_INFO_PANEL, panel);
    } else {
        currentStudy = new StudyBean();
    }
    httpSession.setAttribute("study", currentStudy);
    // restored
    if (currentStudy.getParentStudyId() > 0) {
        currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
    }
    if (currentStudy.getParentStudyId() > 0) {
        /*The Role decription will be set depending on whether the user logged in at
       study lever or site level. issue-2422*/
        List roles = Role.toArrayList();
        for (Iterator it = roles.iterator(); it.hasNext(); ) {
            Role role = (Role) it.next();
            switch(role.getId()) {
                case 2:
                    role.setDescription("site_Study_Coordinator");
                    break;
                case 3:
                    role.setDescription("site_Study_Director");
                    break;
                case 4:
                    role.setDescription("site_investigator");
                    break;
                case 5:
                    role.setDescription("site_Data_Entry_Person");
                    break;
                case 6:
                    role.setDescription("site_monitor");
                    break;
                case 7:
                    role.setDescription("site_Data_Entry_Person2");
                    break;
                default:
            }
        }
    } else {
        /*If the current study is a site, we will change the role description. issue-2422*/
        List roles = Role.toArrayList();
        for (Iterator it = roles.iterator(); it.hasNext(); ) {
            Role role = (Role) it.next();
            switch(role.getId()) {
                case 2:
                    role.setDescription("Study_Coordinator");
                    break;
                case 3:
                    role.setDescription("Study_Director");
                    break;
                case 4:
                    role.setDescription("investigator");
                    break;
                case 5:
                    role.setDescription("Data_Entry_Person");
                    break;
                case 6:
                    role.setDescription("monitor");
                    break;
                default:
            }
        }
    }
    if (currentRole.getId() <= 0) {
        // kept as "invalid" -- YW 06-21-2007
        if (userAccountBean.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
            currentRole = userAccountBean.getRoleByStudy(currentStudy.getId());
            if (currentStudy.getParentStudyId() > 0) {
                // Checking if currentStudy has been removed or not will
                // ge good enough -- YW 10-17-2007
                StudyUserRoleBean roleInParent = userAccountBean.getRoleByStudy(currentStudy.getParentStudyId());
                // inherited role from parent study, pick the higher
                // role
                currentRole.setRole(Role.max(currentRole.getRole(), roleInParent.getRole()));
            }
        // logger.info("currentRole:" + currentRole.getRoleName());
        } else {
            currentRole = new StudyUserRoleBean();
        }
        httpSession.setAttribute("userRole", currentRole);
    } else // active study has been removed.
    if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
        currentRole.setRole(Role.INVALID);
        currentRole.setStatus(Status.DELETED);
        httpSession.setAttribute("userRole", currentRole);
    }
}
Also used : Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel)

Example 38 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class ChangeStudyServlet method changeStudy.

private void changeStudy() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt("studyId");
    int prevStudyId = currentStudy.getId();
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean current = (StudyBean) sdao.findByPK(studyId);
    // reset study parameters -jxu 02/09/2007
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList studyParameters = spvdao.findParamConfigByStudy(current);
    current.setStudyParameters(studyParameters);
    int parentStudyId = currentStudy.getParentStudyId() > 0 ? currentStudy.getParentStudyId() : currentStudy.getId();
    StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
    current.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
    String idSetting = current.getStudyParameterConfig().getSubjectIdGeneration();
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        int nextLabel = this.getStudySubjectDAO().findTheGreatestLabel() + 1;
        request.setAttribute("label", new Integer(nextLabel).toString());
    }
    StudyConfigService scs = new StudyConfigService(sm.getDataSource());
    if (current.getParentStudyId() <= 0) {
        // top study
        scs.setParametersForStudy(current);
    } else {
        // YW <<
        if (current.getParentStudyId() > 0) {
            current.setParentStudyName(((StudyBean) sdao.findByPK(current.getParentStudyId())).getName());
        }
        // YW 06-12-2007>>
        scs.setParametersForSite(current);
    }
    if (current.getStatus().equals(Status.DELETED) || current.getStatus().equals(Status.AUTO_DELETED)) {
        session.removeAttribute("studyWithRole");
        addPageMessage(restext.getString("study_choosed_removed_restore_first"));
    } else {
        session.setAttribute("study", current);
        currentStudy = current;
        // change user's active study id
        UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
        ub.setActiveStudyId(current.getId());
        ub.setUpdater(ub);
        ub.setUpdatedDate(new java.util.Date());
        udao.update(ub);
        if (current.getParentStudyId() > 0) {
            /*
                 * The Role decription will be set depending on whether the user
                 * logged in at study lever or site level. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("site_Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("site_Study_Director");
                        break;
                    case 4:
                        role.setDescription("site_investigator");
                        break;
                    case 5:
                        role.setDescription("site_Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("site_monitor");
                        break;
                    case 7:
                        role.setDescription("site_Data_Entry_Person2");
                        break;
                    default:
                }
            }
        } else {
            /*
                 * If the current study is a site, we will change the role
                 * description. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("Study_Director");
                        break;
                    case 4:
                        role.setDescription("investigator");
                        break;
                    case 5:
                        role.setDescription("Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("monitor");
                        break;
                    default:
                }
            }
        }
        currentRole = (StudyUserRoleBean) session.getAttribute("studyWithRole");
        session.setAttribute("userRole", currentRole);
        session.removeAttribute("studyWithRole");
        addPageMessage(restext.getString("current_study_changed_succesfully"));
    }
    ub.incNumVisitsToMainMenu();
    // YW 2-18-2008, if study has been really changed <<
    if (prevStudyId != studyId) {
        session.removeAttribute("eventsForCreateDataset");
        session.setAttribute("tableFacadeRestore", "false");
    }
    request.setAttribute("studyJustChanged", "yes");
    // YW >>
    //Integer assignedDiscrepancies = getDiscrepancyNoteDAO().countAllItemDataByStudyAndUser(currentStudy, ub);
    Integer assignedDiscrepancies = getDiscrepancyNoteDAO().getViewNotesCountWithFilter(" AND dn.assigned_user_id =" + ub.getId() + " AND (dn.resolution_status_id=1 OR dn.resolution_status_id=2 OR dn.resolution_status_id=3)", currentStudy);
    request.setAttribute("assignedDiscrepancies", assignedDiscrepancies == null ? 0 : assignedDiscrepancies);
    if (currentRole.isInvestigator() || currentRole.isResearchAssistant() || currentRole.isResearchAssistant2()) {
        setupListStudySubjectTable();
    }
    if (currentRole.isMonitor()) {
        setupSubjectSDVTable();
    } else if (currentRole.isCoordinator() || currentRole.isDirector()) {
        if (currentStudy.getStatus().isPending()) {
            response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
            return;
        }
        setupStudySiteStatisticsTable();
        setupSubjectEventStatusStatisticsTable();
        setupStudySubjectStatusStatisticsTable();
        if (currentStudy.getParentStudyId() == 0) {
            setupStudyStatisticsTable();
        }
    }
    forwardPage(Page.MENU);
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Validator(org.akaza.openclinica.control.form.Validator)

Example 39 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class RemoveEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String idString = request.getParameter("id");
    int defId = Integer.valueOf(idString.trim()).intValue();
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
    //        checkRoleByUserAndStudy(ub.getName(), sed.getStudyId(), 0);
    if (currentStudy.getId() != sed.getStudyId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    // find all CRFs
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
        edc.setVersions(versions);
        CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
        edc.setCrfName(crf.getName());
        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
        edc.setDefaultVersionName(defaultVersion.getName());
        CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
        String crfPath = sed.getOid() + "." + cBean.getOid();
        edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
    }
    // finds all events
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
    String action = request.getParameter("action");
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_SED_to_remove"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            if (!sed.getStatus().equals(Status.AVAILABLE)) {
                addPageMessage(respage.getString("this_SED_is_not_available_for_this_study") + respage.getString("please_contact_sysadmin_for_more_information"));
                forwardPage(Page.LIST_DEFINITION_SERVLET);
                return;
            }
            StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
            String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
            if (participateFormStatus.equals("enabled"))
                baseUrl();
            request.setAttribute("participateFormStatus", participateFormStatus);
            request.setAttribute("definitionToRemove", sed);
            request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
            request.setAttribute("events", events);
            forwardPage(Page.REMOVE_DEFINITION);
        } else {
            logger.info("submit to remove the definition");
            // remove definition
            sed.setStatus(Status.DELETED);
            sed.setUpdater(ub);
            sed.setUpdatedDate(new Date());
            sdao.update(sed);
            // remove all crfs
            for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
                if (!edc.getStatus().equals(Status.DELETED)) {
                    edc.setStatus(Status.AUTO_DELETED);
                    edc.setUpdater(ub);
                    edc.setUpdatedDate(new Date());
                    edao.update(edc);
                }
            }
            // remove all events
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            for (int j = 0; j < events.size(); j++) {
                StudyEventBean event = (StudyEventBean) events.get(j);
                if (!event.getStatus().equals(Status.DELETED)) {
                    event.setStatus(Status.AUTO_DELETED);
                    event.setUpdater(ub);
                    event.setUpdatedDate(new Date());
                    sedao.update(event);
                    ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
                    // remove all the item data
                    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                    for (int k = 0; k < eventCRFs.size(); k++) {
                        EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
                        if (!eventCRF.getStatus().equals(Status.DELETED)) {
                            eventCRF.setStatus(Status.AUTO_DELETED);
                            eventCRF.setUpdater(ub);
                            eventCRF.setUpdatedDate(new Date());
                            ecdao.update(eventCRF);
                            ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
                            for (int a = 0; a < itemDatas.size(); a++) {
                                ItemDataBean item = (ItemDataBean) itemDatas.get(a);
                                if (!item.getStatus().equals(Status.DELETED)) {
                                    item.setStatus(Status.AUTO_DELETED);
                                    item.setUpdater(ub);
                                    item.setUpdatedDate(new Date());
                                    iddao.update(item);
                                }
                            }
                        }
                    }
                }
            }
            String emailBody = respage.getString("the_SED") + sed.getName() + " " + respage.getString("has_been_removed_from_the_study") + currentStudy.getName() + ".";
            addPageMessage(emailBody);
            //                sendEmail(emailBody);
            forwardPage(Page.LIST_DEFINITION_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) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 40 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class RestoreEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String idString = request.getParameter("id");
    int defId = Integer.valueOf(idString.trim()).intValue();
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
    // find all CRFs
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
        edc.setVersions(versions);
        CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
        edc.setCrfName(crf.getName());
        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
        edc.setDefaultVersionName(defaultVersion.getName());
        CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
        String crfPath = sed.getOid() + "." + cBean.getOid();
        edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
    }
    // finds all events
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
    String action = request.getParameter("action");
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_SED_to_restore"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            if (!sed.getStatus().equals(Status.DELETED)) {
                addPageMessage(respage.getString("this_SED_cannot_be_restored") + " " + respage.getString("please_contact_sysadmin_for_more_information"));
                forwardPage(Page.LIST_DEFINITION_SERVLET);
                return;
            }
            String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
            request.setAttribute("participateFormStatus", participateFormStatus);
            if (participateFormStatus.equals("enabled"))
                baseUrl();
            request.setAttribute("definitionToRestore", sed);
            request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
            request.setAttribute("events", events);
            forwardPage(Page.RESTORE_DEFINITION);
        } else {
            logger.info("submit to restore the definition");
            // restore definition
            sed.setStatus(Status.AVAILABLE);
            sed.setUpdater(ub);
            sed.setUpdatedDate(new Date());
            sdao.update(sed);
            // restore all crfs
            for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
                if (edc.getStatus().equals(Status.AUTO_DELETED)) {
                    edc.setStatus(Status.AVAILABLE);
                    edc.setUpdater(ub);
                    edc.setUpdatedDate(new Date());
                    edao.update(edc);
                }
            }
            // restore all events
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            for (int j = 0; j < events.size(); j++) {
                StudyEventBean event = (StudyEventBean) events.get(j);
                if (event.getStatus().equals(Status.AUTO_DELETED)) {
                    event.setStatus(Status.AVAILABLE);
                    event.setUpdater(ub);
                    event.setUpdatedDate(new Date());
                    sedao.update(event);
                    ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
                    // remove all the item data
                    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                    for (int k = 0; k < eventCRFs.size(); k++) {
                        EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
                        if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
                            eventCRF.setStatus(Status.AVAILABLE);
                            eventCRF.setUpdater(ub);
                            eventCRF.setUpdatedDate(new Date());
                            ecdao.update(eventCRF);
                            ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
                            for (int a = 0; a < itemDatas.size(); a++) {
                                ItemDataBean item = (ItemDataBean) itemDatas.get(a);
                                if (item.getStatus().equals(Status.AUTO_DELETED)) {
                                    item.setStatus(Status.AVAILABLE);
                                    item.setUpdater(ub);
                                    item.setUpdatedDate(new Date());
                                    iddao.update(item);
                                }
                            }
                        }
                    }
                }
            }
            String emailBody = respage.getString("the_SED") + " " + sed.getName() + "(" + respage.getString("and_all_associated_event_data_restored_to_study") + currentStudy.getName() + ".";
            addPageMessage(emailBody);
            //                sendEmail(emailBody);
            forwardPage(Page.LIST_DEFINITION_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) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Aggregations

StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)54 ArrayList (java.util.ArrayList)37 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)36 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)29 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)27 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)22 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)21 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)16 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)15 Date (java.util.Date)13 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)10 FormLayoutDAO (org.akaza.openclinica.dao.submit.FormLayoutDAO)10 HashMap (java.util.HashMap)9 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)9 ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)9 Iterator (java.util.Iterator)8 FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)8 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)8 StudyConfigService (org.akaza.openclinica.dao.service.StudyConfigService)7