View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * This is a description of what this class does - Venkat don't forget to fill this in. 
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
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  }