PageRenderTime 31ms CodeModel.GetById 25ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
16package com.google.ie.web.controller;
17
18import com.google.ie.business.domain.IdeaCategory;
19import com.google.ie.business.service.IdeaCategoryService;
20import com.google.ie.dto.ViewStatus;
21
22import org.apache.log4j.Logger;
23import org.springframework.beans.factory.annotation.Autowired;
24import org.springframework.stereotype.Controller;
25import org.springframework.web.bind.annotation.RequestMapping;
26
27import java.util.List;
28import java.util.Map;
29
30/**
31 * A controller that handles requests for idea categories.
32 * 
33 * @author Sachneet
34 * 
35 */
36@Controller
37public class IdeaCategoryController {
38    private static Logger log = Logger.getLogger(IdeaCategoryController.class);
39    @Autowired
40    private IdeaCategoryService ideaCategoryService;
41
42    public IdeaCategoryController() {
43    }
44
45    /**
46     * Handles the request for getting all categories.
47     * 
48     * @return View name.
49     */
50    @RequestMapping("/ideas/categories.json")
51    public void getAllCategories(Map<String, Object> model) {
52        List<IdeaCategory> listOfCategories =
53                        ideaCategoryService.getAllIdeaCategories();
54        log
55                        .debug("Number of categories fetched are:    " + listOfCategories != null ? listOfCategories
56                                        .size()
57                                        : WebConstants.ZERO);
58        ViewStatus status = ViewStatus.createTheViewStatus(listOfCategories,
59                        WebConstants.CATEGORIES, null);
60        model.put(WebConstants.VIEW_STATUS, status);
61    }
62
63    public void setIdeaCategoryService(IdeaCategoryService ideaCategoryService) {
64        this.ideaCategoryService = ideaCategoryService;
65    }
66
67    public IdeaCategoryService getIdeaCategoryService() {
68        return ideaCategoryService;
69    }
70
71}
72