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 edu.sampleu.kew.krad.form.StatsForm;
019 import org.kuali.rice.kew.service.KEWServiceLocator;
020 import org.kuali.rice.kew.stats.service.StatsService;
021 import org.kuali.rice.krad.web.controller.UifControllerBase;
022 import org.kuali.rice.krad.web.form.UifFormBase;
023 import org.springframework.stereotype.Controller;
024 import org.springframework.validation.BindingResult;
025 import org.springframework.web.bind.annotation.ModelAttribute;
026 import org.springframework.web.bind.annotation.RequestMapping;
027 import org.springframework.web.servlet.ModelAndView;
028
029 import javax.servlet.http.HttpServletRequest;
030 import javax.servlet.http.HttpServletResponse;
031
032 /**
033 * This is a description of what this class does - Venkat don't forget to fill this in.
034 *
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 *
037 */
038 @Controller
039 @RequestMapping(value = "/stats")
040 public class StatsController extends UifControllerBase {
041
042 @Override
043 protected Class<StatsForm> formType() {
044 return StatsForm.class;
045 }
046
047 @Override
048 @RequestMapping(params = "methodToCall=start")
049 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
050 HttpServletRequest request, HttpServletResponse response) {
051
052 StatsForm statForm = (StatsForm) form;
053
054 try{
055 statForm.determineBeginDate();
056 statForm.determineEndDate();
057
058 StatsService statsService = this.getStatsService();
059 statsService.NumUsersReport(statForm.getStats());
060 statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate());
061 statsService.NumActiveItemsReport(statForm.getStats());
062 statsService.NumberOfDocTypesReport(statForm.getStats());
063 statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats());
064
065 }catch (Exception e) {
066 throw new RuntimeException(e);
067 }
068
069 return super.start(statForm, result, request, response);
070 }
071
072 public StatsService getStatsService() {
073 return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE);
074 }
075 }