View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.beans.stats.providers;
12  
13  import java.util.List;
14  
15  import javax.servlet.http.HttpServletRequest;
16  
17  import org.jfree.data.xy.DefaultTableXYDataset;
18  import org.jfree.data.xy.XYDataItem;
19  import org.springframework.web.bind.ServletRequestBindingException;
20  import org.springframework.web.bind.ServletRequestUtils;
21  
22  import psiprobe.model.stats.StatsCollection;
23  
24  /**
25   * The Class ConnectorSeriesProvider.
26   */
27  public class ConnectorSeriesProvider extends AbstractSeriesProvider {
28  
29    @Override
30    public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
31        HttpServletRequest request) {
32  
33      try {
34        // get Connector name from the request
35        String connectorName = ServletRequestUtils.getStringParameter(request, "cn");
36  
37        // type of statistic to be displayed
38        String statType = ServletRequestUtils.getStringParameter(request, "st");
39  
40        if (connectorName != null && statType != null) {
41          List<XYDataItem> stats =
42              statsCollection.getStats("stat.connector." + connectorName + "." + statType);
43          if (stats != null) {
44            // Series legend
45            String series1Legend = ServletRequestUtils.getStringParameter(request, "sl", "");
46            dataset.addSeries(toSeries(series1Legend, stats));
47          }
48        }
49      } catch (ServletRequestBindingException e) {
50        logger.error("", e);
51      }
52    }
53  }