1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.kew.krad.controller;
17
18 import edu.sampleu.kew.krad.form.StatsForm;
19 import org.kuali.rice.kew.service.KEWServiceLocator;
20 import org.kuali.rice.kew.stats.service.StatsService;
21 import org.kuali.rice.krad.web.controller.UifControllerBase;
22 import org.kuali.rice.krad.web.form.UifFormBase;
23 import org.springframework.stereotype.Controller;
24 import org.springframework.validation.BindingResult;
25 import org.springframework.web.bind.annotation.ModelAttribute;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.servlet.ModelAndView;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31
32
33
34
35
36
37
38 @Controller
39 @RequestMapping(value = "/stats")
40 public class StatsController extends UifControllerBase {
41
42 @Override
43 protected Class<StatsForm> formType() {
44 return StatsForm.class;
45 }
46
47 @Override
48 @RequestMapping(params = "methodToCall=start")
49 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
50 HttpServletRequest request, HttpServletResponse response) {
51
52 StatsForm statForm = (StatsForm) form;
53
54 try{
55 statForm.determineBeginDate();
56 statForm.determineEndDate();
57
58 StatsService statsService = this.getStatsService();
59 statsService.NumUsersReport(statForm.getStats());
60 statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate());
61 statsService.NumActiveItemsReport(statForm.getStats());
62 statsService.NumberOfDocTypesReport(statForm.getStats());
63 statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats());
64
65 }catch (Exception e) {
66 throw new RuntimeException(e);
67 }
68
69 return super.start(statForm, result, request, response);
70 }
71
72 public StatsService getStatsService() {
73 return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE);
74 }
75 }