annotate backend/src/main/java/org/dive4elements/river/model/TimeInterval.java @ 9055:df5c5614e9a7

New pseudo datetime for year-only values (31.12. instead of 15.6.)
author mschaefer
date Fri, 04 May 2018 14:03:47 +0200
parents 4c3ccf2b0304
children df6f1b5806f6
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;
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
12 import java.util.Calendar;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import java.util.Date;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
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;
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
17 import javax.persistence.GeneratedValue;
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
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;
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
20 import javax.persistence.SequenceGenerator;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
21 import javax.persistence.Table;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
22
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
23 @Entity
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
24 @Table(name = "time_intervals")
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 public class TimeInterval
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 implements Serializable
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 {
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
28 /**
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
29 * Pseudo-date for Date values where only the year field is significant
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
30 * (in Flys 3.2.1 June-15 12:00 had been used)
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
31 */
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
32 public final static Calendar YEAR_ONLY_DATE;
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
33 static {
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
34 YEAR_ONLY_DATE = Calendar.getInstance();
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
35 YEAR_ONLY_DATE.clear();
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
36 YEAR_ONLY_DATE.set(0, Calendar.DECEMBER, 31, 3, 5, 6);
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
37 }
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
38
168
86a1bd9cc50e More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 167
diff changeset
39 private Integer id;
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
40 private Date startTime;
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
41 private Date stopTime;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 public TimeInterval() {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
46 public TimeInterval(final Date startTime, final Date stopTime) {
486
8ea09ec7f0c8 Importer: Attach a time interval to a discharge table if we find one during import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
47 this.startTime = startTime;
8ea09ec7f0c8 Importer: Attach a time interval to a discharge table if we find one during import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
48 this.stopTime = stopTime;
8ea09ec7f0c8 Importer: Attach a time interval to a discharge table if we find one during import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
49 }
8ea09ec7f0c8 Importer: Attach a time interval to a discharge table if we find one during import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
50
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
51 @Id
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
52 @SequenceGenerator(
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
53 name = "SEQUENCE_TIME_INTERVALS_ID_SEQ",
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
54 sequenceName = "TIME_INTERVALS_ID_SEQ",
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
55 allocationSize = 1)
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
56 @GeneratedValue(
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
57 strategy = GenerationType.SEQUENCE,
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
58 generator = "SEQUENCE_TIME_INTERVALS_ID_SEQ")
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
59 @Column(name = "id")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
60 public Integer getId() {
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
61 return this.id;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
62 }
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
63
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
64 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
65 this.id = id;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
68 @Column(name = "start_time") // FIXME: type mapping needed?
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
69 public Date getStartTime() {
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
70 return this.startTime;
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
71 }
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
72
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
73 public void setStartTime(final Date startTime) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 this.startTime = startTime;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
77 @Column(name = "stop_time") // FIXME: type mapping needed?
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
78 public Date getStopTime() {
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
79 return this.stopTime;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81
9055
df5c5614e9a7 New pseudo datetime for year-only values (31.12. instead of 15.6.)
mschaefer
parents: 5992
diff changeset
82 public void setStopTime(final Date stopTime) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 this.stopTime = stopTime;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org