Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java @ 4447:a5993b69439b
Add processor to be able to generate curves for WKms values
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 07 Nov 2012 15:52:25 +0100 |
parents | ed13816047b3 |
children | 8320427ecd5c |
rev | line source |
---|---|
2850
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.importer; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.hibernate.Session; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.hibernate.Query; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.model.WaterlevelDifferenceColumn; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.model.WaterlevelDifferenceValue; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 public class ImportWaterlevelDifferenceValue { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 private static final Logger log = |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 Logger.getLogger(ImportWaterlevelDifferenceValue.class); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 private Double station; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 private Double value; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 private WaterlevelDifferenceValue peer; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public ImportWaterlevelDifferenceValue(Double station, Double value) { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 this.station = station; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 this.value = value; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public void storeDependencies(WaterlevelDifferenceColumn column) { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 getPeer(column); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 public WaterlevelDifferenceValue getPeer(WaterlevelDifferenceColumn column) { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 if (peer == null) { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Session session = ImporterSession.getInstance().getDatabaseSession(); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 Query query = session.createQuery( |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 "from WaterlevelDifferenceValue where " + |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 " column=:column and " + |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 " station=:station and " + |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 " value=:value" |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 ); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 query.setParameter("column", column); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 query.setParameter("station", station); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 query.setParameter("value", value); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 List<WaterlevelDifferenceValue> values = query.list(); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 if (values.isEmpty()) { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 peer = new WaterlevelDifferenceValue(column, station, value); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 session.save(peer); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 else { |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 peer = values.get(0); |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 return peer; |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
a1402c16152f
Added a parser and importer classes used to import waterlevel differences.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |