Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYieldValue.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 | 75446c47ef77 |
children |
rev | line source |
---|---|
2838
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.importer; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.hibernate.Session; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.hibernate.Query; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.model.SedimentYield; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.model.SedimentYieldValue; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 public class ImportSedimentYieldValue { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 private Double station; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 private Double value; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 private SedimentYieldValue peer; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 public ImportSedimentYieldValue(Double station, Double value) { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 this.station = station; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 this.value = value; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public void storeDependencies(SedimentYield sedimentYield) { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 getPeer(sedimentYield); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 public SedimentYieldValue getPeer(SedimentYield sedimentYield) { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 if (peer == null) { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 Session session = ImporterSession.getInstance().getDatabaseSession(); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 Query query = session.createQuery( |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 "from SedimentYieldValue where " + |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 " sedimentYield=:sedimentYield and " + |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 " station=:station and " + |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 " value=:value" |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 ); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 query.setParameter("sedimentYield", sedimentYield); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 query.setParameter("station", station); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 query.setParameter("value", value); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 List<SedimentYieldValue> values = query.list(); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 if (values.isEmpty()) { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 peer = new SedimentYieldValue(sedimentYield, station, value); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 session.save(peer); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 else { |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 peer = values.get(0); |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 return peer; |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |
75446c47ef77
Added new importer classes for importing sediment yield data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |