annotate backend/src/main/java/org/dive4elements/river/model/DischargeTable.java @ 6692:ce691d22cee3

issue1891: Add method to get a discharge table by it's id
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 29 Jul 2013 12:17:11 +0200
parents 4c3ccf2b0304
children ff27548d078c
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;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
26
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
27 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
28 import org.hibernate.Query;
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
29 import org.dive4elements.river.backend.SessionHolder;
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
30
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
31 @Entity
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
32 @Table(name = "discharge_tables")
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 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
34 implements Serializable, Comparable<DischargeTable>
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 {
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
36 private Integer id;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 private Gauge gauge;
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
38 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
39 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
40 private Integer kind;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 private TimeInterval timeInterval;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
43 private List<DischargeTableValue> dischargeTableValues;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
44
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public DischargeTable() {
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
46 kind = 0;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
198
d980e545ccab Added import code for importing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 174
diff changeset
49 public DischargeTable(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
50 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
51 }
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
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
53 public DischargeTable(
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
54 Gauge gauge,
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
55 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
56 String bfgId,
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
57 Integer kind,
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
58 TimeInterval timeInterval
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
59 ) {
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
60 this.gauge = gauge;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
61 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
62 this.bfgId = bfgId;
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
63 this.kind = kind;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
64 this.timeInterval = timeInterval;
198
d980e545ccab Added import code for importing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 174
diff changeset
65 }
d980e545ccab Added import code for importing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 174
diff changeset
66
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
67 @Id
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
68 @SequenceGenerator(
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
69 name = "SEQUENCE_DISCHARGE_TABLES_ID_SEQ",
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
70 sequenceName = "DISCHARGE_TABLES_ID_SEQ",
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
71 allocationSize = 1)
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
72 @GeneratedValue(
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
73 strategy = GenerationType.SEQUENCE,
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
74 generator = "SEQUENCE_DISCHARGE_TABLES_ID_SEQ")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
75 @Column(name = "id")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
76 public Integer getId() {
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
77 return id;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
78 }
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
79
168
86a1bd9cc50e More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 167
diff changeset
80 public void setId(Integer id) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 this.id = id;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
84 @OneToOne
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
85 @JoinColumn(name = "gauge_id" )
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
86 public Gauge getGauge() {
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 return 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
88 }
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 public void setGauge(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
91 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
92 }
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
493
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
94 @Column(name = "description")
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
95 public String getDescription() {
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
96 return description;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
97 }
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 public void setDescription(String description) {
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
100 this.description = description;
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
101 }
b35c5dc0f8b7 Importer: Make import of historical discharge tables work.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 467
diff changeset
102
4776
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
103 @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
104 public String getBfgId() {
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
105 return bfgId;
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
106 }
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 public void setBfgId(String bfgId) {
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
109 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
110 }
20b6ebf23916 !!! FLYS backend schema change !!! Add column bfg_id column to discharge_tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4227
diff changeset
111
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
112 @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
113 public Integer getKind() {
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 return 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
115 }
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 public void setKind(Integer 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
118 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
119 }
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 @OneToOne
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
122 @JoinColumn(name = "time_interval_id" )
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
123 public TimeInterval getTimeInterval() {
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
124 return timeInterval;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
125 }
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
126
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 public void setTimeInterval(TimeInterval timeInterval) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 this.timeInterval = timeInterval;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
131 @OneToMany
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
132 @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
133 @OrderBy("q")
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
134 public List<DischargeTableValue> getDischargeTableValues() {
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
135 return dischargeTableValues;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
136 }
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 public void setDischargeTableValues(
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
139 List<DischargeTableValue> dischargeTableValues
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
140 ) {
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
141 this.dischargeTableValues = dischargeTableValues;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 }
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
143
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 @Override
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
145 public int compareTo(DischargeTable o) {
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
146 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
147 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
148 }
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
149
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
150 TimeInterval other = o.getTimeInterval();
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
151 if (other == null && timeInterval == 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
152 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
153 }
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
154 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
155 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
156 }
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
157 else if (timeInterval == null) {
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4173
diff changeset
158 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
159 }
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
160
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
161 Date otherStartTime = other.getStartTime();
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
162 Date thisStartTime = timeInterval.getStartTime();
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
163
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
164 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
165 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
166 }
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
167 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
168 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
169 }
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
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
171 long otherStart = otherStartTime.getTime();
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
172 long thisStart = thisStartTime.getTime();
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 (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
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 (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
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
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
181 Date otherStopTime = other.getStopTime();
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
182 Date thisStopTime = timeInterval.getStopTime();
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 (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
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 (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
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
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
191 long otherEnd = otherStopTime.getTime();
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
192 long thisEnd = thisStopTime.getTime();
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 (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
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 (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
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 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
201 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
202 }
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 }
6692
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
204
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
205 public static DischargeTable getDischargeTableById(int dtId)
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
206 {
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
207 Session session = SessionHolder.HOLDER.get();
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
208 Query query = session.createQuery(
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
209 "from DischargeTable where id =:dtId");
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
210 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
211
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
212 List<DischargeTable> list = query.list();
ce691d22cee3 issue1891: Add method to get a discharge table by it's id
Andre Heinecke <aheinecke@intevation.de>
parents: 5992
diff changeset
213 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
214 }
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org