List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:fragment.web.AbstractProductsControllerTest.java
@Test public void testAllFilterWithSelectedCategoryInHistoryViewForProducts() { int count = 0; boolean hasNext = true; int page = 1; ModelMap map1 = new ModelMap(); while (hasNext) { String result = productsController.listProducts("003fa8ee-fba3-467f-a517-fd806dae8a80", Integer.toString(page), null, null, "history", null, "All", "Categorized1", map1); Assert.assertNotNull(result);// www . ja va2s. c o m Assert.assertEquals("products.list", result); List<Product> productList = (List<Product>) map1.get("productsList"); count = count + productList.size(); hasNext = (Boolean) map1.get("enableNext"); page = page + 1; } Assert.assertEquals(2, count); }
From source file:fragment.web.RegistrationControllerTest.java
/** * Description : test to verify the blacklisted countries will not show for user to signup in the country list * //w w w . j a va 2 s . c o m * @author nageswarap * @throws Exception */ @SuppressWarnings("unchecked") @Test public void testUserInfoWithBlackListedCountries() { int filteredCountriesBefore; int filteredCountriesAfter; // creating a ModelMap object and Registration object ModelMap model = new ModelMap(); UserRegistration registration = new UserRegistration(); // get the Account type for registration AccountType disposition = registrationService.getTrialAccountType(); BindingResult result; registration.setAcceptedTerms(true); // calling the setupRegistration private method to setup the registration object result = setupRegistration(disposition, registration); // getting the list of countries that are available for registration, before adding the black list country String view = controller.userInfo(registration, result, model, null, status, request); Assert.assertEquals("register.moreuserinfo", view); List<Country> filteredCountriesListBefore = (List<Country>) model.get("filteredCountryList"); filteredCountriesBefore = filteredCountriesListBefore.size(); // updating the blacklisted countries in CPBM configurationService.clearConfigurationCache(true, ""); com.vmops.model.Configuration blackListCountries = configurationService .locateConfigurationByName("com.citrix.cpbm.accountManagement.onboarding.country.blacklist"); blackListCountries.setValue("IN,US"); configurationService.update(blackListCountries); // getting the list of countries that are available for registration, before adding the black list country String view1 = controller.userInfo(registration, result, model, null, status, request); Assert.assertEquals("register.moreuserinfo", view1); List<Country> filteredCountriesListAfter = (List<Country>) model.get("filteredCountryList"); filteredCountriesAfter = filteredCountriesListAfter.size(); // Asserting the countries count before and after Assert.assertEquals("the countries count not matched", filteredCountriesBefore - 2, filteredCountriesAfter); // verifying the Blacklisted country is not available in the filtered countries list // TODO: add verification for US not present boolean countryFound = false; for (Country country : filteredCountriesListAfter) { if ("IN".equalsIgnoreCase(country.getCountryCode2())) { countryFound = true; break; } } Assert.assertFalse("black listed country found in the filtered list", countryFound); }
From source file:com.Voxce.Controllers.TrialsController.java
public ModelAndView CreateSubmission(HttpServletRequest request, HttpServletResponse response) throws Exception { List<ApprovalStatusType> approvalstatustypelist; List<SubmissionType> submissiontypelist; List<Sites> siteslist;// ww w. ja va2 s . c om List<Submission> submissionlist; List<ProtocolVersion> versionlist; List<Countries> countrieslist; approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id()); submissiontypelist = submissiontypedao.listsubmissiontype(currentstudy.getStudy_id()); versionlist = traininguserdao.listprotocolversions(currentstudy.getStudy_id()); siteslist = sitedao.SitesList(CurrentUser); submissionlist = submissiondao.listsubmission(currentstudy.getStudy_id()); countrieslist = countriesDAO.listCountry(); Submission submission = new Submission(); submission.setStudy_id(currentstudy.getStudy_id()); String id = request.getParameter("submission_edit_id"); int idnum = Integer.parseInt(id); if (idnum != 0) { //user is editing the approval status type if (Integer.parseInt(request.getParameter("upload_submission")) == 2) { //editing user training but not uploaded new document System.out.println("editing..kk"); Submission temp = new Submission(); temp = submissiondao.find(idnum); if (temp.getFilename() != null) { submissionitem = null; submission.setData(temp.getData()); submission.setFilename(temp.getFilename()); submission.setType(temp.getType()); } } submission.setSubmission_id(idnum); String str = request.getParameter("create_submission_date_created"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2]; */ java.sql.Date datecreated = java.sql.Date.valueOf(str); submission.setDate_created(datecreated); submission.setCreated_by(Integer.parseInt(request.getParameter("submission_created_by"))); submission.setModified_by((int) CurrentUser.getUser_id()); } else { submission.setModified_by((int) CurrentUser.getUser_id()); submission.setCreated_by((int) CurrentUser.getUser_id()); } submission.setApproval_status_type_id(Integer.parseInt(request.getParameter("submission_approval"))); if (request.getParameter("actual_review_date") != "" && request.getParameter("actual_review_date") != null) { String str = request.getParameter("actual_review_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2]; */ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setActual_review_date(sub_date); } if (request.getParameter("approval_date") != "" && request.getParameter("approval_date") != null) { String str = request.getParameter("approval_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2]; */ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setApproval_date(sub_date); } if (request.getParameter("expiration_date") != "" && request.getParameter("expiration_date") != null) { String str = request.getParameter("expiration_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2]; */ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setExpiration_date(sub_date); } if (request.getParameter("material_sent_date") != "" && request.getParameter("material_sent_date") != null) { String str = request.getParameter("material_sent_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2]; */ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setMaterial_sent_date(sub_date); } if (request.getParameter("schedule_review_date") != "" && request.getParameter("schedule_review_date") != null) { String str = request.getParameter("schedule_review_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2];*/ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setSched_review_date(sub_date); } if (request.getParameter("concent_date") != "" && request.getParameter("concent_date") != null) { String str = request.getParameter("concent_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2];*/ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setConsent_date(sub_date); } submission.setSubmission_name(request.getParameter("create_submission_name").trim()); submission.setSubmission_type_id(Integer.parseInt(request.getParameter("submission_type"))); if (request.getParameter("submission_site") != "" && request.getParameter("submission_site") != null) { submission.setSite_id(Integer.parseInt(request.getParameter("submission_site"))); } submission.setDescription(request.getParameter("submission_description")); if (request.getParameter("submission_file_description") != "") { submission.setFile_description(request.getParameter("submission_file_description")); } String str = request.getParameter("submission_date"); /*String delimeter = "-"; String[] temp; temp = str.split(delimeter); str = temp[0] + "-" + temp[1] + "-" + temp[2];*/ java.sql.Date sub_date = java.sql.Date.valueOf(str); submission.setSubmission_date(sub_date); String st = request.getParameter("submission_protocol"); String tempvar[] = st.split("-"); submission.setProtocol_id(tempvar[0]); submission.setProtocol_version(tempvar[1]); submission.setRegulatorybody_name(request.getParameter("submission_regulatory_body_name").trim()); submission.setRegulatorybody_country(request.getParameter("submission_regulatory_body_country")); submission.setStudy_id(currentstudy.getStudy_id()); //=====================================================create submission========================================================// int Message = submissiondao.UploadSubmission(submissionitem, submission, idnum); try { submissionlist = submissiondao.listsubmission(currentstudy.getStudy_id()); ModelMap modelMap = new ModelMap(); modelMap.addAttribute("currentstudy", currentstudy); modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist); modelMap.addAttribute("submissiontypelist", submissiontypelist); modelMap.addAttribute("countrieslist", countrieslist); modelMap.addAttribute("siteslist", siteslist); modelMap.addAttribute("submissionlist", submissionlist); modelMap.addAttribute("versionlist", versionlist); if (idnum == 0) { modelMap.addAttribute("CurrentFormSubmission", "Create_Submission_div"); modelMap.addAttribute("MessageCode", Message); } else { modelMap.addAttribute("CurrentFormSubmission", "View_Submission_div"); if (Message == 0) { modelMap.addAttribute("ESError", "Submission cannot be updated at this time !"); } else if (Message == 1) { modelMap.addAttribute("ESSuccess", "Submission successfully updated..."); } } return new ModelAndView("submissions", modelMap); } catch (Exception expObj) { return new ModelAndView("submissions"); } }
From source file:fragment.web.AbstractProductsControllerTest.java
@Test public void testAllFilterWithNullCategoryInHistoryViewForProducts() { int count = 0; boolean hasNext = true; int page = 1; ModelMap map1 = new ModelMap(); while (hasNext) { String result = productsController.listProducts("003fa8ee-fba3-467f-a517-fd806dae8a80", Integer.toString(page), null, null, "history", null, "All", null, map1); Assert.assertNotNull(result);/*from ww w .j a v a 2s . co m*/ Assert.assertEquals("products.list", result); List<Product> productList = (List<Product>) map1.get("productsList"); count = count + productList.size(); hasNext = (Boolean) map1.get("enableNext"); page = page + 1; } Assert.assertEquals(35, count); }
From source file:fragment.web.AbstractProductsControllerTest.java
@Test public void testAllFilterWithEmptyCategoryInHistoryViewForProducts() { int count = 0; boolean hasNext = true; int page = 1; ModelMap map1 = new ModelMap(); while (hasNext) { String result = productsController.listProducts("003fa8ee-fba3-467f-a517-fd806dae8a80", Integer.toString(page), null, null, "history", null, "All", "", map1); Assert.assertNotNull(result);// www . j a va 2s. c om Assert.assertEquals("products.list", result); List<Product> productList = (List<Product>) map1.get("productsList"); count = count + productList.size(); hasNext = (Boolean) map1.get("enableNext"); page = page + 1; } Assert.assertEquals(35, count); }
From source file:fragment.web.RegistrationControllerTest.java
/** * Description : test to verify the whitelisted countries will only show for user to signup in the country list * //from www .ja va 2 s. c om * @author nageswarap * @throws Exception */ @Test public void testUserInfoWithWhiteListedCountries() { int filteredCountriesAfter; // creating a ModelMap object and Registration object ModelMap model = new ModelMap(); UserRegistration registration = new UserRegistration(); // get the Account type for registration AccountType disposition = accountTypeDAO.getTrialAccountType(); BindingResult result; registration.setAcceptedTerms(true); // calling the setupRegistration private method to setup the registration object result = setupRegistration(disposition, registration); // updating the blacklisted countries in CPBM configurationService.clearConfigurationCache(true, ""); com.vmops.model.Configuration blackListCountries = configurationService .locateConfigurationByName("com.citrix.cpbm.accountManagement.onboarding.country.whitelist"); blackListCountries.setValue("IN"); configurationService.update(blackListCountries); // getting the list of countries that are available for registration, before adding the black list country String view1 = controller.userInfo(registration, result, model, null, status, request); Assert.assertEquals("register.moreuserinfo", view1); List<Country> filteredCountries = (List<Country>) model.get("filteredCountryList"); filteredCountriesAfter = filteredCountries.size(); // Asserting the countries count after setting the white list Assert.assertEquals("the countries count not matched", 1, filteredCountriesAfter); // verifying the white listed country is not available in the filtered countries list Assert.assertEquals("white listed country not found in the filtered list", "IN", filteredCountries.get(0).getCountryCode2()); }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "{title}", method = RequestMethod.POST) public ModelAndView save(@PathVariable String title, @RequestParam String content) { ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); Article article = new Article(); article.setTitle(title);/* www . j ava 2 s .c om*/ article.setContent(content); article.setUserId(StringUtils.EMPTY); article.setPublished(true); articleService.save(article); mav.setViewName(View.ARTICLE); mav.addAllObjects(model); return new ModelAndView(new RedirectView(URL.makeAbsolutePath(URL.ARTICLE, title))); }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "{title}/{chapterCssId}", method = RequestMethod.POST) public ModelAndView checkAnswer(HttpServletRequest request, @PathVariable String title, @PathVariable String chapterCssId, @RequestParam String answer) { Integer chapterIndex = Integer.valueOf(chapterCssId.replace(Consts.CHAPTER, StringUtils.EMPTY)); ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("keynote")) { Article article = articleService.get(title); if (article == null || !article.getUserId().equals(sessionService.getLoginUser().getUserId())) { break; }/* ww w. ja v a 2 s .c om*/ // keynote mode if (!articleService.isChapterExisted(title, chapterIndex + 1)) { bookmarkService.complete(title); return new ModelAndView("redirect:/article/" + title + "/license"); } model.addAttribute("chapter", articleService.getChapter(title, chapterIndex + 1)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("answer", articleService.getChapter(title, chapterIndex).getQuiz().getAnswer()); mav.setViewName(View.CHAPTER); mav.addAllObjects(model); bookmarkService.updateChapter(title, chapterIndex + 1); return mav; } } // word mode Chapter chapter = articleService.getChapter(title, chapterIndex); if (answerService.check(chapter, answer)) { if (!articleService.isChapterExisted(title, chapterIndex + 1)) { bookmarkService.complete(title); return new ModelAndView("redirect:/article/" + title + "/license"); } model.addAttribute("chapter", articleService.getChapter(title, chapterIndex + 1)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("answer", articleService.getChapter(title, chapterIndex).getQuiz().getAnswer()); mav.setViewName(View.CHAPTER); mav.addAllObjects(model); bookmarkService.updateChapter(title, chapterIndex + 1); } else { mav.setViewName(View.WRONG); mav.addAllObjects(model); } return mav; }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "", method = RequestMethod.GET) public ModelAndView list() { ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); List<Article> articles = articleService.getAll(); List<String> tags = tagService.getTags(); model.addAttribute("articles", articles); model.addAttribute("tags", tags); mav.setViewName(View.ARTICLES); mav.addAllObjects(model);//from www .j a v a2s. c o m return mav; }