View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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 org.kuali.rice.kew.stats.web;
17  
18  import java.util.Map;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import org.apache.struts.action.ActionForm;
24  import org.apache.struts.action.ActionForward;
25  import org.apache.struts.action.ActionMapping;
26  import org.kuali.rice.kew.service.KEWServiceLocator;
27  import org.kuali.rice.kew.stats.Stats;
28  import org.kuali.rice.kew.stats.service.StatsService;
29  import org.kuali.rice.kew.web.KewKualiAction;
30  
31  
32  /**
33   * A Struts Action for compiling and displaying statistics about the KEW application.
34   *
35   * @see Stats
36   * @see StatsService
37   *
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  public class StatsAction extends KewKualiAction {
41  
42      @Override
43      public ActionForward execute(ActionMapping mapping, ActionForm form,
44              HttpServletRequest request, HttpServletResponse response)
45              throws Exception {
46          initForm(mapping, request, form);
47          return super.execute(mapping, form, request, response);
48      }
49  
50      public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
51  
52              StatsForm statForm = (StatsForm) form;
53  
54              statForm.determineBeginDate();
55              statForm.determineEndDate();
56  
57              StatsService statsService = this.getStatsService();
58              statsService.NumUsersReport(statForm.getStats());
59              statsService.DocumentsRoutedReport(statForm.getStats(), statForm.getBeginningDate(), statForm.getEndingDate());
60              statsService.NumActiveItemsReport(statForm.getStats());
61              statsService.NumberOfDocTypesReport(statForm.getStats());
62              statsService.NumInitiatedDocsByDocTypeReport(statForm.getStats());
63  
64              return mapping.findForward("basic");
65  
66      }
67  
68      public void initForm(ActionMapping mapping, HttpServletRequest request, ActionForm form) {
69          StatsForm statForm = (StatsForm) form;
70          Map dropDownMap = statForm.makePerUnitOfTimeDropDownMap();
71          request.setAttribute("timeUnitDropDown", dropDownMap);
72          statForm.validateDates();
73      }
74  
75      public StatsService getStatsService() {
76          return (StatsService) KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE);
77      }
78  
79  }