annotate backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5992
4c3ccf2b0304 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5844
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5992
4c3ccf2b0304 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5844
diff changeset
6 * documentation coming with Dive4Elements River for details.
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
9 package org.dive4elements.river.model;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
11 import java.util.Iterator;
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
12 import java.util.List;
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
13 import java.util.ArrayList;
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
14 import java.util.Collections;
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
15 import java.util.Comparator;
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
16
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import javax.persistence.Column;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import javax.persistence.Entity;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import javax.persistence.GeneratedValue;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import javax.persistence.GenerationType;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import javax.persistence.Id;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import javax.persistence.JoinColumn;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import javax.persistence.OneToOne;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import javax.persistence.SequenceGenerator;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import javax.persistence.Table;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
27 import org.hibernate.Session;
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
28 import org.hibernate.Query;
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
29
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
30 import org.dive4elements.river.backend.SessionHolder;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
32 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
33 import org.apache.logging.log4j.LogManager;
8693
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
34
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
35 import static org.dive4elements.river.backend.utils.EpsilonComparator.CMP;
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
36
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 @Entity
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 @Table(name = "measurement_station")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public class MeasurementStation {
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
40 private static final Logger log = LogManager.getLogger(
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
41 MeasurementStation.class);
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 private Integer id;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 private String name;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 private String measurementType;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 private String riverside;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 private String operator;
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
49 private String comment;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 private Range range;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 private Gauge gauge;
5457
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
54 private String gaugeName;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 private TimeInterval observationTimerange;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
8665
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
58 public static final String MEASUREMENT_TYPE_BEDLOAD = "Geschiebe";
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
59 public static final String MEASUREMENT_TYPE_SUSP = "Schwebstoff";
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
60
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
61 public static final class MeasurementStationComparator
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
62 implements Comparator<MeasurementStation> {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
63
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
64 public MeasurementStationComparator() {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
65 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
66
8665
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
67 /* Compare MeasurementStations by km and consider MeasurementStations
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
68 of type "Geschiebe" as smaller if at same km. */
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
69 @Override
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
70 public int compare(MeasurementStation m1, MeasurementStation m2)
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
71 throws IllegalArgumentException {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
72
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
73 if (m1.getRange().getRiver() != m2.getRange().getRiver()) {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
74 throw new IllegalArgumentException(
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
75 "Stations not at same river");
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
76 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
77
8693
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
78 int cmpStations = CMP.compare(m1.retrieveKm(), m2.retrieveKm());
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
79 if (cmpStations == 0) {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
80 if (m1.getMeasurementType().equals(m2.getMeasurementType())) {
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
81 throw new IllegalArgumentException(
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
82 "Two stations of same type at same km");
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
83 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
84
8665
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
85 return m1.getMeasurementType().equals(MEASUREMENT_TYPE_BEDLOAD)
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
86 ? -1
8fbc0649da13 Move static measurement types to their natural home.
Tom Gottfried <tom@intevation.de>
parents: 8602
diff changeset
87 : +1;
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
88 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
89 return cmpStations;
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
90 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
91 }
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
92
4261
1264fef59bfa Add default constructor to MeasurementStation
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4193
diff changeset
93 public MeasurementStation() {
1264fef59bfa Add default constructor to MeasurementStation
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4193
diff changeset
94 }
1264fef59bfa Add default constructor to MeasurementStation
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4193
diff changeset
95
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
96 public MeasurementStation(String name, String measurementType,
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
97 String riverside, Range range, Gauge gauge,
5457
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
98 String gaugeName, TimeInterval observationTimerange, String operator,
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
99 String comment
5457
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
100 ) {
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 this.name = name;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 this.measurementType = measurementType;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 this.riverside = riverside;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 this.range = range;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 this.gauge = gauge;
5457
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
106 this.gaugeName = gaugeName;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 this.observationTimerange = observationTimerange;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 this.operator = operator;
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
109 this.comment = comment;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 @Id
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
113 @SequenceGenerator(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
114 name = "SEQ_MEASUREMENT_STATION_ID_SEQ",
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
115 sequenceName = "MEASUREMENT_STATION_ID_SEQ",
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
116 allocationSize = 1)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
117 @GeneratedValue(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
118 strategy = GenerationType.SEQUENCE,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8693
diff changeset
119 generator = "SEQ_MEASUREMENT_STATION_ID_SEQ")
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 @Column(name = "id")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 public Integer getId() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 return id;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 public void setId(Integer id) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 this.id = id;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 @Column(name = "name")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 public String getName() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 return name;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 public void setName(String name) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 this.name = name;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 @Column(name = "measurement_type")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 public String getMeasurementType() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 return measurementType;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 public void setMeasurementType(String measurementType) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 this.measurementType = measurementType;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 @Column(name = "riverside")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 public String getRiverside() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 return riverside;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 public void setRiverside(String riverside) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 this.riverside = riverside;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 @OneToOne
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 @JoinColumn(name = "reference_gauge_id")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 public Gauge getGauge() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 return gauge;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 public void setGauge(Gauge gauge) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 this.gauge = gauge;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165
5457
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
166 @Column(name = "reference_gauge_name")
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
167 public String getGaugeName() {
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
168 return gaugeName;
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
169 }
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
170
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
171 public void setGaugeName(String gaugeName) {
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
172 this.gaugeName = gaugeName;
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
173 }
1b676aefaf3a Added gauge name to measurement station parser and model.
Raimund Renkert <rrenkert@intevation.de>
parents: 5428
diff changeset
174
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 @OneToOne
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 @JoinColumn(name = "range_id")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 public Range getRange() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 return range;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 public void setRange(Range range) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 this.range = range;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 @OneToOne
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
186 @JoinColumn(name = "time_interval_id")
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 public TimeInterval getObservationTimerange() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 return observationTimerange;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 public void setObservationTimerange(TimeInterval observationTimerange) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 this.observationTimerange = observationTimerange;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 @Column(name = "operator")
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 public String getOperator() {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 return operator;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 public void setOperator(String operator) {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 this.operator = operator;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203
8415
ffbeffe2d266 SCHEMA CHANGE: 'comment' is not acceptable as column name for Oracle.
Tom Gottfried <tom@intevation.de>
parents: 8412
diff changeset
204 @Column(name = "commentary")
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
205 public String getComment() {
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
206 return comment;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
209 public void setComment(String comment) {
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
210 this.comment = comment;
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 }
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
212
8693
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
213 /* Get the actual location of the measurement station at the river */
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
214 public double retrieveKm() {
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
215 // In case river is km_up, station is at larger value of range
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
216 return getRange().getRiver().getKmUp() && getRange().getB() != null
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
217 ? getRange().getB().doubleValue()
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
218 : getRange().getA().doubleValue();
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
219 }
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
220
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
221 /* Get measurement station of other type at the same location */
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
222 public MeasurementStation findCompanionStation() {
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
223 River river = getRange().getRiver();
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
224 double km = retrieveKm();
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
225 List<MeasurementStation> stations = getStationsAtKM(river, km);
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
226
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
227 for (MeasurementStation station: stations) {
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
228 if (!station.getMeasurementType().equals(getMeasurementType())) {
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
229 return station;
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
230 }
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
231 }
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
232 log.debug("No additional stations found at km " + km +
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
233 " at river " + river);
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
234 return null;
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
235 }
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
236
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
237 public static List<MeasurementStation> getStationsAtRiver(River river) {
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
238 Session session = SessionHolder.HOLDER.get();
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
239
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
240 Query query = session.createQuery(
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
241 "from MeasurementStation " +
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
242 "where range.river = :river");
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
243 query.setParameter("river", river);
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
244
8418
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
245 List<MeasurementStation> result = query.list();
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
246 Collections.sort(result, new MeasurementStationComparator());
536a1c0c8a81 Give ordered list of measurement stations at river.
Tom Gottfried <tom@intevation.de>
parents: 8415
diff changeset
247 return result;
6857
d5d717effa06 (issue1347) Add measurement station getter for location
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
248 }
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
249
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
250 public static List<MeasurementStation> getStationsAtKM(
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
251 River river,
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
252 Double river_km
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
253 ) {
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
254 Session session = SessionHolder.HOLDER.get();
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
255
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
256 Query query = session.createQuery(
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
257 "from MeasurementStation where range.river = :river");
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
258 query.setParameter("river", river);
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
259
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
260 List<MeasurementStation> result = new ArrayList<MeasurementStation>();
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
261 for (Iterator iter = query.iterate(); iter.hasNext();) {
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
262 MeasurementStation st = (MeasurementStation)iter.next();
8693
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
263 if (CMP.compare(st.retrieveKm(), river_km) == 0) {
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
264 result.add(st);
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
265 }
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
266 }
8693
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
267
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
268 if (result.size() > 2) {
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
269 // TODO: database schema should prevent this
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
270 log.warn("More than two measurement stations at km " + river_km +
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
271 " at river " + river.getName());
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
272 }
851ea37d35f3 (issue1750) New methods for finding the actual location and companion station of a measurement station.
Tom Gottfried <tom@intevation.de>
parents: 8665
diff changeset
273
8412
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
274 return result;
17db08570637 SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents: 6857
diff changeset
275 }
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 }

http://dive4elements.wald.intevation.org