Search in sources :

Example 41 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class StudyModuleController method handleMainPage.

@RequestMapping(method = RequestMethod.GET)
public ModelMap handleMainPage(HttpServletRequest request, HttpServletResponse response) {
    ModelMap map = new ModelMap();
    // Todo need something to reset panel from all the Spring Controllers
    StudyInfoPanel panel = new StudyInfoPanel();
    UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    panel.reset();
    request.getSession().setAttribute("panel", panel);
    // setUpSidebar(request);
    ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    eventDefinitionCRFDao = new EventDefinitionCRFDAO(dataSource);
    studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
    crfDao = new CRFDAO(dataSource);
    studyGroupClassDao = new StudyGroupClassDAO(dataSource);
    studyDao = new StudyDAO(dataSource);
    userDao = new UserAccountDAO(dataSource);
    ruleDao = new RuleDAO(dataSource);
    StudyModuleStatus sms = studyModuleStatusDao.findByStudyId(currentStudy.getId());
    if (sms == null) {
        sms = new StudyModuleStatus();
        sms.setStudyId(currentStudy.getId());
    }
    int crfCount = crfDao.findAllByStudy(currentStudy.getId()).size();
    int crfWithEventDefinition = crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
    int totalCrf = crfCount + crfWithEventDefinition;
    // int eventDefinitionCount = eventDefinitionCRFDao.findAllActiveByStudy(currentStudy).size();
    int eventDefinitionCount = studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
    int subjectGroupCount = studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
    // List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByStudy(currentStudy);
    // ruleSets = ruleSetService.filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets);
    int ruleCount = ruleSetService.getCountByStudy(currentStudy);
    int siteCount = studyDao.findOlnySiteIdsByStudy(currentStudy).size();
    int userCount = userDao.findAllUsersByStudy(currentStudy.getId()).size();
    Collection childStudies = studyDao.findAllByParent(currentStudy.getId());
    Map childStudyUserCount = new HashMap();
    for (Object sb : childStudies) {
        StudyBean childStudy = (StudyBean) sb;
        childStudyUserCount.put(childStudy.getName(), userDao.findAllUsersByStudy(childStudy.getId()).size());
    }
    if (sms.getCrf() == 0) {
        sms.setCrf(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getCrf() != 3 && totalCrf > 0) {
        sms.setCrf(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getEventDefinition() == 0) {
        sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
        sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSubjectGroup() == 0) {
        sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
        sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getRule() == 0) {
        sms.setRule(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getRule() != 3 && ruleCount > 0) {
        sms.setRule(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSite() == 0) {
        sms.setSite(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSite() != 3 && siteCount > 0) {
        sms.setSite(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getUsers() == 0) {
        sms.setUsers(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getUsers() != 3 && userCount > 0) {
        sms.setUsers(StudyModuleStatus.IN_PROGRESS);
    }
    map.addAttribute(sms);
    map.addAttribute("crfCount", totalCrf);
    map.addAttribute("eventDefinitionCount", eventDefinitionCount);
    map.addAttribute("subjectGroupCount", subjectGroupCount);
    map.addAttribute("ruleCount", ruleCount);
    map.addAttribute("siteCount", siteCount);
    map.addAttribute("userCount", userCount);
    map.addAttribute("childStudyUserCount", childStudyUserCount);
    map.addAttribute("studyId", currentStudy.getId());
    map.addAttribute("currentStudy", currentStudy);
    // Load Participate registration information
    String portalURL = CoreResources.getField("portalURL");
    map.addAttribute("portalURL", portalURL);
    if (portalURL != null && !portalURL.equals("")) {
        String participateOCStatus = currentStudy.getStudyParameterConfig().getParticipantPortal();
        ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
        Authorization pManageAuthorization = registrar.getAuthorization(currentStudy.getOid());
        String participateStatus = "";
        String url = "";
        try {
            URL pManageUrl = new URL(portalURL);
            if (pManageAuthorization != null && pManageAuthorization.getAuthorizationStatus() != null && pManageAuthorization.getAuthorizationStatus().getStatus() != null)
                participateStatus = pManageAuthorization.getAuthorizationStatus().getStatus();
            map.addAttribute("participateURL", pManageUrl);
            map.addAttribute("participateOCStatus", participateOCStatus);
            map.addAttribute("participateStatus", participateStatus);
            if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
                url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
            }
        } catch (MalformedURLException e) {
            logger.error(e.getMessage());
            logger.error(ExceptionUtils.getStackTrace(e));
        }
        map.addAttribute("participateURLDisplay", url);
        map.addAttribute("participateURLFull", url + "/#/login");
    }
    // Load Randomization  information
    String moduleManager = CoreResources.getField("moduleManager");
    map.addAttribute("moduleManager", moduleManager);
    if (moduleManager != null && !moduleManager.equals("")) {
        String randomizationOCStatus = currentStudy.getStudyParameterConfig().getRandomization();
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO randomization = null;
        try {
            randomization = randomizationRegistrar.getCachedRandomizationDTOObject(currentStudy.getOid(), true);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        String randomizationStatus = "";
        URL randomizeUrl = null;
        if (randomization != null && randomization.getStatus() != null) {
            randomizationStatus = randomization.getStatus();
            if (randomization.getUrl() != null) {
                try {
                    randomizeUrl = new URL(randomization.getUrl());
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        map.addAttribute("randomizeURL", randomizeUrl);
        map.addAttribute("randomizationOCStatus", randomizationOCStatus);
        map.addAttribute("randomizationStatus", randomizationStatus);
    }
    // @pgawade 13-April-2011- #8877: Added the rule designer URL
    if (null != coreResources) {
        map.addAttribute("ruleDesignerURL", coreResources.getField("designer.url"));
        map.addAttribute("contextPath", getContextPath(request));
        logMe("before checking getHostPath url = " + request.getRequestURL());
        // JN: for the eclinicalhosting the https is not showing up in the request path, going for a fix of taking
        // the hostpath from sysurl
        // map.addAttribute("hostPath", getHostPath(request));
        map.addAttribute("hostPath", getHostPathFromSysUrl(coreResources.getField("sysURL.base"), request.getContextPath()));
        map.addAttribute("path", "pages/studymodule");
    }
    // UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    request.setAttribute("userBean", userBean);
    ArrayList statusMap = Status.toStudyUpdateMembersList();
    // statusMap.add(Status.PENDING);
    request.setAttribute("statusMap", statusMap);
    if (currentStudy.getParentStudyId() > 0) {
        StudyBean parentStudy = (StudyBean) studyDao.findByPK(currentStudy.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    }
    ArrayList pageMessages = new ArrayList();
    if (request.getSession().getAttribute("pageMessages") != null) {
        pageMessages.addAll((ArrayList) request.getSession().getAttribute("pageMessages"));
        request.setAttribute("pageMessages", pageMessages);
        request.getSession().removeAttribute("pageMessages");
    }
    ArrayList regMessages = new ArrayList();
    if (request.getSession().getAttribute(REG_MESSAGE) != null) {
        regMessages.addAll((ArrayList) request.getSession().getAttribute(REG_MESSAGE));
        request.setAttribute(REG_MESSAGE, regMessages);
        request.getSession().removeAttribute(REG_MESSAGE);
    }
    return map;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) ArrayList(java.util.ArrayList) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel) URL(java.net.URL) RuleDAO(org.akaza.openclinica.dao.rule.RuleDAO) Authorization(org.akaza.openclinica.service.pmanage.Authorization) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyModuleStatus(org.akaza.openclinica.domain.managestudy.StudyModuleStatus) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) Collection(java.util.Collection) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class ScheduledJobController method listScheduledJobs.

@RequestMapping("/listCurrentScheduledJobs")
public ModelMap listScheduledJobs(HttpServletRequest request, HttpServletResponse response) throws SchedulerException {
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    ModelMap gridMap = new ModelMap();
    String[] triggerNames;
    boolean showMoreLink = false;
    if (request.getParameter("showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(request.getParameter("showMoreLink").toString());
    } else {
        showMoreLink = true;
    }
    request.setAttribute("showMoreLink", showMoreLink + "");
    // request.setAttribute("studySubjectId",studySubjectId);
    /*SubjectIdSDVFactory tableFactory = new SubjectIdSDVFactory();
        * @RequestParam("studySubjectId") int studySubjectId,*/
    request.setAttribute("imagePathPrefix", "../");
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    List<JobExecutionContext> listCurrentJobs = new ArrayList<JobExecutionContext>();
    listCurrentJobs = scheduler.getCurrentlyExecutingJobs();
    Iterator<JobExecutionContext> itCurrentJobs = listCurrentJobs.iterator();
    List<String> currentJobList = new ArrayList<String>();
    while (itCurrentJobs.hasNext()) {
        JobExecutionContext temp = itCurrentJobs.next();
        currentJobList.add(temp.getTrigger().getJobKey().getName() + temp.getTrigger().getKey().getGroup());
    }
    List<String> triggerGroupNames = scheduler.getTriggerGroupNames();
    String[] triggerGroups = triggerGroupNames.stream().toArray(String[]::new);
    List<SimpleTrigger> simpleTriggers = new ArrayList<SimpleTrigger>();
    int index1 = 0;
    for (String triggerGroup : triggerGroups) {
        logger.debug("Group: " + triggerGroup + " contains the following triggers");
        Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(triggerGroup));
        triggerNames = triggerKeys.stream().toArray(String[]::new);
        for (String triggerName : triggerNames) {
            Trigger.TriggerState state = scheduler.getTriggerState(TriggerKey.triggerKey(triggerName, triggerGroup));
            logger.debug("- " + triggerName);
            if (state != Trigger.TriggerState.PAUSED) {
                simpleTriggers.add(index1, (SimpleTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerName, triggerGroup)));
                index1++;
            }
        }
    }
    List<ScheduledJobs> jobsScheduled = new ArrayList<ScheduledJobs>();
    int index = 0;
    for (SimpleTrigger st : simpleTriggers) {
        boolean isExecuting = currentJobList.contains(st.getJobKey().getName() + st.getJobKey().getGroup());
        ScheduledJobs jobs = new ScheduledJobs();
        ExtractPropertyBean epBean = null;
        if (st.getJobDataMap() != null) {
            epBean = (ExtractPropertyBean) st.getJobDataMap().get(EP_BEAN);
        }
        if (epBean != null) {
            StringBuilder checkbox = new StringBuilder();
            checkbox.append("<input style='margin-right: 5px' type='checkbox'/>");
            StringBuilder actions = new StringBuilder("<table><tr><td>");
            if (isExecuting) {
                actions.append("&nbsp;");
            } else {
                String contextPath = request.getContextPath();
                StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/cancelScheduledJob").append("';").append("this.form.theJobName.value='").append(st.getJobKey().getName()).append("';").append("this.form.theJobGroupName.value='").append(st.getJobKey().getGroup()).append("';").append("this.form.theTriggerName.value='").append(st.getJobKey().getName()).append("';").append("this.form.theTriggerGroupName.value='").append(st.getJobKey().getGroup()).append("';").append("this.form.submit();");
                actions.append("<td><input type=\"submit\" class=\"button\" value=\"Cancel Job\" ").append("name=\"cancelJob\" onclick=\"").append(jsCodeString.toString()).append("\" />");
            }
            actions.append("</td></tr></table>");
            jobs.setCheckbox(checkbox.toString());
            jobs.setDatasetId(epBean.getDatasetName());
            String fireTime = st.getStartTime() != null ? longFormat(locale).format(st.getStartTime()) : "";
            jobs.setFireTime(fireTime);
            if (st.getNextFireTime() != null) {
                jobs.setScheduledFireTime(longFormat(locale).format(st.getNextFireTime()));
            }
            jobs.setExportFileName(epBean.getExportFileName()[0]);
            jobs.setAction(actions.toString());
            jobs.setJobStatus(isExecuting ? "Currently Executing" : "Scheduled");
            jobsScheduled.add(index, jobs);
            index++;
        }
    }
    logger.debug("totalRows" + index);
    request.setAttribute("totalJobs", index);
    request.setAttribute("jobs", jobsScheduled);
    TableFacade facade = scheduledJobTableFactory.createTable(request, response);
    String sdvMatrix = facade.render();
    gridMap.addAttribute(SCHEDULED_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : ModelMap(org.springframework.ui.ModelMap) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) TableFacade(org.jmesa.facade.TableFacade) ScheduledJobs(org.akaza.openclinica.web.table.scheduledjobs.ScheduledJobs) ExtractPropertyBean(org.akaza.openclinica.bean.extract.ExtractPropertyBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class SDVController method viewSubjectHandler.

@RequestMapping("/viewAllSubjectSDV")
public ModelMap viewSubjectHandler(HttpServletRequest request, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("studyId") int studyId) {
    ModelMap gridMap = new ModelMap();
    /*EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
        List<EventCRFBean> eventCRFBeans = eventCRFDAO.findAllByStudySubject(studySubjectId);*/
    request.setAttribute("studyId", studyId);
    request.setAttribute("studySubjectId", studySubjectId);
    //  request.setAttribute("isViewSubjectRequest","y");
    request.setAttribute("imagePathPrefix", "../");
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    String sdvMatrix = sdvUtil.renderSubjectsTableWithLimit(request, studyId, studySubjectId);
    gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : ModelMap(org.springframework.ui.ModelMap) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 44 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class ExtractController method processSubmit.

/**
     * process the page from whence you came, i.e. extract a dataset
     * @param id, the id of the extract properties bean, gained from Core Resources
     * @param datasetId, the id of the dataset, found through DatasetDAO
     * @param request, http request
     * @return model map, but more importantly, creates a quartz job which runs right away and generates all output there
     */
@RequestMapping(method = RequestMethod.GET)
public ModelMap processSubmit(@RequestParam("id") String id, @RequestParam("datasetId") String datasetId, HttpServletRequest request, HttpServletResponse response) {
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    ModelMap map = new ModelMap();
    ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
    // String datasetId = (String)request.getAttribute("datasetId");
    // String id = (String)request.getAttribute("id");
    logger.debug("found both id " + id + " and dataset " + datasetId);
    ExtractUtils extractUtils = new ExtractUtils();
    // get extract id
    // get dataset id
    // if id is a number and dataset id is a number ...
    datasetDao = new DatasetDAO(dataSource);
    UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    CoreResources cr = new CoreResources();
    ExtractPropertyBean epBean = cr.findExtractPropertyBeanById(new Integer(id).intValue(), datasetId);
    DatasetBean dsBean = (DatasetBean) datasetDao.findByPK(new Integer(datasetId).intValue());
    // set the job in motion
    String[] files = epBean.getFileName();
    String exportFileName;
    int fileSize = files.length;
    int cnt = 0;
    SimpleTrigger simpleTrigger = null;
    //TODO: if files and export names size is not same... throw an error
    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.
    while (i < exportFiles.length) {
        temp[i] = resolveVars(exportFiles[i], dsBean, sdfDir, SQLInitServlet.getField("filePath"), extractUtils);
        i++;
    }
    epBean.setDoNotDelFiles(temp);
    epBean.setExportFileName(temp);
    XsltTriggerService xsltService = new XsltTriggerService();
    // TODO get a user bean somehow?
    String generalFileDir = SQLInitServlet.getField("filePath");
    generalFileDir = generalFileDir + "datasets" + File.separator + dsBean.getId() + File.separator + sdfDir.format(new java.util.Date());
    exportFileName = epBean.getExportFileName()[cnt];
    // need to set the dataset path here, tbh
    logger.debug("found odm xml file path " + generalFileDir);
    // next, can already run jobs, translations, and then add a message to be notified later
    //JN all the properties need to have the variables...
    String xsltPath = SQLInitServlet.getField("filePath") + "xslt" + File.separator + files[cnt];
    String endFilePath = epBean.getFileLocation();
    endFilePath = getEndFilePath(endFilePath, dsBean, sdfDir, SQLInitServlet.getField("filePath"), extractUtils);
    //  exportFileName = resolveVars(exportFileName,dsBean,sdfDir);
    if (epBean.getPostProcExportName() != null) {
        //String preProcExportPathName = getEndFilePath(epBean.getPostProcExportName(),dsBean,sdfDir);
        String preProcExportPathName = resolveVars(epBean.getPostProcExportName(), dsBean, sdfDir, SQLInitServlet.getField("filePath"), extractUtils);
        epBean.setPostProcExportName(preProcExportPathName);
    }
    if (epBean.getPostProcLocation() != null) {
        String prePocLoc = getEndFilePath(epBean.getPostProcLocation(), dsBean, sdfDir, SQLInitServlet.getField("filePath"), extractUtils);
        epBean.setPostProcLocation(prePocLoc);
    }
    setAllProps(epBean, dsBean, sdfDir, extractUtils);
    // also need to add the status fields discussed w/ cc:
    // result code, user message, optional URL, archive message, log file message
    // asdf table: sort most recent at top
    logger.debug("found xslt file name " + xsltPath);
    // String xmlFilePath = generalFileDir + ODMXMLFileName;
    simpleTrigger = xsltService.generateXsltTrigger(scheduler, xsltPath, // xml_file_path
    generalFileDir, endFilePath + File.separator, exportFileName, dsBean.getId(), epBean, userBean, LocaleResolver.getLocale(request).getLanguage(), cnt, SQLInitServlet.getField("filePath") + "xslt", this.TRIGGER_GROUP_NAME);
    // System.out.println("just set locale: " + LocaleResolver.getLocale(request).getLanguage());
    cnt++;
    ApplicationContext context = null;
    try {
        context = (ApplicationContext) scheduler.getContext().get("applicationContext");
    } catch (SchedulerException e) {
        e.printStackTrace();
    }
    //WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
    JobDetailFactoryBean jobDetailFactoryBean = context.getBean(JobDetailFactoryBean.class, simpleTrigger, this.TRIGGER_GROUP_NAME);
    try {
        Date dateStart = scheduler.scheduleJob(jobDetailFactoryBean.getObject(), simpleTrigger);
        logger.debug("== found job date: " + dateStart.toString());
    } catch (SchedulerException se) {
        se.printStackTrace();
    }
    request.setAttribute("datasetId", datasetId);
    // set the job name here in the user's session, so that we can ping the scheduler to pull it out later
    if (jobDetailFactoryBean != null)
        request.getSession().setAttribute("jobName", jobDetailFactoryBean.getObject().getKey().getName());
    if (simpleTrigger != null)
        request.getSession().setAttribute("groupName", this.TRIGGER_GROUP_NAME);
    request.getSession().setAttribute("datasetId", new Integer(dsBean.getId()));
    return map;
}
Also used : SchedulerException(org.quartz.SchedulerException) Date(java.util.Date) ModelMap(org.springframework.ui.ModelMap) CoreResources(org.akaza.openclinica.dao.core.CoreResources) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) SchedulerException(org.quartz.SchedulerException) Date(java.util.Date) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) 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) SimpleDateFormat(java.text.SimpleDateFormat) JobDetailFactoryBean(org.springframework.scheduling.quartz.JobDetailFactoryBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class SDVController method viewAllSubjectHandler.

@RequestMapping("/viewAllSubjectSDVtmp")
public ModelMap viewAllSubjectHandler(HttpServletRequest request, @RequestParam("studyId") int studyId, HttpServletResponse response) {
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
    // Reseting the side info panel set by SecureControler Mantis Issue: 8680.
    // Todo need something to reset panel from all the Spring Controllers
    StudyInfoPanel panel = new StudyInfoPanel();
    panel.reset();
    HttpSession session = request.getSession();
    request.getSession().setAttribute("panel", panel);
    ModelMap gridMap = new ModelMap();
    //set up request attributes for sidebar
    //Not necessary when using old page design...
    // setUpSidebar(request);
    boolean showMoreLink = false;
    if (session.getAttribute("tableFacadeRestore") != null && session.getAttribute("tableFacadeRestore") == "false") {
        session.setAttribute("tableFacadeRestore", "true");
        session.setAttribute("sSdvRestore", "false");
        showMoreLink = true;
    } else if (request.getParameter("showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(request.getParameter("showMoreLink").toString());
    } else if (session.getAttribute("sdv_showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(session.getAttribute("sdv_showMoreLink") + "");
    } else {
        showMoreLink = true;
    }
    request.setAttribute("showMoreLink", showMoreLink + "");
    session.setAttribute("sdv_showMoreLink", showMoreLink + "");
    request.setAttribute("studyId", studyId);
    String restore = (String) request.getAttribute("sdv_restore");
    restore = restore != null && restore.length() > 0 ? restore : "false";
    request.setAttribute("sdv_restore", restore);
    //request.setAttribute("imagePathPrefix","../");
    //We need a study subject id for the first tab;
    Integer studySubjectId = (Integer) request.getAttribute("studySubjectId");
    studySubjectId = studySubjectId == null || studySubjectId == 0 ? 0 : studySubjectId;
    request.setAttribute("studySubjectId", studySubjectId);
    //set up the elements for the view's filter box
    // sdvUtil.prepareSDVSelectElements(request,studyBean);
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    String sdvMatrix = sdvUtil.renderEventCRFTableWithLimit(request, studyId, "../");
    gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelMap(org.springframework.ui.ModelMap) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelMap (org.springframework.ui.ModelMap)48 Test (org.junit.Test)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 ModelAndView (org.springframework.web.servlet.ModelAndView)11 RedirectAttributesModelMap (org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 IOException (java.io.IOException)3 Date (java.util.Date)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 HttpSessionRequiredException (org.springframework.web.HttpSessionRequiredException)3 RedirectAttributes (org.springframework.web.servlet.mvc.support.RedirectAttributes)3 NimbusClient (backtype.storm.utils.NimbusClient)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpSession (javax.servlet.http.HttpSession)2