001 /* 002 * Copyright 2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 1.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl1.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package edu.sampleu.kew.krad.controller; 017 018 import javax.servlet.http.HttpServletRequest; 019 import javax.servlet.http.HttpServletResponse; 020 021 import org.kuali.rice.kew.service.KEWServiceLocator; 022 import org.kuali.rice.kew.stats.service.StatsService; 023 import org.kuali.rice.krad.web.controller.UifControllerBase; 024 import org.kuali.rice.krad.web.form.UifFormBase; 025 import org.springframework.stereotype.Controller; 026 import org.springframework.validation.BindingResult; 027 import org.springframework.web.bind.annotation.ModelAttribute; 028 import org.springframework.web.bind.annotation.RequestMapping; 029 import org.springframework.web.servlet.ModelAndView; 030 031 import edu.sampleu.kew.krad.form.StatsForm; 032 033 /** 034 * This is a description of what this class does - Venkat don't forget to fill this in. 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 * 038 */ 039 @Controller 040 @RequestMapping(value = "/stats") 041 public class StatsController extends UifControllerBase { 042 043 /** 044 * This overridden method ... 045 * 046 * @see org.kuali.rice.krad.web.spring.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest) 047 */ 048 @Override 049 protected UifFormBase createInitialForm(HttpServletRequest request) { 050 return new StatsForm(); 051 } 052 053 @Override 054 @RequestMapping(params = "methodToCall=start") 055 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 056 HttpServletRequest request, HttpServletResponse response) { 057 058 StatsForm statForm = (StatsForm) form; 059 060 try{ 061 statForm.determineBeginDate(); 062 statForm.determineEndDate(); 063 064 StatsService statsService = this.getStatsService(); 065 statsService.NumUsersReport(statForm.getStats()); 066 statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate()); 067 statsService.NumActiveItemsReport(statForm.getStats()); 068 statsService.NumberOfDocTypesReport(statForm.getStats()); 069 statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats()); 070 071 }catch (Exception e) { 072 throw new RuntimeException(e); 073 } 074 075 return super.start(statForm, result, request, response); 076 } 077 078 public StatsService getStatsService() { 079 return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE); 080 } 081 }