/src/main/java/com/google/ie/web/controller/IdeaCategoryController.java

http://thoughtsite.googlecode.com/ · Java · 72 lines · 36 code · 11 blank · 25 comment · 1 complexity · 71d64c409ca749b93a15370cbf8518f1 MD5 · raw file

  1. /* Copyright 2010 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS.
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License
  14. */
  15. package com.google.ie.web.controller;
  16. import com.google.ie.business.domain.IdeaCategory;
  17. import com.google.ie.business.service.IdeaCategoryService;
  18. import com.google.ie.dto.ViewStatus;
  19. import org.apache.log4j.Logger;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Controller;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import java.util.List;
  24. import java.util.Map;
  25. /**
  26. * A controller that handles requests for idea categories.
  27. *
  28. * @author Sachneet
  29. *
  30. */
  31. @Controller
  32. public class IdeaCategoryController {
  33. private static Logger log = Logger.getLogger(IdeaCategoryController.class);
  34. @Autowired
  35. private IdeaCategoryService ideaCategoryService;
  36. public IdeaCategoryController() {
  37. }
  38. /**
  39. * Handles the request for getting all categories.
  40. *
  41. * @return View name.
  42. */
  43. @RequestMapping("/ideas/categories.json")
  44. public void getAllCategories(Map<String, Object> model) {
  45. List<IdeaCategory> listOfCategories =
  46. ideaCategoryService.getAllIdeaCategories();
  47. log
  48. .debug("Number of categories fetched are: " + listOfCategories != null ? listOfCategories
  49. .size()
  50. : WebConstants.ZERO);
  51. ViewStatus status = ViewStatus.createTheViewStatus(listOfCategories,
  52. WebConstants.CATEGORIES, null);
  53. model.put(WebConstants.VIEW_STATUS, status);
  54. }
  55. public void setIdeaCategoryService(IdeaCategoryService ideaCategoryService) {
  56. this.ideaCategoryService = ideaCategoryService;
  57. }
  58. public IdeaCategoryService getIdeaCategoryService() {
  59. return ideaCategoryService;
  60. }
  61. }