Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/model/CrossSection.java @ 9464:c77255da734b
cross-section logs removed
author | gernotbelger |
---|---|
date | Thu, 30 Aug 2018 10:53:40 +0200 |
parents | 80800fe126cd |
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; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
11 import java.awt.geom.Point2D; |
9463 | 12 import java.io.Serializable; |
13 import java.math.BigDecimal; | |
14 import java.math.MathContext; | |
15 import java.util.ArrayList; | |
16 import java.util.List; | |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
9463 | 18 import javax.persistence.Column; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import javax.persistence.Entity; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import javax.persistence.GeneratedValue; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import javax.persistence.GenerationType; |
9463 | 22 import javax.persistence.Id; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import javax.persistence.JoinColumn; |
9463 | 24 import javax.persistence.OneToMany; |
25 import javax.persistence.OneToOne; | |
26 import javax.persistence.OrderBy; | |
27 import javax.persistence.SequenceGenerator; | |
28 import javax.persistence.Table; | |
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
|
29 |
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
|
30 import org.apache.log4j.Logger; |
9463 | 31 import org.dive4elements.river.backend.SessionHolder; |
32 import org.hibernate.Query; | |
33 import org.hibernate.SQLQuery; | |
34 import org.hibernate.Session; | |
35 import org.hibernate.type.StandardBasicTypes; | |
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
|
36 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 @Entity |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 @Table(name = "cross_sections") |
9463 | 39 public class CrossSection implements Serializable { |
40 private static Logger log = Logger.getLogger(CrossSection.class); | |
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 |
9460 | 42 private static final MathContext PRECISION = new MathContext(6); |
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
|
43 |
9463 | 44 private static final String SQL_FAST_CROSS_SECTION_LINES = "SELECT km, x, y, csl.id AS csl_id " |
45 + "FROM cross_section_lines csl JOIN cross_section_points csp " + "ON csp.cross_section_line_id = csl.id " | |
46 + "WHERE csl.cross_section_id = :cs_id AND " + "km between :from_km AND :to_km " + "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
|
47 |
9463 | 48 private static final String SQL_MIN_MAX = "SELECT * FROM ( " + "SELECT cross_section_id, MIN(km) AS minkm, MAX(km) AS maxkm " + "FROM cross_section_lines " |
49 + "WHERE cross_section_id IN " + " (SELECT id FROM cross_sections WHERE river_id = :river_id) " + " GROUP BY cross_section_id" + ") cs_ranges " | |
50 + "JOIN cross_sections cs ON cs_ranges.cross_section_id = cs.id " + "LEFT OUTER JOIN time_intervals " | |
51 + " ON cs.time_interval_id = time_intervals.id " + "WHERE :km BETWEEN minkm AND maxkm " | |
52 + "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
|
53 // Order by time interval missing. |
c155f8f57b7e
Initial improved query to find matching cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6270
diff
changeset
|
54 |
9463 | 55 private Integer id; |
56 private River river; | |
57 private TimeInterval timeInterval; | |
58 private String description; | |
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
|
59 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
|
60 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 public CrossSection() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
9463 | 64 public CrossSection(final River river, final TimeInterval timeInterval, final String description) { |
65 this.river = river; | |
1204
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
66 this.timeInterval = timeInterval; |
9463 | 67 this.description = description; |
1204
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
68 } |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
69 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 @Id |
9463 | 71 @SequenceGenerator(name = "SEQUENCE_CROSS_SECTIONS_ID_SEQ", sequenceName = "CROSS_SECTIONS_ID_SEQ", allocationSize = 1) |
72 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_CROSS_SECTIONS_ID_SEQ") | |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 @Column(name = "id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 public Integer getId() { |
9463 | 75 return this.id; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 |
9463 | 78 public void setId(final Integer id) { |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 this.id = id; |
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 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 @JoinColumn(name = "river_id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 public River getRiver() { |
9463 | 85 return this.river; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 |
9463 | 88 public void setRiver(final River river) { |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 this.river = river; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 @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
|
94 public TimeInterval getTimeInterval() { |
9463 | 95 return this.timeInterval; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
9463 | 98 public void setTimeInterval(final TimeInterval timeInterval) { |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 this.timeInterval = timeInterval; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 |
1202
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
102 @Column(name = "description") |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
103 public String getDescription() { |
9463 | 104 return this.description; |
1202
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
105 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
106 |
9463 | 107 public void setDescription(final String description) { |
1202
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
108 this.description = description; |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
109 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
110 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 @OneToMany |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1204
diff
changeset
|
112 @OrderBy("km") |
9463 | 113 @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
|
114 public List<CrossSectionLine> getLines() { |
9463 | 115 return this.lines; |
1194
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 |
9463 | 118 public void setLines(final List<CrossSectionLine> lines) { |
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
|
119 this.lines = lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 } |
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
|
121 |
9463 | 122 public List<CrossSectionLine> getLines(final double startKm, final double endKm) { |
123 final Session session = SessionHolder.HOLDER.get(); | |
124 final Query query = session.createQuery("from CrossSectionLine where crossSection=:crossSection " + "and km between :startKm and :endKm order by km"); | |
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
|
125 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
|
126 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
|
127 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
|
128 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
129 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
|
130 } |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
131 |
6269 | 132 /** Get Lines from startkm to endkm, fast because direct usage of sql. */ |
9463 | 133 public List<FastCrossSectionLine> getFastLines(final double startKm, final double endKm) { |
134 final Session session = SessionHolder.HOLDER.get(); | |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
135 |
9463 | 136 final SQLQuery sqlQuery = session.createSQLQuery(SQL_FAST_CROSS_SECTION_LINES).addScalar("km", StandardBasicTypes.DOUBLE) |
137 .addScalar("x", StandardBasicTypes.DOUBLE).addScalar("y", StandardBasicTypes.DOUBLE).addScalar("csl_id", StandardBasicTypes.INTEGER); | |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
138 |
9463 | 139 sqlQuery.setInteger("cs_id", getId()).setDouble("from_km", startKm).setDouble("to_km", endKm); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
140 |
9463 | 141 final List<Object[]> results = sqlQuery.list(); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
142 |
9463 | 143 ArrayList<Point2D> points = new ArrayList<>(500); |
144 final ArrayList<FastCrossSectionLine> lines = new ArrayList<>(); | |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
145 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
146 Integer lastId = null; |
9463 | 147 Double lastKm = null; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
148 |
9463 | 149 for (final Object[] result : results) { |
150 final Double km = (Double) result[0]; | |
151 final Double x = (Double) result[1]; | |
152 final Double y = (Double) result[2]; | |
153 final Integer id = (Integer) result[3]; | |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
154 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
155 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
|
156 points.trimToSize(); |
9463 | 157 final FastCrossSectionLine line = new FastCrossSectionLine(lastKm, points); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
158 lines.add(line); |
9463 | 159 points = new ArrayList<>(500); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
160 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
161 |
8813
8abe94270f32
Do not filter cross section points for display.
Tom Gottfried <tom@intevation.de>
parents:
8200
diff
changeset
|
162 points.add(new Point2D.Double(x, y)); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
163 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
164 lastKm = km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
165 lastId = id; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
166 } |
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 if (lastId != null) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
169 points.trimToSize(); |
9463 | 170 final FastCrossSectionLine line = new FastCrossSectionLine(lastKm, points); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
171 lines.add(line); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
172 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
173 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
174 lines.trimToSize(); |
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 return lines; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
177 } |
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
|
178 |
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
|
179 /** |
8856 | 180 * True if the given section is the "newest" for that river |
181 * and has values at km. | |
9463 | 182 * |
183 * @param km | |
184 * Given station. | |
8856 | 185 * @return true if the section has the most advanced end of its validity |
186 * interval or the most advanced start of its validity interval. | |
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
|
187 */ |
9463 | 188 public boolean shouldBeMaster(final double km) { |
189 final Session session = SessionHolder.HOLDER.get(); | |
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
|
190 |
9463 | 191 final SQLQuery sqlQuery = session.createSQLQuery(SQL_MIN_MAX).addScalar("cross_section_id", StandardBasicTypes.INTEGER); |
192 | |
193 sqlQuery.setInteger("river_id", getRiver().getId()).setDouble("km", km); | |
194 | |
195 final List<Integer> results = sqlQuery.list(); | |
196 | |
6852
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
197 if (results.size() >= 1) { |
9463 | 198 final Integer result = results.get(0); |
9464 | 199 if (result.equals(getId())) { // NIEMALS OBJEKTE MIT "==" VERGLEICHEN! |
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
|
200 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
|
201 } |
9463 | 202 } else { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7017
diff
changeset
|
203 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
|
204 } |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
205 |
d02ad36115c6
issue1157: Only look at the best match for CrossSections to activate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6622
diff
changeset
|
206 // 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
|
207 // 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
|
208 |
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
|
209 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
|
210 } |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |