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 org.kuali.rice.kew.stats.web; 017 018 import java.util.Map; 019 020 import javax.servlet.http.HttpServletRequest; 021 import javax.servlet.http.HttpServletResponse; 022 023 import org.apache.struts.action.ActionForm; 024 import org.apache.struts.action.ActionForward; 025 import org.apache.struts.action.ActionMapping; 026 import org.kuali.rice.kew.service.KEWServiceLocator; 027 import org.kuali.rice.kew.stats.Stats; 028 import org.kuali.rice.kew.stats.service.StatsService; 029 import org.kuali.rice.kew.web.KewKualiAction; 030 031 032 /** 033 * A Struts Action for compiling and displaying statistics about the KEW application. 034 * 035 * @see Stats 036 * @see StatsService 037 * 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 public class StatsAction extends KewKualiAction { 041 042 @Override 043 public ActionForward execute(ActionMapping mapping, ActionForm form, 044 HttpServletRequest request, HttpServletResponse response) 045 throws Exception { 046 initForm(mapping, request, form); 047 return super.execute(mapping, form, request, response); 048 } 049 050 public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 051 052 StatsForm statForm = (StatsForm) form; 053 054 statForm.determineBeginDate(); 055 statForm.determineEndDate(); 056 057 StatsService statsService = this.getStatsService(); 058 statsService.NumUsersReport(statForm.getStats()); 059 statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate()); 060 statsService.NumActiveItemsReport(statForm.getStats()); 061 statsService.NumberOfDocTypesReport(statForm.getStats()); 062 statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats()); 063 064 return mapping.findForward("basic"); 065 066 } 067 068 public void initForm(ActionMapping mapping, HttpServletRequest request, ActionForm form) { 069 StatsForm statForm = (StatsForm) form; 070 Map dropDownMap = statForm.makePerUnitOfTimeDropDownMap(); 071 request.setAttribute("timeUnitDropDown", dropDownMap); 072 statForm.validateDates(); 073 } 074 075 public StatsService getStatsService() { 076 return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE); 077 } 078 079 }