annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java @ 5449:504a62887217

Datacage: Compile XPath expressions and reuse them. With the introduction of filters in dc:elements XPath expressions are evalutated very often so compiling them should reduce the overhead significantly.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 27 Mar 2013 10:59:55 +0100
parents 2fe120e1e4df
children
rev   line source
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.text.DateFormat;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.text.ParseException;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.util.ArrayList;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.util.Collections;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import java.util.Date;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.List;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import java.util.Locale;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.Logger;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.hibernate.Session;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.ChartFactory;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.jfree.chart.JFreeChart;
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
16 import org.jfree.chart.plot.Marker;
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.jfree.chart.plot.PlotOrientation;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.jfree.chart.plot.XYPlot;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.jfree.data.xy.XYSeries;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.jfree.data.xy.XYSeriesCollection;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import org.w3c.dom.Document;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Element;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.NodeList;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.CallMeta;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.artifacts.GlobalContext;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.artifacts.model.DischargeTables;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.artifacts.model.GaugesFactory;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import de.intevation.flys.artifacts.resources.Resources;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import de.intevation.flys.backend.SessionHolder;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.flys.model.DischargeTable;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.model.Gauge;
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
33 import de.intevation.flys.model.MainValue;
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 import de.intevation.flys.model.TimeInterval;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
5342
7b119fa1e29f Doc and vim-magiv.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4230
diff changeset
37 /** Generate Discharge Table chart. */
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public class DischargeTablesOverview extends AbstractChartService {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 private static final Logger log = Logger
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 .getLogger(DischargeTablesOverview.class);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 private static final long serialVersionUID = 1L;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public static final String I18N_CHART_TITLE = "gauge.discharge.service.chart.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public static final String DEFAULT_CHART_TITLE = "Pegel: XXX";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 public static final String I18N_CHART_X_AXIS_TITLE = "gauge.discharge.service.chart.x.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public static final String DEFAULT_X_AXIS_TITLE = "Q [m^3/s]";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 public static final String I18N_CHART_Y_AXIS_TITLE = "gauge.discharge.service.chart.y.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public static final String DEFAULT_Y_AXIS_TITLE = "W [cm]";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 public static final String I18N_CHART_SERIES_TITLE = "gauge.discharge.service.chart.series.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public static final String DEFAULT_CHART_SERIES_TITLE = "Abflusskurve";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 public static final String I18N_CHART_SERIES_TITLE_MASTER = "gauge.discharge.service.chart.series.title.master";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public static final String DEFAULT_CHART_SERIES_TITLE_MASTER = "Aktuelle Abflusskurve";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 DateFormat.SHORT, Locale.GERMANY);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 private Session session;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 @Override
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 protected void init() {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 session = SessionHolder.acquire();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 @Override
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 protected void finish() {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 if (session != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 session.close();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 SessionHolder.release();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 protected JFreeChart createChart(Document data,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 GlobalContext globalContext, CallMeta callMeta) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 Gauge gauge = extractGauge(data);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 if (gauge == null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 log.warn("Could not determine Gauge from request!");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 log.info("create discharge chart for gauge '" + gauge.getName() + "'");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 TimeInterval timerange = extractTimeInterval(data);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 List<DischargeTable> dts = getDischargeTables(gauge, timerange);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 XYSeriesCollection dataset = new XYSeriesCollection();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 for (DischargeTable dt : dts) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 try {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 XYSeries series = createSeries(callMeta, dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 if (series != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 dataset.addSeries(series);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 catch (IllegalArgumentException iae) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 log.warn("unable to create discharge curve: "
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 + iae.getMessage());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 String title = Resources.format(callMeta, I18N_CHART_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 DEFAULT_CHART_TITLE, gauge.getName());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 String xAxis = Resources.getMsg(callMeta, I18N_CHART_X_AXIS_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 DEFAULT_X_AXIS_TITLE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 String yAxis = Resources.format(callMeta, I18N_CHART_Y_AXIS_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 DEFAULT_Y_AXIS_TITLE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 null, PlotOrientation.VERTICAL, true, true, false);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 chart.setBackgroundPaint(Color.white);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 XYPlot plot = (XYPlot) chart.getPlot();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 plot.setDataset(0, dataset);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 plot.setBackgroundPaint(Color.white);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 plot.setDomainGridlinePaint(Color.gray);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 plot.setRangeGridlinePaint(Color.gray);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 plot.setDomainGridlinesVisible(true);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 plot.setRangeGridlinesVisible(true);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
129 applyMainValueMarkers(
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
130 plot,
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
131 gauge,
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
132 callMeta);
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
133
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 return chart;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt)
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 throws IllegalArgumentException {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 double[][] xy = null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 if (dt.getKind() == DischargeTables.MASTER) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 xy = DischargeTables.loadDischargeTableValues(dt,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 DischargeTables.MASTER_SCALE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 else {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 xy = DischargeTables.loadDischargeTableValues(dt,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 DischargeTables.HISTORICAL_SCALE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 XYSeries series = new XYSeries(createSeriesTitle(callMeta, dt), false);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 for (int i = 0, n = xy[0].length; i < n; i++) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 series.add(xy[0][i], xy[1][i]);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 return series;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
159
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
160 /** Add domain markers to plot that indicate mainvalues. */
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
161 protected static void applyMainValueMarkers(
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
162 XYPlot plot,
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
163 Gauge gauge,
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
164 CallMeta meta
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
165 ) {
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
166 String river = gauge.getRiver().getName();
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
167 double km = gauge.getStation().doubleValue();
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
168
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
169 // Get Gauge s mainvalues.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
170 List<MainValue> mainValues = gauge.getMainValues();
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
171 for (MainValue mainValue : mainValues) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
172 if (mainValue.getMainValue().getType().getName().equals("Q")) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
173 // Its a Q main value.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
174 Marker m = FixingsKMChartService.createQSectorMarker(
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
175 mainValue.getValue().doubleValue(),
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
176 mainValue.getMainValue().getName());
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
177 plot.addDomainMarker(m);
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
178 }
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
179 else if (mainValue.getMainValue().getType().getName().equals("W")) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
180 // Its a W main value.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
181 Marker m = FixingsKMChartService.createQSectorMarker(
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
182 mainValue.getValue().doubleValue(),
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
183 mainValue.getMainValue().getName());
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
184 plot.addRangeMarker(m);
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
185 }
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
186 }
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
187 }
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
188
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt)
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 throws IllegalArgumentException {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 TimeInterval timeInterval = dt.getTimeInterval();
4227
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
192
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
193 if (timeInterval == null) {
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
194 return Resources.format(callMeta, DEFAULT_CHART_SERIES_TITLE);
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
195 }
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
196
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 Date start = timeInterval.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 Date end = timeInterval.getStopTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 if (start != null && end != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 return Resources.format(callMeta, I18N_CHART_SERIES_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 DEFAULT_CHART_SERIES_TITLE, start, end);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 else if (start != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 return Resources.format(callMeta, I18N_CHART_SERIES_TITLE_MASTER,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 DEFAULT_CHART_SERIES_TITLE, start);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 else {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 throw new IllegalArgumentException(
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 "Missing start date of DischargeTable " + dt.getId());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 protected Gauge extractGauge(Document data) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 NodeList gauges = data.getElementsByTagName("gauge");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 if (gauges.getLength() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 String name = ((Element) gauges.item(0)).getAttribute("name");
4217
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
219
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
220 try {
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
221 long officialNumber = Long.valueOf(name);
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
222 return Gauge.getGaugeByOfficialNumber(officialNumber);
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
223 }
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
224 catch (NumberFormatException nfe) {
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
225 // it seems, that the client uses the name of the gauge instead
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
226 // of its official number
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
227 }
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
228
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229 if (name != null && name.length() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 return GaugesFactory.getGauge(name);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 protected TimeInterval extractTimeInterval(Document data) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 NodeList timeranges = data.getElementsByTagName("timerange");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 if (timeranges != null && timeranges.getLength() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 Element timerange = (Element) timeranges.item(0);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 String lower = timerange.getAttribute("lower");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 String upper = timerange.getAttribute("upper");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 if (lower != null && upper != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 try {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 Date d1 = DATE_FORMAT.parse(lower);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 Date d2 = DATE_FORMAT.parse(upper);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 return new TimeInterval(d1, d2);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 catch (ParseException pe) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 log.warn("Wrong time format: " + pe.getMessage());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 protected List<DischargeTable> getDischargeTables(Gauge gauge,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 TimeInterval timerange) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 List<DischargeTable> all = gauge.getDischargeTables();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 Collections.sort(all);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 if (timerange == null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 return all;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 List<DischargeTable> dts = new ArrayList<DischargeTable>(all.size());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 long startDate = timerange.getStartTime().getTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 long stopDate = timerange.getStopTime().getTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 for (DischargeTable dt : all) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 TimeInterval tmp = dt.getTimeInterval();
4230
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
277 if (tmp == null) {
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
278 // this should never happen because all discharge tables should
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
279 // have a time interval set!
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
280 continue;
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
281 }
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
282
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 Date start = tmp.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 Date stop = tmp.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 if (start.getTime() > startDate && start.getTime() < stopDate) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 dts.add(dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 continue;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 else if (stop != null && stop.getTime() < stopDate
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 && stop.getTime() > startDate) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 dts.add(dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 continue;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297 return dts;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 }
5342
7b119fa1e29f Doc and vim-magiv.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4230
diff changeset
300 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org