1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.mobility.alerts.controllers;
17
18 import java.util.List;
19
20 import javax.servlet.http.HttpServletRequest;
21
22 import org.kuali.mobility.alerts.entity.Alert;
23 import org.kuali.mobility.alerts.service.AlertsService;
24 import org.kuali.mobility.campus.service.CampusService;
25 import org.kuali.mobility.security.user.api.User;
26 import org.kuali.mobility.shared.Constants;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Controller;
29 import org.springframework.ui.Model;
30 import org.springframework.web.bind.annotation.RequestMapping;
31 import org.springframework.web.bind.annotation.RequestMethod;
32 import org.springframework.web.bind.annotation.ResponseBody;
33
34 import flexjson.JSONSerializer;
35
36 @Controller
37 @RequestMapping("/alerts")
38 public class AlertsController {
39
40 @Autowired
41 private AlertsService alertsService;
42
43 @Autowired
44 private CampusService campusService;
45
46 @RequestMapping(method = RequestMethod.GET)
47 public String getList(HttpServletRequest request, Model uiModel) {
48 User user = (User) request.getSession().getAttribute(Constants.KME_USER_KEY);
49 if (user.getViewCampus() != null) {
50 if (campusService.needToSelectDifferentCampusForTool("alerts", user.getViewCampus())) {
51 return "redirect:/campus?toolName=alerts";
52 }
53 }
54 return "alerts/list";
55 }
56
57 @Deprecated
58 @RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json")
59 @ResponseBody
60 public String getListJson(HttpServletRequest request, Model uiModel) {
61 User user = (User) request.getSession().getAttribute(Constants.KME_USER_KEY);
62 List<Alert> alerts = alertsService.findAlertsByCampus(user.getViewCampus());
63
64 return new JSONSerializer().exclude("*.class").deepSerialize(alerts);
65 }
66
67 public AlertsService getAlertsService() {
68 return alertsService;
69 }
70
71 public void setAlertsService(AlertsService alertsService) {
72 this.alertsService = alertsService;
73 }
74
75 public CampusService getCampusService() {
76 return campusService;
77 }
78
79 public void setCampusService(CampusService campusService) {
80 this.campusService = campusService;
81 }
82 }