Search in sources :

Example 41 with StudyDAO

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

the class SecureController method process.

private void process(HttpServletRequest request, HttpServletResponse response) throws OpenClinicaException, UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    session = request.getSession();
    // BWP >> 1/8/2008
    try {
        // YW 10-03-2007 <<
        session.setMaxInactiveInterval(Integer.parseInt(SQLInitServlet.getField("max_inactive_interval")));
    // YW >>
    } catch (NumberFormatException nfe) {
        // BWP>>3600 is the datainfo.properties maxInactiveInterval on
        // 1/8/2008
        session.setMaxInactiveInterval(3600);
    }
    // If the session already has a value with key SUPPORT_URL don't reset
    if (session.getAttribute(SUPPORT_URL) == null) {
        session.setAttribute(SUPPORT_URL, SQLInitServlet.getSupportURL());
    }
    ub = (UserAccountBean) session.getAttribute(USER_BEAN_NAME);
    currentStudy = (StudyBean) session.getAttribute("study");
    currentRole = (StudyUserRoleBean) session.getAttribute("userRole");
    // Set current language preferences
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    resadmin = ResourceBundleProvider.getAdminBundle(locale);
    resaudit = ResourceBundleProvider.getAuditEventsBundle(locale);
    resexception = ResourceBundleProvider.getExceptionsBundle(locale);
    resformat = ResourceBundleProvider.getFormatBundle(locale);
    restext = ResourceBundleProvider.getTextsBundle(locale);
    resterm = ResourceBundleProvider.getTermsBundle(locale);
    resword = ResourceBundleProvider.getWordsBundle(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle(locale);
    resworkflow = ResourceBundleProvider.getWorkflowBundle(locale);
    local_df = I18nFormatUtil.getDateFormat(locale);
    try {
        String userName = request.getRemoteUser();
        // BWP 1/8/08<< the sm variable may already be set with a mock
        // object,
        // from the perspective of
        // JUnit servlets tests
        /*
             * if(sm==null && (!StringUtil.isBlank(userName))) {//check if user logged in, then create a new sessionmanger to
             * get ub //create a new sm in order to get a new ub object sm = new SessionManager(ub, userName); }
             */
        // BWP 01/08 >>
        // sm = new SessionManager(ub, userName);
        sm = new SessionManager(ub, userName, SpringServletAccess.getApplicationContext(context));
        ub = sm.getUserBean();
        session.setAttribute("userBean", ub);
        StudyDAO sdao = new StudyDAO(sm.getDataSource());
        if (currentStudy == null || currentStudy.getId() <= 0) {
            if (ub.getId() > 0 && ub.getActiveStudyId() > 0) {
                StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
                currentStudy = (StudyBean) sdao.findByPK(ub.getActiveStudyId());
                ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
                currentStudy.setStudyParameters(studyParameters);
                StudyConfigService scs = new StudyConfigService(sm.getDataSource());
                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());
                     */
                session.setAttribute(STUDY_INFO_PANEL, panel);
            } else {
                currentStudy = new StudyBean();
            }
            session.setAttribute("study", currentStudy);
        } else if (currentStudy.getId() > 0) {
            // restored
            if (currentStudy.getParentStudyId() > 0) {
                currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
            }
        // YW >>
        }
        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 == null || currentRole.getId() <= 0) {
            // kept as "invalid" -- YW 06-21-2007
            if (ub.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
                currentRole = ub.getRoleByStudy(currentStudy.getId());
            // logger.info("currentRole:" + currentRole.getRoleName());
            } else {
                currentRole = new StudyUserRoleBean();
            }
            session.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);
            session.setAttribute("userRole", currentRole);
        }
        // YW 06-19-2007 >>
        request.setAttribute("isAdminServlet", getAdminServlet());
        this.request = request;
        this.response = response;
        // logger.info(rq_names);
        if (!request.getRequestURI().endsWith("ResetPassword")) {
            passwdTimeOut();
        }
        mayProceed();
        pingJobServer(request);
        processRequest();
    } catch (InconsistentStateException ise) {
        ise.printStackTrace();
        logger.warn("InconsistentStateException: org.akaza.openclinica.control.SecureController: " + ise.getMessage());
        addPageMessage(ise.getOpenClinicaMessage());
        forwardPage(ise.getGoTo());
    } catch (InsufficientPermissionException ipe) {
        ipe.printStackTrace();
        logger.warn("InsufficientPermissionException: org.akaza.openclinica.control.SecureController: " + ipe.getMessage());
        // addPageMessage(ipe.getOpenClinicaMessage());
        forwardPage(ipe.getGoTo());
    } catch (OutOfMemoryError ome) {
        ome.printStackTrace();
        long heapSize = Runtime.getRuntime().totalMemory();
        session.setAttribute("ome", "yes");
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(SecureController.getStackTrace(e));
        forwardPage(Page.ERROR);
    }
}
Also used : Locale(java.util.Locale) SessionManager(org.akaza.openclinica.core.SessionManager) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) ArrayList(java.util.ArrayList) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) InconsistentStateException(org.akaza.openclinica.web.InconsistentStateException) MailException(org.springframework.mail.MailException) InconsistentStateException(org.akaza.openclinica.web.InconsistentStateException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) MessagingException(javax.mail.MessagingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) MalformedURLException(java.net.MalformedURLException) Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) 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)

Example 42 with StudyDAO

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

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

the class UpdateJobExportServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    TriggerService triggerService = new TriggerService();
    String action = fp.getString("action");
    String triggerName = fp.getString("tname");
    scheduler = getScheduler();
    ExtractUtils extractUtils = new ExtractUtils();
    Trigger updatingTrigger = scheduler.getTrigger(triggerName.trim(), XsltTriggerService.TRIGGER_GROUP_NAME);
    if (StringUtil.isBlank(action)) {
        setUpServlet(updatingTrigger);
        forwardPage(Page.UPDATE_JOB_EXPORT);
    } else if ("confirmall".equalsIgnoreCase(action)) {
        // change and update trigger here
        // validate first
        // then update or send back
        HashMap errors = validateForm(fp, request, scheduler.getTriggerNames(XsltTriggerService.TRIGGER_GROUP_NAME), updatingTrigger.getName());
        if (!errors.isEmpty()) {
            // send back
            addPageMessage("Your modifications caused an error, please see the messages for more information.");
            setUpServlet(updatingTrigger);
            logger.error("errors : " + errors.toString());
            forwardPage(Page.UPDATE_JOB_EXPORT);
        } else {
            // change trigger, update in database
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            StudyBean study = (StudyBean) studyDAO.findByPK(sm.getUserBean().getActiveStudyId());
            DatasetDAO datasetDao = new DatasetDAO(sm.getDataSource());
            CoreResources cr = new CoreResources();
            UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
            int datasetId = fp.getInt(DATASET_ID);
            String period = fp.getString(PERIOD);
            String email = fp.getString(EMAIL);
            String jobName = fp.getString(JOB_NAME);
            String jobDesc = fp.getString(JOB_DESC);
            Date startDateTime = fp.getDateTime(DATE_START_JOB);
            Integer exportFormatId = fp.getInt(FORMAT_ID);
            ExtractPropertyBean epBean = cr.findExtractPropertyBeanById(exportFormatId, "" + datasetId);
            DatasetBean dsBean = (DatasetBean) datasetDao.findByPK(new Integer(datasetId).intValue());
            String[] files = epBean.getFileName();
            String exportFileName;
            int fileSize = files.length;
            int cnt = 0;
            dsBean.setName(dsBean.getName().replaceAll(" ", "_"));
            String[] exportFiles = epBean.getExportFileName();
            String pattern = "yyyy" + File.separator + "MM" + File.separator + "dd" + File.separator + "HHmmssSSS" + File.separator;
            SimpleDateFormat sdfDir = new SimpleDateFormat(pattern);
            int i = 0;
            String[] temp = new String[exportFiles.length];
            // JN: The following logic is for comma separated variables, to avoid the second file be treated as a old file and deleted.
            String datasetFilePath = SQLInitServlet.getField("filePath") + "datasets";
            while (i < exportFiles.length) {
                temp[i] = extractUtils.resolveVars(exportFiles[i], dsBean, sdfDir, datasetFilePath);
                i++;
            }
            epBean.setDoNotDelFiles(temp);
            epBean.setExportFileName(temp);
            XsltTriggerService xsltService = new XsltTriggerService();
            String generalFileDir = SQLInitServlet.getField("filePath");
            generalFileDir = generalFileDir + "datasets" + File.separator + dsBean.getId() + File.separator + sdfDir.format(new java.util.Date());
            exportFileName = epBean.getExportFileName()[cnt];
            String xsltPath = SQLInitServlet.getField("filePath") + "xslt" + File.separator + files[cnt];
            String endFilePath = epBean.getFileLocation();
            endFilePath = extractUtils.getEndFilePath(endFilePath, dsBean, sdfDir, datasetFilePath);
            // exportFileName = resolveVars(exportFileName,dsBean,sdfDir);
            if (epBean.getPostProcExportName() != null) {
                String preProcExportPathName = extractUtils.resolveVars(epBean.getPostProcExportName(), dsBean, sdfDir, datasetFilePath);
                epBean.setPostProcExportName(preProcExportPathName);
            }
            if (epBean.getPostProcLocation() != null) {
                String prePocLoc = extractUtils.getEndFilePath(epBean.getPostProcLocation(), dsBean, sdfDir, datasetFilePath);
                epBean.setPostProcLocation(prePocLoc);
            }
            extractUtils.setAllProps(epBean, dsBean, sdfDir, datasetFilePath);
            SimpleTrigger trigger = null;
            trigger = xsltService.generateXsltTrigger(xsltPath, // xml_file_path
            generalFileDir, endFilePath + File.separator, exportFileName, dsBean.getId(), epBean, userBean, LocaleResolver.getLocale(request).getLanguage(), cnt, SQLInitServlet.getField("filePath") + "xslt", TRIGGER_GROUP_JOB);
            // Updating the original trigger with user given inputs
            trigger.setRepeatCount(64000);
            trigger.setRepeatInterval(XsltTriggerService.getIntervalTime(period));
            trigger.setDescription(jobDesc);
            // set just the start date
            trigger.setStartTime(startDateTime);
            // + datasetId);
            trigger.setName(jobName);
            trigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);
            trigger.getJobDataMap().put(XsltTriggerService.EMAIL, email);
            trigger.getJobDataMap().put(XsltTriggerService.PERIOD, period);
            trigger.getJobDataMap().put(XsltTriggerService.EXPORT_FORMAT, epBean.getFiledescription());
            trigger.getJobDataMap().put(XsltTriggerService.EXPORT_FORMAT_ID, exportFormatId);
            trigger.getJobDataMap().put(XsltTriggerService.JOB_NAME, jobName);
            JobDetailBean jobDetailBean = new JobDetailBean();
            jobDetailBean.setGroup(xsltService.TRIGGER_GROUP_NAME);
            jobDetailBean.setName(trigger.getName());
            jobDetailBean.setJobClass(org.akaza.openclinica.job.XsltStatefulJob.class);
            jobDetailBean.setJobDataMap(trigger.getJobDataMap());
            // need durability?
            jobDetailBean.setDurability(true);
            jobDetailBean.setVolatility(false);
            try {
                // scheduler.unscheduleJob(triggerName, "DEFAULT");
                scheduler.deleteJob(triggerName, XsltTriggerService.TRIGGER_GROUP_NAME);
                Date dataStart = scheduler.scheduleJob(jobDetailBean, trigger);
                // Date dateStart = scheduler.rescheduleJob(triggerName,
                // "DEFAULT", trigger);
                // scheduler.rescheduleJob(triggerName, groupName,
                // newTrigger)
                addPageMessage("Your job has been successfully modified.");
                forwardPage(Page.VIEW_JOB_SERVLET);
            } catch (SchedulerException se) {
                se.printStackTrace();
                // set a message here with the exception message
                setUpServlet(trigger);
                addPageMessage("There was an unspecified error with your creation, please contact an administrator.");
                forwardPage(Page.UPDATE_JOB_EXPORT);
            }
        }
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) CoreResources(org.akaza.openclinica.dao.core.CoreResources) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) JobDetailBean(org.springframework.scheduling.quartz.JobDetailBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) Date(java.util.Date) XsltTriggerService(org.akaza.openclinica.service.extract.XsltTriggerService) TriggerService(org.akaza.openclinica.web.job.TriggerService) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) ExtractUtils(org.akaza.openclinica.service.extract.ExtractUtils) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ExtractPropertyBean(org.akaza.openclinica.bean.extract.ExtractPropertyBean) XsltTriggerService(org.akaza.openclinica.service.extract.XsltTriggerService) SimpleTrigger(org.quartz.SimpleTrigger) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SimpleDateFormat(java.text.SimpleDateFormat)

Example 44 with StudyDAO

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

the class ViewCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    panel.setSubmitDataModule(false);
    panel.setExtractData(false);
    panel.setCreateDataset(false);
    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    List<StudyBean> studyBeans = null;
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
        forwardPage(Page.CRF_LIST);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        crf.setVersions(versions);
        ArrayList<ItemGroupCrvVersionUtil> items_verified = verifyUniqueItemPlacementInGroups(crf.getName());
        request.setAttribute("items", items_verified);
        if ("admin".equalsIgnoreCase(module)) {
            // BWP 3279: generate a table showing a list of studies associated with the CRF>>
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            studyBeans = findStudiesForCRFId(crfId, studyDAO);
            // Create the Jmesa table for the studies associated with the CRF
            String studyHtml = renderStudiesTable(studyBeans);
            request.setAttribute("studiesTableHTML", studyHtml);
        // >>
        }
        Collection<TableColumnHolder> items = populate(crf, versions);
        request.setAttribute(CRF, crf);
        forwardPage(Page.VIEW_CRF);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 45 with StudyDAO

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

the class EditDatasetServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int dsId = fp.getInt("dsId");
    DatasetBean dataset = initializeAttributes(dsId);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) sdao.findByPK(dataset.getStudyId());
    // Checking if user has permission to access the current study/site
    checkRoleByUserAndStudy(ub, study.getParentStudyId(), study.getId());
    // Checking the dataset belongs to current study or a site of current study
    if (study.getId() != currentStudy.getId() && study.getParentStudyId() != currentStudy.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    if ((currentRole.isMonitor() || currentRole.isInvestigator()) && dataset.getOwnerId() != ub.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    HashMap events = (LinkedHashMap) session.getAttribute("eventsForCreateDataset");
    // << tbh
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    // >> tbh 11/2009
    if (events == null || events.isEmpty()) {
        events = new LinkedHashMap();
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyBean studyWithEventDefinitions = currentStudy;
        if (currentStudy.getParentStudyId() > 0) {
            studyWithEventDefinitions = new StudyBean();
            studyWithEventDefinitions.setId(currentStudy.getParentStudyId());
        }
        ArrayList seds = seddao.findAllActiveByStudy(studyWithEventDefinitions);
        for (int i = 0; i < seds.size(); i++) {
            StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seds.get(i);
            ArrayList crfs = (ArrayList) crfdao.findAllActiveByDefinition(sed);
            if (!crfs.isEmpty()) {
                events.put(sed, crfs);
            }
        }
        if (events.isEmpty()) {
            addPageMessage(respage.getString("not_have_study_definitions_assigned"));
            forwardPage(Page.VIEW_DATASETS);
        } else {
            request.setAttribute("eventlist", events);
            session.setAttribute("eventsForCreateDataset", events);
        }
    }
    /*
         * if ("validate".equalsIgnoreCase(action)) { //check name, description, status for right now Validator v = new Validator(request);
         * v.addValidation("dsName", Validator.NO_BLANKS); v.addValidation("dsDesc", Validator.NO_BLANKS); v.addValidation("dsStatus", Validator.IS_VALID_TERM,
         * TermType.STATUS); v.addValidation("dsName", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
         * v.addValidation("dsDesc", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000); //what else to validate?
         * HashMap errors = v.validate(); if (!StringUtil.isBlank(fp.getString("dsName"))) { //logger.info("dsName" + fp.getString("dsName")); DatasetDAO dsdao
         * = new DatasetDAO(sm.getDataSource()); DatasetBean dsBean = (DatasetBean) dsdao.findByNameAndStudy(fp.getString("dsName").trim(), currentStudy); if
         * (dsBean.getId() > 0 && (dsBean.getId() != fp.getInt("dsId"))) { Validator.addError(errors, "dsName",
         * restext.getString("dataset_name_used_by_another_choose_unique")); } } if (!errors.isEmpty()) { String fieldNames[] = { "dsName", "dsDesc" };
         * fp.setCurrentStringValuesAsPreset(fieldNames); fp.addPresetValue("dsStatus", fp.getInt("dsStatus"));
         * addPageMessage(restext.getString("errors_in_update_see_below")); setInputMessages(errors); setPresetValues(fp.getPresetValues()); //TODO determine if
         * this is necessary //int dsId = fp.getInt("dsId"); //DatasetDAO dsDAO = new DatasetDAO(sm.getDataSource()); //DatasetBean showDataset = (DatasetBean)
         * dsDAO.findByPK(dsId); request.setAttribute("dataset", dataset); //maybe just set the above to the session? request.setAttribute("statuses",
         * getStatuses()); forwardPage(Page.EDIT_DATASET); } else { dataset.setName(fp.getString("dsName")); dataset.setDescription(fp.getString("dsDesc"));
         * dataset.setStatus(Status.get(fp.getInt("dsStatus"))); dataset.setUpdater(ub); //dataset.setUpdaterId(ub.getId()); dsDAO.update(dataset);
         * addPageMessage(restext.getString("dataset_properties_updated")); //forward to view all datasets ArrayList datasets = (ArrayList)
         * dsDAO.findAllByStudyId(currentStudy.getId()); //changed from findAll() EntityBeanTable table = fp.getEntityBeanTable(); ArrayList datasetRows =
         * DatasetRow.generateRowsFromBeans(datasets); String[] columns = {resword.getString("dataset_name"), resword.getString("description"),
         * resword.getString("created_by"), resword.getString("created_date"), resword.getString("status"),resword.getString("actions")}; table.setColumns(new
         * ArrayList(Arrays.asList(columns))); table.hideColumnLink(5); table.setQuery("ViewDatasets", new HashMap()); table.setRows(datasetRows);
         * table.computeDisplay(); request.setAttribute("table", table); //request.setAttribute("datasets", datasets); forwardPage(Page.VIEW_DATASETS); } } else
         * {
         */
    request.setAttribute("dataset", dataset);
    request.setAttribute("statuses", getStatuses());
    forwardPage(Page.EDIT_DATASET);
// }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)205 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)184 ArrayList (java.util.ArrayList)116 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)73 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)59 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)50 Date (java.util.Date)49 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)49 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)47 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)43 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)43 HashMap (java.util.HashMap)42 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)39 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)35 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)34 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)30