Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.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 | 8979f2294af9 |
children | 7c1dd9c3f6bd |
rev | line source |
---|---|
2813
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.importer; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.math.BigDecimal; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
5 import java.util.List; |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
6 |
2813
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
9 import org.hibernate.Session; |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
10 import org.hibernate.Query; |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
11 |
2813
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.model.Depth; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 public class ImportDepth { |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 private static Logger log = Logger.getLogger(ImportDepth.class); |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 protected Depth peer; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 protected BigDecimal lower; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 protected BigDecimal upper; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 protected ImportUnit unit; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public ImportDepth(BigDecimal lower, BigDecimal upper, ImportUnit unit) { |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 this.lower = lower; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 this.upper = upper; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 this.unit = unit; |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 } |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public void storeDependencies() { |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 log.info("store dependencies"); |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
37 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
38 getPeer(); |
2813
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 } |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 public Depth getPeer() { |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 log.info("get peer"); |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
45 if (peer == null) { |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
46 Session session = ImporterSession.getInstance().getDatabaseSession(); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
47 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
48 Query query = session.createQuery( |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
49 "from Depth where " + |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
50 " lower=:lower and " + |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
51 " upper=:upper and " + |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
52 " unit=:unit"); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
53 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
54 query.setParameter("lower", lower); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
55 query.setParameter("upper", upper); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
56 query.setParameter("unit", unit.getPeer()); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
57 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
58 List<Depth> depths = query.list(); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
59 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
60 if (depths.isEmpty()) { |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
61 log.debug("Create new Depth DB instance."); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
62 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
63 peer = new Depth(lower, upper, unit.getPeer()); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
64 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
65 session.save(peer); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
66 } |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
67 else { |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
68 peer = depths.get(0); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
69 } |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
70 } |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
71 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2813
diff
changeset
|
72 return peer; |
2813
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 } |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
f121c0f456ab
Added new importer classes used during MINFO sediment density import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |