Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java @ 2817:8979f2294af9
Finished parsing MINFO specific sediment density.
flys-backend/trunk@4234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 13 Apr 2012 11:45:29 +0000 |
parents | 70b4a31a3306 |
children | be9e28cff0c4 |
comparison
equal
deleted
inserted
replaced
2816:70b4a31a3306 | 2817:8979f2294af9 |
---|---|
1 package de.intevation.flys.importer; | 1 package de.intevation.flys.importer; |
2 | 2 |
3 import java.math.BigDecimal; | 3 import java.math.BigDecimal; |
4 | 4 |
5 import java.util.List; | |
6 | |
5 import org.apache.log4j.Logger; | 7 import org.apache.log4j.Logger; |
8 | |
9 import org.hibernate.Session; | |
10 import org.hibernate.Query; | |
6 | 11 |
7 import de.intevation.flys.model.SedimentDensity; | 12 import de.intevation.flys.model.SedimentDensity; |
8 import de.intevation.flys.model.SedimentDensityValue; | 13 import de.intevation.flys.model.SedimentDensityValue; |
9 | 14 |
10 | 15 |
34 } | 39 } |
35 | 40 |
36 | 41 |
37 public void storeDependencies(SedimentDensity sedimentDensity) { | 42 public void storeDependencies(SedimentDensity sedimentDensity) { |
38 log.info("store dependencies"); | 43 log.info("store dependencies"); |
44 | |
45 getPeer(sedimentDensity); | |
39 } | 46 } |
40 | 47 |
41 | 48 |
42 public SedimentDensityValue getPeer(SedimentDensity sedimentDensity) { | 49 public SedimentDensityValue getPeer(SedimentDensity sedimentDensity) { |
43 log.info("get peer"); | 50 log.info("get peer"); |
44 | 51 |
45 return null; | 52 if (peer == null) { |
53 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
54 | |
55 Query query = session.createQuery( | |
56 "from SedimentDensityValue where " + | |
57 " sedimentDensity=:sedimentDensity and " + | |
58 " station=:station and " + | |
59 " density=:density and " + | |
60 " description=:description"); | |
61 | |
62 query.setParameter("sedimentDensity", sedimentDensity); | |
63 query.setParameter("station", station); | |
64 query.setParameter("density", density); | |
65 query.setParameter("description", description); | |
66 | |
67 List<SedimentDensityValue> values = query.list(); | |
68 if (values.isEmpty()) { | |
69 log.debug("Create new SedimentDensityValue DB instance."); | |
70 | |
71 peer = new SedimentDensityValue( | |
72 sedimentDensity, | |
73 station, | |
74 density, | |
75 description); | |
76 | |
77 session.save(peer); | |
78 } | |
79 else { | |
80 peer = values.get(0); | |
81 } | |
82 } | |
83 | |
84 return peer; | |
46 } | 85 } |
47 } | 86 } |
48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |