PageRenderTime 214ms CodeModel.GetById 90ms app.highlight 3ms RepoModel.GetById 118ms app.codeStats 0ms

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

http://thoughtsite.googlecode.com/
Java | 65 lines | 26 code | 11 blank | 28 comment | 0 complexity | 19a573bd9db2686621e759d18cdca79a 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.Idea;
19import com.google.ie.business.service.IdeaService;
20
21import org.springframework.beans.factory.annotation.Autowired;
22import org.springframework.stereotype.Controller;
23import org.springframework.ui.Model;
24import org.springframework.web.bind.annotation.RequestMapping;
25
26import java.util.List;
27
28/**
29 * Controller for handling the data required for home page.
30 * 
31 * @author aksrivastava
32 * 
33 */
34@Controller
35public class HomeController {
36    @Autowired
37    private IdeaService ideaService;
38
39    public HomeController() {
40
41    }
42
43    /**
44     * Handles the request for serving home page.
45     * 
46     * @return View name.
47     */
48    @RequestMapping("/")
49    public String home(Model model) {
50        /* Retrieve the recent idea list and put it into the Model */
51        List<Idea> recentIdeas = ideaService.getRecentIdeas();
52        model.addAttribute(WebConstants.RECENT_IDEAS_MODEL_KEY, recentIdeas);
53        /* Retrieve the popular idea list and put it into the Model */
54        List<Idea> popularIdeas = ideaService.getPopularIdeas();
55        model.addAttribute(WebConstants.POPULAR_IDEAS_MODEL_KEY, popularIdeas);
56        /* Retrieve the recently picked idea list and put it into the Model */
57        List<Idea> recentlyPickedIdeas = ideaService.getRecentlyPickedIdeas();
58        model.addAttribute(WebConstants.RECENTLY_PICKED_IDEA_MODEL_KEY,
59                        recentlyPickedIdeas);
60
61        return "home";
62    }
63
64}
65