List of usage examples for org.springframework.ui Model asMap
Map<String, Object> asMap();
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(value = "/{id}/updateManagerComment", method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER')") public String updateManagerComment(@PathVariable("id") Long id, @RequestParam String comment, Model uiModel) { PosteCandidature postecandidature = PosteCandidature.findPosteCandidature(id); postecandidature.setManagerComment4Members(comment); postecandidature.merge();// ww w . j a v a 2 s .co m uiModel.asMap().clear(); return "redirect:/postecandidatures/" + id; }
From source file:org.openmrs.module.metadatasharing.web.controller.ImportController.java
/** * An AJAX request where we perform the actual package download process. *///from w w w . j av a2 s . c o m @RequestMapping(value = JSON_PERFORM_DOWNLOAD_PATH, method = RequestMethod.GET) public ModelAndView jsonPerformDownload(@ModelAttribute(DOWNLOADER) Downloader downloader, HttpSession session, Model model) throws IOException { PackageImporter metadataImporter = MetadataSharing.getInstance().newPackageImporter(); ByteArrayInputStream in = null; try { in = new ByteArrayInputStream(downloader.downloadAsByteArray()); } catch (Exception e) { model.addAttribute("object", SubscriptionStatus.FATAL_ERROR); return new ModelAndView(jsonObjectView); } metadataImporter.loadSerializedPackageStream(in); session.setAttribute(ImportController.IMPORTER, metadataImporter); model.asMap().remove(DOWNLOADER); model.addAttribute("object", SubscriptionStatus.UPDATE_AVAILABLE); return new ModelAndView(jsonObjectView); }
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(value = "/{id}/addReporter", method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasPermission(#id, 'manageReporters')") public String addReporter(@PathVariable("id") Long id, @RequestParam Long userId, Model uiModel) { PosteCandidature postecandidature = PosteCandidature.findPosteCandidature(id); User user = User.findUser(userId);//from www . j a v a 2s .c o m postecandidature.getReporters().add(user); postecandidature.merge(); uiModel.asMap().clear(); return "redirect:/postecandidatures/" + id; }
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(value = "/{id}/delReporter", method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasPermission(#id, 'manageReporters')") public String delReporter(@PathVariable("id") Long id, @RequestParam Long userId, Model uiModel) { PosteCandidature postecandidature = PosteCandidature.findPosteCandidature(id); User user = User.findUser(userId);/*www. j av a2 s . co m*/ postecandidature.getReporters().remove(user); postecandidature.merge(); uiModel.asMap().clear(); return "redirect:/postecandidatures/" + id; }
From source file:net.triptech.metahive.web.DataSourceController.java
@RequestMapping(method = RequestMethod.POST) @PreAuthorize("hasAnyRole('ROLE_EDITOR','ROLE_ADMIN')") public String create(@Valid DataSourceForm dataSourceForm, BindingResult bindingResult, Model uiModel, HttpServletRequest request) {// w w w. j a v a 2 s.co m Person user = loadUser(request); if (user == null) { // A valid user is required FlashScope.appendMessage(getMessage("metahive_valid_user_required"), request); return "redirect:/definitions" + encodeUrlPathSegment(dataSourceForm.getDefinition().getId().toString(), request); } if (bindingResult.hasErrors()) { uiModel.addAttribute("dataSource", dataSourceForm); FlashScope.appendMessage(getMessage("metahive_object_validation", DataSource.class), request); return "datasources/create"; } DataSource dataSource = dataSourceForm.newDataSource(user); Definition definition = Definition.findDefinition(dataSource.getDefinition().getId()); Organisation organisation = Organisation.findOrganisation(dataSource.getOrganisation().getId()); uiModel.asMap().clear(); definition.addDataSource(dataSource); organisation.addDataSource(dataSource); dataSource.persist(); dataSource.flush(); Comment comment = dataSourceForm.newComment(CommentType.CREATE, dataSource, user); comment.persist(); FlashScope.appendMessage(getMessage("metahive_create_complete", DataSource.class), request); return "redirect:/definitions/" + encodeUrlPathSegment(definition.getId().toString(), request); }
From source file:net.triptech.metahive.web.RecordController.java
@RequestMapping(value = "/keyvalue/{id}", method = RequestMethod.POST) @PreAuthorize("hasRole('ROLE_ADMIN')") public @ResponseBody String overrideKeyValue(@PathVariable("id") Long id, KeyValueForm kvForm, Model uiModel, HttpServletRequest request) {/*from w w w . ja v a 2 s . c o m*/ Person user = loadUser(request); if (user == null) { // A valid user is required return getMessage("metahive_valid_user_required"); } List<KeyValue> updatedValues = KeyValue.updateRelevantKeyValues(id, kvForm, user); // Submit a recalculation JMS request for each updated key value for (KeyValue kv : updatedValues) { JmsRecalculateRequest req = new JmsRecalculateRequest(kv); keyValueGenerationTemplate.convertAndSend(req); } uiModel.asMap().clear(); return getMessage("metahive_record_keyvaluedetail_success"); }
From source file:net.triptech.metahive.web.ContributeController.java
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @PreAuthorize("hasRole('ROLE_ADMIN','ROLE_EDITOR')") public String delete(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) { Submission submission = Submission.findSubmission(id); List<JmsRecalculateRequest> toProcess = new ArrayList<JmsRecalculateRequest>(); if (submission != null) { for (SubmittedField submittedField : submission.getSubmittedFields()) { // Build a list of JMS requests to process following the delete JmsRecalculateRequest req = new JmsRecalculateRequest(); req.setPrimaryRecordId(submittedField.getPrimaryRecordId()); req.setSecondaryRecordId(submittedField.getSecondaryRecordId()); req.setTertiaryRecordId(submittedField.getTertiaryRecordId()); req.setDefinitionId(submittedField.getDefinition().getId()); toProcess.add(req);/*w w w .j a v a 2 s. co m*/ } submission.remove(); } for (JmsRecalculateRequest req : toProcess) { keyValueGenerationTemplate.convertAndSend(req); } uiModel.asMap().clear(); FlashScope.appendMessage(getMessage("metahive_delete_complete", Submission.class), request); return "redirect:/submissions"; }
From source file:org.kew.rmf.matchconf.web.CustomConfigController.java
@RequestMapping(value = "/{configType}_configs/{configName}", method = RequestMethod.DELETE, produces = "text/html") public String delete(@PathVariable String configType, @PathVariable("configName") String configName, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception { Configuration configuration = Configuration.findConfigurationsByNameEquals(configName).getSingleResult(); try {/*from w w w .jav a2 s . c o m*/ for (Transformer t : configuration.getTransformers()) t.removeOrphanedWiredTransformers(); // this is expensive and should go soon configuration.remove(); } catch (JpaSystemException e) { // assuming a possibly still exotically ocurring legacy error: a wire // of a *different* config uses this matcher, hence it would have a // foreign key into the void and complains so the matcher can't be // deleted and this config neither.. configuration.fixMatchersForAlienWire(); configuration.getWiring().clear(); configuration.merge(); configuration.removeTransformers(); configuration = Configuration.findConfigurationsByNameEquals(configName).getSingleResult(); configuration.remove(); } uiModel.asMap().clear(); uiModel.addAttribute("page", (page == null) ? "1" : page.toString()); uiModel.addAttribute("size", (size == null) ? "10" : size.toString()); return String.format("redirect:/%s_configs", configType); }
From source file:org.openmrs.module.metadatasharing.web.controller.PublishController.java
/** * Serializes to the client a subscription header of the latest package version with the given * group (group is extracted from the request URL) */// ww w. j a v a 2 s . c o m @RequestMapping(value = OLD_PACKAGE_PATH + "/*/latest", method = RequestMethod.GET) public ModelAndView getSubscriptionHeader(Model model, HttpServletRequest request, HttpServletResponse response) { try { Context.addProxyPrivilege(MetadataSharingConsts.MODULE_PRIVILEGE); String req = request.getRequestURI(); String group = PublishUtils.extractGroupFromPath(req, PREFIX); MetadataSharingService service = Context.getService(MetadataSharingService.class); ExportedPackage pack = service.getLatestPublishedPackageByGroup(group); if (pack != null) { SubscriptionHeader header = new SubscriptionHeader(); pack.setOpenmrsVersion(OpenmrsConstants.OPENMRS_VERSION); header.setPackageHeader(pack); header.setContentUri(PublishUtils .createRelativeURI("../" + pack.getGroupUuid() + "/" + pack.getVersion() + "/download")); model.addAttribute("header", header); return new ModelAndView(subscriptionHeaderView, model.asMap()); } else { throw new PackageNotFoundException(); } } finally { Context.removeProxyPrivilege(MetadataSharingConsts.MODULE_PRIVILEGE); } }