List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:info.raack.appliancedetection.evaluation.web.SimulationController.java
@RequestMapping(value = "/simulationcontrolpanel", method = RequestMethod.GET) public ModelAndView showSimulationControlPanel(HttpServletRequest request, HttpServletResponse response) { ModelMap modelMap = new ModelMap(); modelMap.put("simulations", simulationService.getAllSimulationInformation()); modelMap.put("algorithms", new ArrayList<ApplianceEnergyConsumptionDetectionAlgorithm>(algorithms)); return new ModelAndView("controlPanel", modelMap); }
From source file:org.esupportail.portlet.filemanager.portlet.PortletControllerAjax.java
/** * Data for the browser area./*w ww. j ava 2 s . c o m*/ * @param dir * @param request * @param response * @return */ @ResourceMapping("htmlFileTree") public ModelAndView fileTree(@RequestParam String dir, @RequestParam(required = false) String sortField, ResourceRequest request, ResourceResponse response) { dir = pathEncodingUtils.decodeDir(dir); ModelMap model = new ModelMap(); if (this.serverAccess.formAuthenticationRequired(dir, userParameters)) { model = new ModelMap("currentDir", pathEncodingUtils.encodeDir(dir)); model.put("username", this.serverAccess.getUserPassword(dir, userParameters).getUsername()); model.put("password", this.serverAccess.getUserPassword(dir, userParameters).getPassword()); return new ModelAndView("authenticationForm", model); } JsTreeFile resource = this.serverAccess.get(dir, userParameters, false, false); pathEncodingUtils.encodeDir(resource); model.put("resource", resource); List<JsTreeFile> files = this.serverAccess.getChildren(dir, userParameters); Comparator<JsTreeFile> comparator = JsTreeFile.comparators.get(sortField); if (comparator != null) { Collections.sort(files, comparator); } else { Collections.sort(files); } pathEncodingUtils.encodeDir(files); model.put("files", files); ListOrderedMap parentsEncPathes = pathEncodingUtils.getParentsEncPathes(resource); model.put("parentsEncPathes", parentsEncPathes); FormCommand command = new FormCommand(); model.put("command", command); final String view = getThumbnailMode(request) ? "fileTree_thumbnails" : "fileTree"; return new ModelAndView(view, model); }
From source file:org.esupportail.portlet.filemanager.portlet.PortletControllerAction.java
@RequestMapping(value = { "VIEW" }, params = { "action=createFolderWai" }) public ModelAndView createFolderWai(RenderRequest request, RenderResponse response, @RequestParam String dir) { ModelMap model = new ModelMap(); model.put("currentDir", dir); return new ModelAndView("view-portlet-create-wai", model); }
From source file:org.ngrinder.script.controller.FileEntryControllerTest.java
@SuppressWarnings("unchecked") @Test/*w ww.jav a 2 s . c o m*/ public void testUploadFiles() { ModelMap model = new ModelMap(); String path = "test-upload-path"; scriptController.addFolder(getTestUser(), "", path, model); String upFileName = "Uploaded"; MultipartFile upFile = new MockMultipartFile("Uploaded.py", "Uploaded.py", null, "#test content...".getBytes()); path = path + "/" + upFileName; scriptController.upload(getTestUser(), path, "Uploaded file desc.", upFile, model); model.clear(); scriptController.search(getTestUser(), "Uploaded", model); Collection<FileEntry> searchResult = (Collection<FileEntry>) model.get("files"); assertThat(searchResult.size(), is(1)); }
From source file:se.vgregion.portal.iframe.controller.CSViewControllerTest.java
@Test public void testShowView_AuthNoSiteUser() throws ReadOnlyException { PortletPreferences prefs = new MockPortletPreferences(); initPortletPreferences(prefs);/*from ww w. j a v a 2s .c om*/ prefs.setValue("auth", "true"); RenderRequest mockReq = new MockRenderRequest(PortletMode.VIEW); Map<String, String> userInfo = new HashMap<String, String>(); userInfo.put(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString(), "no-credential-user"); mockReq.setAttribute(PortletRequest.USER_INFO, userInfo); RenderResponse mockResp = new MockRenderResponse(); ModelMap model = new ModelMap(); String response = controller.showView(prefs, mockReq, mockResp, model); assertEquals("userCredentialForm", response); }
From source file:org.esupportail.dining.web.controllers.ViewController.java
@RequestMapping("/restaurant") public ModelAndView renderRestaurantView(@RequestParam(value = "id", required = true) int id) throws Exception { ModelMap model = new ModelMap(); User user = this.authenticator.getUser(); Restaurant restaurant = this.cache.getCachedDining(id); model.put("restaurant", restaurant); try {//from ww w. j av a 2s .c om ResultSet results = this.dc.executeQuery("SELECT * FROM FAVORITERESTAURANT WHERE USERNAME='" + StringEscapeUtils.escapeSql(user.getLogin()) + "' AND RESTAURANTID='" + id + "';"); if (results.next()) { model.put("isFavorite", true); } if (this.feed.isClosed(restaurant)) { model.put("restaurantClosed", true); } } catch (NullPointerException e) { /* * Useful is the user isn't logged * in */ } return new ModelAndView("restaurant", model); }
From source file:org.openmrs.web.controller.provider.ProviderFormControllerTest.java
private ModelMap createModelMap(ProviderAttributeType providerAttributeType) { ModelMap modelMap = new ModelMap(); modelMap.put("providerAttributeTypes", Arrays.asList(providerAttributeType)); return modelMap; }
From source file:org.openmrs.module.patientflags.web.FindFlaggedPatientsController.java
@RequestMapping(method = RequestMethod.GET, params = "tags") public ModelAndView processSubmit(@ModelAttribute("filter") Filter filter, BindingResult result, SessionStatus status) {//from w w w . j av a 2 s .c om if (result.hasErrors()) { return new ModelAndView("/module/patientflags/findFlaggedPatients"); } FlagService flagService = Context.getService(FlagService.class); // get the flags to test on List<Flag> flags = flagService.getFlagsByFilter(filter); // returns a map of flagged Patients and the respective flags Cohort flaggedPatients = flagService.getFlaggedPatients(flags); Cohort allPatients = Context.getPatientSetService().getAllPatients(); // create the model map ModelMap model = new ModelMap(); model.addAttribute("flaggedPatients", flaggedPatients.getMemberIds()); model.addAttribute("allPatients", allPatients); // clears the command object from the session status.setComplete(); // displays the query results return new ModelAndView("/module/patientflags/findFlaggedPatientsResults", model); }
From source file:au.org.ala.layers.web.TabulationService.java
public ModelAndView generateTabulation(List<Tabulation> tabulations, String func, String fid1, String fid2, String wkt) throws IOException { ModelMap m = new ModelMap(); Field field1 = fieldDao.getFieldById(fid1); Field field2 = fieldDao.getFieldById(fid2); String title = "Tabulation for \""; if (field1 != null) { title += field1.getName();//from w w w . j a v a 2 s. c o m } else { title += fid1; } title += "\" and \""; if (field2 != null) { title += field2.getName(); } else { title += fid2; } if (func.equals("area")) { title += "\"(sq km)"; } else { title += "\""; } m.addAttribute("title", title); String[][] grid = tabulationGridGenerator(tabulations, fid1, fid2, wkt, func); double[] sumOfColumns = func.equals("species") ? speciesTotals(tabulations, true) : tabulationSumOfColumnsGenerator(grid, func); double[] sumOfRows = func.equals("species") ? speciesTotals(tabulations, false) : tabulationSumOfRowsGenerator(grid, func); double[][] gridRowPercentage = tabulationGridRowPercentageGenerator(grid, sumOfColumns, func); double[][] gridColumnPercentage = tabulationGridColumnPercentageGenerator(grid, sumOfRows, func); double[][] gridTotalPercentage = tabulationGridTotalPercentageGenerator(grid, sumOfColumns, func); double[] sumOfRowsGridPercentage = tabulationSumOfRowsGridPercentageGenerator(grid, gridRowPercentage, gridColumnPercentage, gridTotalPercentage, sumOfColumns, func); double[] sumOfColumnsGridPercentage = tabulationSumOfColumnsGridPercentageGenerator(grid, gridRowPercentage, gridColumnPercentage, gridTotalPercentage, sumOfColumns, func); double Total = 0.0; for (int j = 1; j < grid[0].length; j++) { Total += sumOfRows[j - 1]; } double TotalPercentage = 0.0; for (int j = 1; j < grid[0].length; j++) { TotalPercentage += sumOfRowsGridPercentage[j - 1]; } double[] AveragePercentageOverRows = new double[grid[0].length - 1]; for (int j = 1; j < grid[0].length; j++) { double NumOfNonzeroRows = 0.0; for (int k = 1; k < grid.length; k++) { if (grid[k][j] != null) { NumOfNonzeroRows = NumOfNonzeroRows + 1; } } if (NumOfNonzeroRows != 0.0) { AveragePercentageOverRows[j - 1] = sumOfRowsGridPercentage[j - 1] / NumOfNonzeroRows; } } double[] AveragePercentageOverColumns = new double[grid.length - 1]; for (int i = 1; i < grid.length; i++) { double NumOfNonzeroColumns = 0.0; for (int k = 1; k < grid[0].length; k++) { if (grid[i][k] != null) { NumOfNonzeroColumns = NumOfNonzeroColumns + 1; } } if (NumOfNonzeroColumns != 0.0) { AveragePercentageOverColumns[i - 1] = sumOfColumnsGridPercentage[i - 1] / NumOfNonzeroColumns; } } if (func.equals("area") || func.equals("occurrences") || func.equals("species")) { m.addAttribute("grid", grid); m.addAttribute("sumofcolumns", sumOfColumns); m.addAttribute("sumofrows", sumOfRows); if (!func.equals("species")) m.addAttribute("total", Total); } else if (func.equals("arearow") || func.equals("occurrencesrow") || func.equals("speciesrow")) { m.addAttribute("grid", grid); m.addAttribute("sumofcolumns", sumOfColumns); m.addAttribute("sumofrows", sumOfRows); m.addAttribute("gridpercentage", gridRowPercentage); m.addAttribute("sumofrowsgridpercentage", sumOfRowsGridPercentage); m.addAttribute("sumofcolumnsgridpercentage", sumOfColumnsGridPercentage); m.addAttribute("AveragePercentageOverRows", AveragePercentageOverRows); } else if (func.equals("areacolumn") || func.equals("occurrencescolumn") || func.equals("speciescolumn")) { m.addAttribute("grid", grid); m.addAttribute("sumofcolumns", sumOfColumns); m.addAttribute("sumofrows", sumOfRows); m.addAttribute("gridpercentage", gridColumnPercentage); m.addAttribute("sumofrowsgridpercentage", sumOfRowsGridPercentage); m.addAttribute("sumofcolumnsgridpercentage", sumOfColumnsGridPercentage); m.addAttribute("AveragePercentageOverColumns", AveragePercentageOverColumns); } else if (func.equals("areatotal") || func.equals("occurrencestotal") || func.equals("speciestotal")) { m.addAttribute("grid", grid); m.addAttribute("sumofcolumns", sumOfColumns); m.addAttribute("sumofrows", sumOfRows); m.addAttribute("gridpercentage", gridTotalPercentage); m.addAttribute("sumofrowsgridpercentage", sumOfRowsGridPercentage); m.addAttribute("sumofcolumnsgridpercentage", sumOfColumnsGridPercentage); m.addAttribute("totalpercentage", TotalPercentage); } if (func.equals("area")) { m.addAttribute("tabulationDescription", "Area (square kilometres)"); m.addAttribute("tabulationRowMargin", "Total area"); m.addAttribute("tabulationColumnMargin", "Total area"); m.addAttribute("id", 1); } else if (func.equals("occurrences")) { m.addAttribute("tabulationDescription", "Number of occurrences"); m.addAttribute("tabulationRowMargin", "Total occurrences"); m.addAttribute("tabulationColumnMargin", "Total occurrences"); m.addAttribute("id", 2); } else if (func.equals("species")) { m.addAttribute("tabulationDescription", "Number of species"); m.addAttribute("tabulationRowMargin", "Total species"); m.addAttribute("tabulationColumnMargin", "Total species"); m.addAttribute("id", 2); } else if (func.equals("arearow")) { m.addAttribute("tabulationDescription", "Area: Row%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Average"); m.addAttribute("id", 4); } else if (func.equals("occurrencesrow")) { m.addAttribute("tabulationDescription", "Occurrences: Row%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Average"); m.addAttribute("id", 4); } else if (func.equals("speciesrow")) { m.addAttribute("tabulationDescription", "Species: Row%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Average"); m.addAttribute("id", 4); } else if (func.equals("areacolumn")) { m.addAttribute("tabulationDescription", "Area: Column%"); m.addAttribute("tabulationRowMargin", "Average"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 3); } else if (func.equals("occurrencescolumn")) { m.addAttribute("tabulationDescription", "Occurrences: Column%"); m.addAttribute("tabulationRowMargin", "Average"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 3); } else if (func.equals("speciescolumn")) { m.addAttribute("tabulationDescription", "Species: Column%"); m.addAttribute("tabulationRowMargin", "Average"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 3); } else if (func.equals("areatotal")) { m.addAttribute("tabulationDescription", "Area: Total%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 5); } else if (func.equals("occurrencestotal")) { m.addAttribute("tabulationDescription", "Occurrences: Total%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 5); } else if (func.equals("speciestotal")) { m.addAttribute("tabulationDescription", "Species: Total%"); m.addAttribute("tabulationRowMargin", "Total"); m.addAttribute("tabulationColumnMargin", "Total"); m.addAttribute("id", 5); } return new ModelAndView("tabulations/tabulation", m); }
From source file:org.esupportail.twitter.web.TwitterController.java
@RequestMapping("EDIT") public ModelAndView renderEditView(RenderRequest request, RenderResponse response) throws Exception { final PortletPreferences prefs = request.getPreferences(); ModelMap model = new ModelMap(); if (this.isOAuthEnabled()) { Token requestToken = service.getRequestToken(); String twitterAccessToken = requestToken.getToken(); String twitterAccessTokenSecret = requestToken.getSecret(); model.put("twitterAccessToken", twitterAccessToken); model.put("twitterAccessTokenSecret", twitterAccessTokenSecret); }//w w w.j a v a 2s . co m String currentTwitterUsername = prefs.getValue(PREF_TWITTER_USERNAME, DEFAULT_TWITTER_USERNAME); boolean connected = false; String twitterUserToken = prefs.getValue(PREF_TWITTER_USER_TOKEN, null); String twitterUserSecret = prefs.getValue(PREF_TWITTER_USER_SECRET, null); String twitterTweetsNumber = prefs.getValue(PREF_TWITTER_TWEETS_NUMBER, "-1"); if (twitterUserToken != null) { Twitter twitter = new TwitterTemplate(oAuthTwitterConfig.getConsumerKey(), oAuthTwitterConfig.getConsumerSecret(), twitterUserToken, twitterUserSecret); TwitterProfile twitterProfile = twitter.userOperations().getUserProfile(); currentTwitterUsername = twitterProfile.getName(); connected = true; } model.put("isOAuthEnabled", this.isOAuthEnabled()); model.put("currentTwitterUsername", currentTwitterUsername); model.put("connectedMode", connected); model.put("twitterTweetsNumber", twitterTweetsNumber); return new ModelAndView("edit", model); }