Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/model/CrossSection.java @ 8755:30b1ddadf275
(issue1801) Unify reference gauge finding code
The basic way as described in the method comment of the
determineRefGauge method is now used in the WINFOArtifact,
MainValuesService and RiverUtils.getGauge method.
RiverUtils.getGauge previously just returned the first
gauge found. While this is now a behavior change I believe
that it is always more correct then the undeterministic
behavior of the previous implmenentation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 24 Jun 2015 14:07:26 +0200 |
parents | 9d2e69f971f5 |
children | 8abe94270f32 |
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; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.io.Serializable; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.util.List; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
14 import java.util.ArrayList; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
15 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
16 import java.awt.geom.Point2D; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import javax.persistence.Entity; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import javax.persistence.Id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import javax.persistence.Table; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import javax.persistence.GeneratedValue; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import javax.persistence.Column; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import javax.persistence.SequenceGenerator; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import javax.persistence.GenerationType; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 import javax.persistence.OneToOne; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 import javax.persistence.OneToMany; |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1204
diff
changeset
|
27 import javax.persistence.OrderBy; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 import javax.persistence.JoinColumn; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
30 import java.math.MathContext; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
31 import java.math.BigDecimal; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
32 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
33 import org.hibernate.Session; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
34 import org.hibernate.SQLQuery; |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
35 import org.hibernate.Query; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
36 |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
37 import org.hibernate.type.StandardBasicTypes; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
38 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
39 import org.dive4elements.river.backend.SessionHolder; |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
40 |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
41 import org.apache.log4j.Logger; |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
42 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 @Entity |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 @Table(name = "cross_sections") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 public class CrossSection |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 implements Serializable |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7017
diff
changeset
|
48 private static Logger log = |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
49 Logger.getLogger(CrossSection.class); |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
50 |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
51 public static final MathContext PRECISION = new MathContext(6); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
52 |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
53 public static final String SQL_FAST_CROSS_SECTION_LINES = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
54 "SELECT km, x, y, csl.id AS csl_id " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
55 "FROM cross_section_lines csl JOIN cross_section_points csp " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
56 "ON csp.cross_section_line_id = csl.id " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
57 "WHERE csl.cross_section_id = :cs_id AND " + |
3334
2ae732e2c65c
FLYS backend: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2380
diff
changeset
|
58 "km between :from_km AND :to_km " + |
6270
44ee7d26eb18
issue1267: Polishing: Move the sorting into the db/sql-query.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6269
diff
changeset
|
59 "ORDER BY csl.km, csl.id, csp.col_pos"; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
60 |
6536
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
61 public static final String SQL_MIN_MAX = |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
62 "SELECT * FROM ( "+ |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
63 "SELECT cross_section_id, MIN(km) AS minkm, MAX(km) AS maxkm " + |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
64 "FROM cross_section_lines " + |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
65 "WHERE cross_section_id IN " + |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
66 " (SELECT id FROM cross_sections WHERE river_id = :river_id) " + |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
67 " GROUP BY cross_section_id" + |
6621
7e697c6eb379
CrossSection: Improve SQl compat of statement.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6538
diff
changeset
|
68 ") cs_ranges " + |
6622
718b0822374d
CrossSection: Uppercase sql keywords in query.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6621
diff
changeset
|
69 "JOIN cross_sections cs ON cs_ranges.cross_section_id = cs.id " + |
718b0822374d
CrossSection: Uppercase sql keywords in query.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6621
diff
changeset
|
70 "LEFT OUTER JOIN time_intervals ON cs.time_interval_id = time_intervals.id " + |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
71 "WHERE :km BETWEEN minkm AND maxkm " + |
7017
b9633d6ce57e
issue1157: Fix sorting by start time (descending) for cross-section selection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6852
diff
changeset
|
72 "ORDER BY stop_time desc, start_time desc, :km - minkm"; |
6536
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
73 // Order by time interval missing. |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
74 |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
75 private Integer id; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
76 private River river; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
77 private TimeInterval timeInterval; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
78 private String description; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
79 private List<CrossSectionLine> lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 public CrossSection() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
1204
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
84 public CrossSection( |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
85 River river, |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
86 TimeInterval timeInterval, |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
87 String description |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
88 ) { |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
89 this.river = river; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
90 this.timeInterval = timeInterval; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
91 this.description = description; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
92 } |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
93 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 @Id |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 @SequenceGenerator( |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 name = "SEQUENCE_CROSS_SECTIONS_ID_SEQ", |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 sequenceName = "CROSS_SECTIONS_ID_SEQ", |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 allocationSize = 1) |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 @GeneratedValue( |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 strategy = GenerationType.SEQUENCE, |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 generator = "SEQUENCE_CROSS_SECTIONS_ID_SEQ") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 @Column(name = "id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 public Integer getId() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 return id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 public void setId(Integer id) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 this.id = id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 @JoinColumn(name = "river_id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 public River getRiver() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 return river; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 public void setRiver(River river) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 this.river = river; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 @JoinColumn(name = "time_interval_id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 public TimeInterval getTimeInterval() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 return timeInterval; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 public void setTimeInterval(TimeInterval timeInterval) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 this.timeInterval = timeInterval; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 |
1202
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
131 @Column(name = "description") |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
132 public String getDescription() { |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
133 return description; |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
134 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
135 |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
136 public void setDescription(String description) { |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
137 this.description = description; |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
138 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
139 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 @OneToMany |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1204
diff
changeset
|
141 @OrderBy("km") |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 @JoinColumn(name="cross_section_id") |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
143 public List<CrossSectionLine> getLines() { |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
144 return lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
147 public void setLines(List<CrossSectionLine> lines) { |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
148 this.lines = lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
150 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
151 public List<CrossSectionLine> getLines(double startKm, double endKm) { |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
152 Session session = SessionHolder.HOLDER.get(); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
153 Query query = session.createQuery( |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
154 "from CrossSectionLine where crossSection=:crossSection " + |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
155 "and km between :startKm and :endKm order by km"); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
156 query.setParameter("crossSection", this); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
157 query.setParameter("startKm", new BigDecimal(startKm, PRECISION)); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
158 query.setParameter("endKm", new BigDecimal(endKm, PRECISION)); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
159 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
160 return query.list(); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
161 } |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
162 |
6269 | 163 /** Get Lines from startkm to endkm, fast because direct usage of sql. */ |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
164 public List<FastCrossSectionLine> getFastLines( |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
165 double startKm, |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
166 double endKm |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
167 ) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
168 Session session = SessionHolder.HOLDER.get(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
169 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
170 SQLQuery sqlQuery = session.createSQLQuery(SQL_FAST_CROSS_SECTION_LINES) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
171 .addScalar("km", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
172 .addScalar("x", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
173 .addScalar("y", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
174 .addScalar("csl_id", StandardBasicTypes.INTEGER); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
175 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
176 sqlQuery |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
177 .setInteger("cs_id", getId()) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
178 .setDouble("from_km", startKm) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
179 .setDouble("to_km", endKm); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
180 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
181 List<Object []> results = sqlQuery.list(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
182 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
183 ArrayList<Point2D> points = new ArrayList<Point2D>(500); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
184 ArrayList<FastCrossSectionLine> lines = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
185 new ArrayList<FastCrossSectionLine>(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
186 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
187 Integer lastId = null; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
188 Double lastKm = null; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
189 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
190 for (Object [] result: results) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
191 Double km = (Double)result[0]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
192 Double x = (Double)result[1]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
193 Double y = (Double)result[2]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
194 Integer id = (Integer)result[3]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
195 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
196 if (lastId != null && !lastId.equals(id)) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
197 points.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
198 FastCrossSectionLine line = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
199 new FastCrossSectionLine(lastKm, points); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
200 lines.add(line); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
201 points = new ArrayList<Point2D>(500); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
202 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
203 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
204 Point2D p = new Point2D.Double(x, y); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
205 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
206 if (CrossSectionLine.isValid(p)) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
207 points.add(p); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
208 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
209 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
210 lastKm = km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
211 lastId = id; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
212 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
213 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
214 if (lastId != null) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
215 points.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
216 FastCrossSectionLine line = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
217 new FastCrossSectionLine(lastKm, points); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
218 lines.add(line); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
219 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
220 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
221 lines.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
222 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
223 return lines; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
224 } |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
225 |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
226 /** |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
227 * True if the given section is the "newest" for that river and has values at km. |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
228 * @param km Given station. |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
229 * @return true if the section has the most advanced end of its validity interval |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
230 * or the most advanced start of its validity interval. |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
231 */ |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
232 public boolean shouldBeMaster(double km) { |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
233 Session session = SessionHolder.HOLDER.get(); |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
234 |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
235 SQLQuery sqlQuery = session.createSQLQuery(SQL_MIN_MAX) |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
236 .addScalar("cross_section_id", StandardBasicTypes.INTEGER); |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
237 |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
238 sqlQuery |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
239 .setInteger("river_id", getRiver().getId()) |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
240 .setDouble("km", km); |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
241 |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
242 List<Integer> results = sqlQuery.list(); |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
243 |
6852
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
244 if (results.size() >= 1) { |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
245 Integer result = results.get(0); |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
246 if (result == getId()) { |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
247 return true; |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
248 } |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
249 } |
6852
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
250 else { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7017
diff
changeset
|
251 log.warn("No CS found that could be master."); |
6852
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
252 } |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
253 |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
254 // TODO If there is none, might need a fallback. |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
255 // Formerly this was the most current CS (issue1157). |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
256 |
6538
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
257 return false; |
de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6536
diff
changeset
|
258 } |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |