List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:org.ngrinder.agent.controller.AgentManagerControllerTest.java
@Test public void testApproveAgent() { AgentInfo agent = new AgentInfo(); agent.setApproved(false);// w ww . j a va 2s . c o m agent.setName("Test-Host"); agent.setIp("127.0.0.1"); agent.setState(AgentControllerState.READY); agentManagerRepository.save(agent); ModelMap model = new ModelMap(); // test get agent agentController.getOne(agent.getId(), model); AgentInfo agentInDB = (AgentInfo) model.get("agent"); assertThat(agentInDB.getName(), is(agent.getName())); assertThat(agentInDB.getIp(), is(agent.getIp())); assertThat(agentInDB.isApproved(), is(false)); // test approve agent model.clear(); agentController.approve(agentInDB.getId()); agentController.getOne(agent.getId(), model); agentInDB = (AgentInfo) model.get("agent"); assertThat(agentInDB.isApproved(), is(true)); // test un-approve model.clear(); agentController.disapprove(agentInDB.getId()); agentController.getOne(agent.getId(), model); agentInDB = (AgentInfo) model.get("agent"); assertThat(agentInDB.isApproved(), is(false)); }
From source file:com.forexnepal.controller.HomeController.java
@RequestMapping(value = "/exchange_rates/date/{date}", method = RequestMethod.GET) public @ResponseBody ModelMap ExchangeRatesByDate(@PathVariable(value = "date") Date date) { ModelMap map = new ModelMap(); map.addAttribute("exchangeRatesByDate", exchangeRatesService.getByDate(date)); return map;/*w ww . j av a2 s.c o m*/ }
From source file:org.esco.portlet.accueil.portlet.PortletController.java
@RequestMapping("HELP") public ModelAndView renderHelpView(RenderRequest request, RenderResponse response) throws Exception { ModelMap model = new ModelMap(); return new ModelAndView("help-portlet", model); }
From source file:cz.muni.fi.mir.controllers.UserRoleController.java
@Secured("ROLE_ADMINISTRATOR") @RequestMapping(value = { "/edit", "/edit/" }, method = RequestMethod.POST) @SiteTitle("{entity.userrole.edit}") public ModelAndView editUserRoleSubimt(@Valid @ModelAttribute("userRoleForm") UserRoleForm userRoleForm, BindingResult result, Model model) { if (result.hasErrors()) { ModelMap mm = new ModelMap(); mm.addAttribute(model);//from w ww. ja v a 2s .co m mm.addAttribute("userRoleForm", userRoleForm); return new ModelAndView("user_edit", mm); } else { userRoleService.updateUserRole(mapper.map(userRoleForm, UserRole.class)); return new ModelAndView("redirect:/userrole/list/"); } }
From source file:fragment.web.AbstractProfilesControllerTest.java
/** * Author: vinayv Description: Test to edit ServiceProvider users profiles */// ww w .j a va2 s . c o m @SuppressWarnings("unchecked") @Test public void testEditServiceProviderUserProfiles() { map = new ModelMap(); Profile profile = profileService.getProfile(4L); String authorityNames = ",ROLE_TICKET_MANAGEMENT"; String result = profilesController.editProfile(map, "4", authorityNames); Assert.assertNotNull(result); Assert.assertEquals("profiles.show", result); List<ProfileAuthority> authorityList = profile.getAuthorityList(); Assert.assertEquals(1, authorityList.size()); List<ProfileForm> allProfileList = (List<ProfileForm>) map.get("allProfileList"); Assert.assertNotNull(allProfileList); Assert.assertEquals(profileDAO.count(), allProfileList.size()); List<Profile> globalProfileList = (List<Profile>) profileService.listAllProfilesOfClass(Scope.GLOBAL); List<ProfileForm> opsProfileList = (List<ProfileForm>) map.get("opsProfileList"); Assert.assertEquals(globalProfileList.size(), opsProfileList.size()); List<Profile> tenantProfileList = (List<Profile>) profileService.listAllProfilesOfClass(Scope.TENANT); List<ProfileForm> nonOpsProfileList = (List<ProfileForm>) map.get("nonOpsProfileList"); Assert.assertEquals(tenantProfileList.size(), nonOpsProfileList.size()); Assert.assertTrue(map.containsAttribute("systemProfileName")); }
From source file:com.callcenter.controller.RecordingLibraryServiceControllerTest.java
@Test public void shouldReturnTheShowView(final @NonStrict RecordingLibraryService recordingLibraryService) { assertEquals("recordinglibrary/show", controller.show(1233L, new ModelMap())); }
From source file:cz.muni.fi.mir.controllers.RevisionController.java
@Secured("ROLE_ADMINISTRATOR") @RequestMapping(value = { "/edit/", "/edit/" }, method = RequestMethod.POST) @SiteTitle("{entity.revision.edit}") public ModelAndView editRevisionSubmit(@Valid @ModelAttribute("revisionForm") RevisionForm revisionForm, BindingResult result, Model model) { if (result.hasErrors()) { ModelMap mm = new ModelMap(); mm.addAttribute("revisionForm", revisionForm); mm.addAttribute(model);//from ww w. ja va 2s. c o m return new ModelAndView("revision_edit", mm); } else { revisionService.updateRevision(mapper.map(revisionForm, Revision.class)); return new ModelAndView("redirect:/revision/list/"); } }
From source file:cz.muni.fi.mir.controllers.StatisticsController.java
private ModelMap prepareStatisticsModelMap(Statistics stat, Map<Long, DateTime> dropdownMap) { Map<Pair<Configuration, Revision>, SortedMap<String, Integer>> map = new HashMap<>(); Map<String, Integer> graph = new HashMap<>(); SortedSet<String> columns = new TreeSet<>(); for (StatisticsHolder sh : stat.getStatisticsHolders()) { Pair<Configuration, Revision> key = new Pair<>(sh.getConfiguration(), sh.getRevision()); SortedMap<String, Integer> keyValues = null; if (map.containsKey(key)) { keyValues = map.get(key);/* ww w . ja v a2 s . co m*/ addOrIncrement(sh.getAnnotation(), sh.getCount(), keyValues); addOrIncrement(sh.getAnnotation(), sh.getCount(), graph); } else { keyValues = new TreeMap<>(); keyValues.put(sh.getAnnotation(), sh.getCount()); addOrIncrement(sh.getAnnotation(), sh.getCount(), graph); } map.put(key, keyValues); columns.add(sh.getAnnotation()); } //postprocessing to fill empty columns for (Pair<Configuration, Revision> pair : map.keySet()) { SortedMap<String, Integer> values = map.get(pair); for (String s : columns) { if (!values.containsKey(s)) { values.put(s, 0); } } map.put(pair, values); } ModelMap mm = new ModelMap(); mm.addAttribute("statisticsMap", map); mm.addAttribute("statisticsColumns", columns); mm.addAttribute("statisticsDate", stat.getCalculationDate()); mm.addAttribute("formulaCount", stat.getTotalFormulas()); mm.addAttribute("coCount", stat.getTotalCanonicOutputs()); mm.addAttribute("graph", graph); mm.addAttribute("statisticsDropdown", dropdownMap); return mm; }
From source file:com.forexnepal.controller.AdminController.java
@RequestMapping(value = "bank/scrap_all", method = RequestMethod.GET) public @ResponseBody // String scrapBank(@PathVariable("id") String id) throws IOException { ModelMap scrapBank() throws IOException { Date date = new java.sql.Date(new java.util.Date().getTime()); Time time = new java.sql.Time(new java.util.Date().getTime()); for (int i = 1; i <= 9; i++) { ScrapListener scrapListener = new ScrapListener(currencyService, bankService, exchangeRatesService, date, time, i + ""); scrapListener.start();//w ww. j a v a 2 s. com } // ScrapListener scrapListener = new ScrapListener(currencyService, bankService, exchangeRatesService, date, time, 9+""); // scrapListener.start(); ModelMap map = new ModelMap(); map.addAttribute("date", date); map.addAttribute("time", time); map.addAttribute("message", "Success"); return map; }
From source file:org.esupportail.twitter.web.TwitterController.java
@RequestMapping("VIEW") protected ModelAndView renderView(RenderRequest request, RenderResponse response) throws Exception { ModelMap model = new ModelMap(); final PortletPreferences prefs = request.getPreferences(); String twitterUsername = prefs.getValue(PREF_TWITTER_USERNAME, DEFAULT_TWITTER_USERNAME); String applicationOnlyBearerToken = oAuthTwitterApplicationOnlyService.getApplicationOnlyBearerToken(); String twitterUserToken = prefs.getValue(PREF_TWITTER_USER_TOKEN, null); String twitterUserSecret = prefs.getValue(PREF_TWITTER_USER_SECRET, null); int tweetsNumber = (new Integer(prefs.getValue(PREF_TWITTER_TWEETS_NUMBER, "-1"))).intValue(); // get username timeline with oAuth authentication log.debug("twitterUserToken:" + twitterUserToken); log.debug("twitterUserSecret:" + twitterUserSecret); Twitter twitter;//from w ww . ja v a 2 s . co m TwitterProfile twitterProfile; List<Tweet> tweetList; if (twitterUserToken != null && twitterUserSecret != null) { twitter = new TwitterTemplate(oAuthTwitterConfig.getConsumerKey(), oAuthTwitterConfig.getConsumerSecret(), twitterUserToken, twitterUserSecret); twitterProfile = twitter.userOperations().getUserProfile(); tweetList = twitter.timelineOperations().getHomeTimeline(tweetsNumber); } else { twitter = new TwitterTemplate(applicationOnlyBearerToken); twitterProfile = twitter.userOperations().getUserProfile(twitterUsername); tweetList = twitter.timelineOperations().getUserTimeline(twitterUsername, tweetsNumber); } model.put("tweetList", tweetList); model.put("twitterProfile", twitterProfile); response.setTitle("Twitter " + twitterProfile.getScreenName()); // return new ModelAndView("error", model); return new ModelAndView("view", model); }