Coverage report

  %line %branch
net.sf.infrared.web.action.PerfDataLayerSummaryAction
0% 
0% 

 1  
 /*
 2  
  *
 3  
  * Copyright 2005 Tavant Technologies and Contributors
 4  
  * 
 5  
  * Licensed under the Apache License, Version 2.0 (the "License")
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  *
 18  
  *
 19  
  * Original Author:  kaushal.kumar (Tavant Technologies)
 20  
  * Contributor(s):   prashant.nair;
 21  
  *
 22  
  */
 23  
 package net.sf.infrared.web.action;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.Set;
 27  
 
 28  
 import javax.servlet.http.HttpServletRequest;
 29  
 import javax.servlet.http.HttpServletResponse;
 30  
 import javax.servlet.http.HttpSession;
 31  
 
 32  
 import net.sf.infrared.base.model.AggregateExecutionTime;
 33  
 import net.sf.infrared.web.formbean.AggrExecTimeFormBean;
 34  
 import net.sf.infrared.web.formbean.SqlStatisticsFormBean;
 35  
 import net.sf.infrared.web.util.DataFetchUtil;
 36  
 import net.sf.infrared.web.util.PerformanceDataSnapshot;
 37  
 import net.sf.infrared.web.util.SqlStatistics;
 38  
 import net.sf.infrared.web.util.ViewUtil;
 39  
 import net.sf.infrared.web.util.WebConfig;
 40  
 
 41  
 import org.apache.commons.beanutils.BeanUtils;
 42  
 import org.apache.struts.action.Action;
 43  
 import org.apache.struts.action.ActionForm;
 44  
 import org.apache.struts.action.ActionForward;
 45  
 import org.apache.struts.action.ActionMapping;
 46  
 
 47  0
 public class PerfDataLayerSummaryAction extends Action {
 48  
     public ActionForward execute(ActionMapping mapping, ActionForm form,
 49  
                                     HttpServletRequest request, HttpServletResponse response) 
 50  
                                     throws Exception {
 51  0
         HttpSession session = request.getSession();
 52  0
         String apiType = request.getParameter("type");
 53  0
         String layerType = request.getParameter("layerType");
 54  0
         if(layerType == null){
 55  0
             layerType = (String)session.getAttribute("layerType");
 56  
         }
 57  
         else{
 58  0
             session.setAttribute("layerType", layerType);
 59  
         }
 60  0
         PerformanceDataSnapshot perfData = 
 61  
                                     (PerformanceDataSnapshot)session.getAttribute("perfData");
 62  
 
 63  0
         if (apiType != null) {
 64  0
             if (apiType.endsWith("SQL")) {
 65  0
                 perfData = (PerformanceDataSnapshot) session.getAttribute("perfData");
 66  0
                 SqlStatistics[] sqlStats = perfData.getSqlStatisticsForLayer(apiType, layerType);
 67  0
                 ArrayList sqlStatisticsByExec = new ArrayList();
 68  0
                 int n = WebConfig.getNumOfSqlQueries();
 69  0
                 SqlStatistics[] topNQueriesByExecution = 
 70  
                                         ViewUtil.getTopNQueriesByExecutionTime(sqlStats, n);
 71  
 
 72  0
                 for (int i = 0; i < topNQueriesByExecution.length; i++) {
 73  0
                     SqlStatisticsFormBean formBean = new SqlStatisticsFormBean();
 74  0
                     BeanUtils.copyProperties(formBean, topNQueriesByExecution[i]);
 75  0
                     sqlStatisticsByExec.add(formBean);
 76  
                 }
 77  
 
 78  0
                 ArrayList sqlStatisticsByCount = new ArrayList();
 79  0
                 SqlStatistics[] topNQueriesByCount = ViewUtil.getTopNQueriesByCount(sqlStats,n);
 80  0
                 for (int i = 0; i < topNQueriesByCount.length; i++) {
 81  0
                     SqlStatisticsFormBean formBean = new SqlStatisticsFormBean();
 82  0
                     BeanUtils.copyProperties(formBean, topNQueriesByCount[i]);
 83  0
                     sqlStatisticsByCount.add(formBean);
 84  
                 }
 85  
                 	
 86  0
                 request.setAttribute("apiType", apiType);
 87  0
                 request.setAttribute("sqlStatisticsByExec", sqlStatisticsByExec);
 88  0
                 request.setAttribute("sqlStatisticsByCount", sqlStatisticsByCount);
 89  
                 
 90  0
                 return (mapping.findForward("sql"));
 91  
             }
 92  
             else{
 93  0
                 AggregateExecutionTime[] summary = 
 94  
                                  ViewUtil.getSummaryForALayer(request, session, apiType, layerType);
 95  0
                 ArrayList aggrApiList = new ArrayList();
 96  
 
 97  0
                 for (int i = 0; i < summary.length; i++) {
 98  0
                     AggrExecTimeFormBean formBean = new AggrExecTimeFormBean();
 99  0
                     BeanUtils.copyProperties(formBean, summary[i]);
 100  0
                     aggrApiList.add(formBean);
 101  
                 }
 102  
 
 103  0
                 String exclusiveInclusiveMode = request.getParameter("exclusiveInclusiveMode");
 104  0
                 if (exclusiveInclusiveMode != null){
 105  0
                     session.setAttribute("exclusiveInclusiveMode", exclusiveInclusiveMode);
 106  
                 }
 107  
                     
 108  0
                 request.setAttribute("summary", summary);
 109  0
                 request.setAttribute("aggrApiList", aggrApiList);
 110  0
                 request.setAttribute("apiType", apiType);
 111  
 
 112  0
                 return (mapping.findForward("continue"));        	
 113  
             }            
 114  
         }
 115  
         
 116  0
         return null;
 117  
 
 118  
     }
 119  
 
 120  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.