001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
045 */
046 @Override
047 protected StatsForm createInitialForm(HttpServletRequest request) {
048 return new StatsForm();
049 }
050
051 @Override
052 @RequestMapping(params = "methodToCall=start")
053 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
054 HttpServletRequest request, HttpServletResponse response) {
055
056 StatsForm statForm = (StatsForm) form;
057
058 try{
059 statForm.determineBeginDate();
060 statForm.determineEndDate();
061
062 StatsService statsService = this.getStatsService();
063 statsService.NumUsersReport(statForm.getStats());
064 statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate());
065 statsService.NumActiveItemsReport(statForm.getStats());
066 statsService.NumberOfDocTypesReport(statForm.getStats());
067 statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats());
068
069 }catch (Exception e) {
070 throw new RuntimeException(e);
071 }
072
073 return super.start(statForm, result, request, response);
074 }
075
076 public StatsService getStatsService() {
077 return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE);
078 }
079 }