annotate backend/src/main/java/org/dive4elements/river/model/DischargeTable.java @ 9201:491e1a434457

Renamed getValues... to fetch...
author mschaefer
date Sun, 01 Jul 2018 15:29:40 +0200
parents 64e56a51db3f
children f2473dc34535
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;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.io.Serializable;
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
12 import java.util.Date;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
13 import java.util.List;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
15 import javax.persistence.Column;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
16 import javax.persistence.Entity;
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
17 import javax.persistence.GeneratedValue;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
18 import javax.persistence.GenerationType;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
19 import javax.persistence.Id;
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
20 import javax.persistence.JoinColumn;
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
21 import javax.persistence.OneToMany;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
22 import javax.persistence.OneToOne;
2425
67f362883fe4 flys/issue499: Sort the values of the discharge table by Q.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 493
diff changeset
23 import javax.persistence.OrderBy;
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
24 import javax.persistence.SequenceGenerator;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
25 import javax.persistence.Table;
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
26 import javax.persistence.Transient;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
27
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
28 import org.dive4elements.river.backend.SessionHolder;
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
29 import org.hibernate.Query;
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
30 import org.hibernate.Session;
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
31
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
32 @Entity
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
33 @Table(name = "discharge_tables")
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 public class DischargeTable
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
35 implements Serializable, Comparable<DischargeTable>
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 {
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
37 private Integer id;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 private Gauge gauge;
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
39 private String description;
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
40 private String bfgId;
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
41 private Integer kind;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 private TimeInterval timeInterval;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
44 private List<DischargeTableValue> dischargeTableValues;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
45
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 public DischargeTable() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
47 this.kind = 0;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
50 public DischargeTable(final Gauge gauge) {
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
51 this(gauge, null, null, 0, null);
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
52 }
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
53
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
54 public DischargeTable(
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
55 final Gauge gauge,
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
56 final String description,
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
57 final String bfgId,
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
58 final Integer kind,
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
59 final TimeInterval timeInterval
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
60 ) {
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
61 this.gauge = gauge;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
62 this.description = description;
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
63 this.bfgId = bfgId;
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
64 this.kind = kind;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
65 this.timeInterval = timeInterval;
198
d980e545ccab Added import code for importing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 174
diff changeset
66 }
d980e545ccab Added import code for importing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 174
diff changeset
67
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
68 @Id
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
69 @SequenceGenerator(
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
70 name = "SEQUENCE_DISCHARGE_TABLES_ID_SEQ",
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
71 sequenceName = "DISCHARGE_TABLES_ID_SEQ",
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
72 allocationSize = 1)
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
73 @GeneratedValue(
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
74 strategy = GenerationType.SEQUENCE,
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
75 generator = "SEQUENCE_DISCHARGE_TABLES_ID_SEQ")
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
76 @Column(name = "id")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
77 public Integer getId() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
78 return this.id;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
79 }
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
80
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
81 public void setId(final Integer id) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 this.id = id;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
85 @OneToOne
8842
ff27548d078c Whitespace cosmetics.
Tom Gottfried <tom@intevation.de>
parents: 6692
diff changeset
86 @JoinColumn(name = "gauge_id")
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
87 public Gauge getGauge() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
88 return this.gauge;
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
89 }
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
90
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
91 public void setGauge(final Gauge gauge) {
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
92 this.gauge = gauge;
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
93 }
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
94
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
95 @Column(name = "description")
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
96 public String getDescription() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
97 return this.description;
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
98 }
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
99
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
100 public void setDescription(final String description) {
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
101 this.description = description;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
102 }
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
103
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
104 @Column(name = "bfg_id")
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
105 public String getBfgId() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
106 return this.bfgId;
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
107 }
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
108
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
109 public void setBfgId(final String bfgId) {
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
110 this.bfgId = bfgId;
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
111 }
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
112
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
113 @Column(name = "kind")
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
114 public Integer getKind() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
115 return this.kind;
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
116 }
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
117
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
118 public void setKind(final Integer kind) {
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
119 this.kind = kind;
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
120 }
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
121
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 198
diff changeset
122 @OneToOne
8842
ff27548d078c Whitespace cosmetics.
Tom Gottfried <tom@intevation.de>
parents: 6692
diff changeset
123 @JoinColumn(name = "time_interval_id")
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
124 public TimeInterval getTimeInterval() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
125 return this.timeInterval;
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
126 }
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
127
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
128 public void setTimeInterval(final TimeInterval timeInterval) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 this.timeInterval = timeInterval;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
132 @OneToMany
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
133 @JoinColumn(name = "table_id")
2425
67f362883fe4 flys/issue499: Sort the values of the discharge table by Q.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 493
diff changeset
134 @OrderBy("q")
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
135 public List<DischargeTableValue> getDischargeTableValues() {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
136 return this.dischargeTableValues;
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
137 }
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
138
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
139 public void setDischargeTableValues(
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
140 final List<DischargeTableValue> dischargeTableValues
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
141 ) {
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
142 this.dischargeTableValues = dischargeTableValues;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 }
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
144
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
145 @Transient
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
146 public double[] getWs() {
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
147 final double[] ws = new double[this.dischargeTableValues.size()];
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
148 for (int i=0; i<=this.dischargeTableValues.size()-1; i++)
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
149 ws[i] = this.dischargeTableValues.get(i).getW().doubleValue();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
150
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
151 return ws;
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
152 }
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
153
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
154 @Override
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
155 public int compareTo(final DischargeTable o) {
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
156 if (getKind() == 0 && o.getKind() != 0) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
157 return 1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
158 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
159
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
160 final TimeInterval other = o.getTimeInterval();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
161 if (other == null && this.timeInterval == null) {
4227
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
162 return 1;
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
163 }
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
164 else if (other == null) {
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
165 return -1;
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
166 }
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
167 else if (this.timeInterval == null) {
4227
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
168 return 1;
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
169 }
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
170
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
171 final Date otherStartTime = other.getStartTime();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
172 final Date thisStartTime = this.timeInterval.getStartTime();
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
174 if (otherStartTime == null) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
175 return -1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
176 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
177 else if (thisStartTime == null) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
178 return 1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
179 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
180
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
181 final long otherStart = otherStartTime.getTime();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
182 final long thisStart = thisStartTime.getTime();
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
183
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
184 if (otherStart < thisStart) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
185 return 1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
186 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
187 else if (otherStart > thisStart) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
188 return -1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
189 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
190
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
191 final Date otherStopTime = other.getStopTime();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
192 final Date thisStopTime = this.timeInterval.getStopTime();
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
193
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
194 if (otherStopTime == null) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
195 return -1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
196 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
197 else if (thisStopTime == null) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
198 return 1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
199 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
200
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
201 final long otherEnd = otherStopTime.getTime();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
202 final long thisEnd = thisStopTime.getTime();
4173
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
203
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
204 if (otherEnd < thisEnd) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
205 return 1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
206 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
207 else if (otherEnd > thisEnd) {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
208 return -1;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
209 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
210 else {
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
211 return 0;
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
212 }
7d4480c0e68e Allow users to select the current relevant discharge table in historical discharge table calculattion.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2425
diff changeset
213 }
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
214
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
215 public static DischargeTable getDischargeTableById(final int dtId)
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
216 {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
217 final Session session = SessionHolder.HOLDER.get();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
218 final Query query = session.createQuery("from DischargeTable where id =:dtId");
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
219 query.setParameter("dtId", dtId);
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
220
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
221 final List<DischargeTable> list = query.list();
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
222 return list.isEmpty() ? null : list.get(0);
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
223 }
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
224
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
225 /**
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
226 * Selects from the database the values of a discharge table sorted by W
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
227 */
9201
491e1a434457 Renamed getValues... to fetch...
mschaefer
parents: 9159
diff changeset
228 public static List<DischargeTableValue> fetchValuesSortedByW(final DischargeTable dischargeTable) {
9159
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
229 final Session session = SessionHolder.HOLDER.get();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
230 final Query query = session.createQuery("FROM DischargeTableValue WHERE table_id=:parentid ORDER BY w");
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
231 query.setParameter("parentid", dischargeTable.getId());
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
232 return query.list();
64e56a51db3f Added methods to select a gauge's discharge table and main value list; added a main value type key enum
mschaefer
parents: 8842
diff changeset
233 }
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org