Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/WaterlevelDifferenceColumn.java @ 4631:d35d316049e8
A little optimization and handle the case that there are duplicates in the values.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 03 Dec 2012 21:16:15 +0100 |
parents | dfc5bc5660c2 |
children |
rev | line source |
---|---|
2847
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.ArrayList; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.util.List; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import javax.persistence.Entity; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import javax.persistence.Id; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import javax.persistence.Table; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import javax.persistence.GeneratedValue; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import javax.persistence.Column; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import javax.persistence.SequenceGenerator; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import javax.persistence.GenerationType; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import javax.persistence.JoinColumn; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import javax.persistence.OneToOne; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import javax.persistence.OneToMany; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.apache.log4j.Logger; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 @Entity |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 @Table(name = "waterlevel_difference_column") |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public class WaterlevelDifferenceColumn |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 implements Serializable |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 private static Logger logger = |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 Logger.getLogger(WaterlevelDifferenceColumn.class); |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 private Integer id; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 private WaterlevelDifference difference; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 private List<WaterlevelDifferenceValue> values; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 private String description; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 public WaterlevelDifferenceColumn() { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 values = new ArrayList<WaterlevelDifferenceValue>(); |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public WaterlevelDifferenceColumn( |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 WaterlevelDifference difference, |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 String description |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 ) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 this(); |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 this.difference = difference; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 this.description = description; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 @Id |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 @SequenceGenerator( |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 name = "SEQUENCE_WATERLEVEL_DIFF_COLUMN_ID_SEQ", |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 sequenceName = "WATERLEVEL_DIFF_COLUMN_ID_SEQ", |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 allocationSize = 1) |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 @GeneratedValue( |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 strategy = GenerationType.SEQUENCE, |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 generator = "SEQUENCE_WATERLEVEL_DIFF_COLUMN_ID_SEQ") |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 @Column(name = "id") |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 public Integer getId() { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 return id; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 public void setId(Integer id) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 this.id = id; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 @OneToOne |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 @JoinColumn(name = "difference_id" ) |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 public WaterlevelDifference getDifference() { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 return difference; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 public void setDifference(WaterlevelDifference difference) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 this.difference = difference; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 @Column(name = "description") |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 public String getDescription() { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 return description; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 public void setDescription(String description) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 this.description = description; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 @OneToMany |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 @JoinColumn(name = "column_id") |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 public List<WaterlevelDifferenceValue> getValues() { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 return values; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 public void setValues(List<WaterlevelDifferenceValue> values) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 this.values = values; |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 public void addValue(WaterlevelDifferenceValue value) { |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 this.values.add(value); |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 } |
dfc5bc5660c2
Added model classes for MINFO specific waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |