1
2
3
4
5
6
7
8
9
10
11 package psiprobe.beans.stats.providers;
12
13 import jakarta.servlet.http.HttpServletRequest;
14
15 import java.text.MessageFormat;
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.jfree.data.xy.DefaultTableXYDataset;
20 import org.jfree.data.xy.XYDataItem;
21 import org.springframework.web.bind.ServletRequestBindingException;
22 import org.springframework.web.bind.ServletRequestUtils;
23
24 import psiprobe.model.stats.StatsCollection;
25
26
27
28
29 public class StandardSeriesProvider extends AbstractSeriesProvider {
30
31
32 private List<String> statNames = new ArrayList<>(2);
33
34
35
36
37
38
39 public List<String> getStatNames() {
40 return statNames;
41 }
42
43
44
45
46
47
48 public void setStatNames(List<String> statNames) {
49 this.statNames = statNames;
50 }
51
52 @Override
53 public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
54 HttpServletRequest request) {
55
56 String seriesParam = null;
57 try {
58 seriesParam = ServletRequestUtils.getStringParameter(request, "sp");
59 } catch (ServletRequestBindingException e) {
60 logger.error("", e);
61 }
62 for (int i = 0; i < statNames.size(); i++) {
63 String statName = statNames.get(i);
64 if (seriesParam != null) {
65 statName = MessageFormat.format(statName, seriesParam);
66 }
67 List<XYDataItem> stats = statsCollection.getStats(statName);
68 if (stats != null) {
69 String series =
70 ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i);
71 dataset.addSeries(toSeries(series, stats));
72 }
73 }
74 }
75 }