asgoyal

order controller

Jun 28th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14. package org.openmrs.web.controller.encounter;
  15.  
  16. import java.util.ArrayList;
  17. import java.util.Collections;
  18. import java.util.List;
  19.  
  20. import org.openmrs.Location;
  21. import org.openmrs.LocationTag;
  22. import org.openmrs.api.context.Context;
  23. import org.openmrs.propertyeditor.LocationTagEditor;
  24. import org.openmrs.util.MetadataComparator;
  25. import org.openmrs.validator.LocationTagValidator;
  26. import org.openmrs.web.WebConstants;
  27. import org.springframework.stereotype.Controller;
  28. import org.springframework.ui.ModelMap;
  29. import org.springframework.util.StringUtils;
  30. import org.springframework.validation.BindingResult;
  31. import org.springframework.web.bind.WebDataBinder;
  32. import org.springframework.web.bind.annotation.InitBinder;
  33. import org.springframework.web.bind.annotation.ModelAttribute;
  34. import org.springframework.web.bind.annotation.RequestMapping;
  35. import org.springframework.web.bind.annotation.RequestMethod;
  36. import org.springframework.web.bind.annotation.RequestParam;
  37. import org.springframework.web.bind.annotation.SessionAttributes;
  38. import org.springframework.web.bind.support.SessionStatus;
  39. import org.springframework.web.context.request.WebRequest;
  40.  
  41. /**
  42. * Controller for managing {@link Orders}s
  43. */
  44.  
  45. @Controller
  46. public class OrderController {
  47.  
  48. /**
  49. * Set up automatic primitive-to-class mappings
  50. *
  51. * @param wdb
  52. */
  53. @InitBinder
  54. public void initBinder(WebDataBinder wdb) {
  55. wdb.registerCustomEditor(Order.class, new OrderEditor());
  56. }
  57.  
  58. /**
  59. * List all Orders
  60. */
  61. @RequestMapping("http://127.0.0.1:8080/openmrs/order")
  62. public void list(ModelMap model) {
  63. List<Order> list = new ArrayList<Order>(Context.getOrderService().getOrderables());
  64. Collections.sort(list, new MetadataComparator(Context.getLocale()));
  65. model.addAttribute("orders", list);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment