comparison backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadLSValue.java @ 8025:c915e99d9e52

Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 09 Jul 2014 18:13:13 +0200
parents
children fd3a24336e6a
comparison
equal deleted inserted replaced
8024:963ede7b32bb 8025:c915e99d9e52
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.importer;
10
11 import java.util.List;
12
13 import org.hibernate.Session;
14 import org.hibernate.Query;
15
16 import org.dive4elements.river.model.SedimentLoadLS;
17 import org.dive4elements.river.model.SedimentLoadLSValue;
18
19
20 public class ImportSedimentLoadLSValue {
21
22 private Double station;
23 private Double value;
24
25 private SedimentLoadLSValue peer;
26
27
28 public ImportSedimentLoadLSValue(Double station, Double value) {
29 this.station = station;
30 this.value = value;
31 }
32
33
34 public void storeDependencies(SedimentLoadLS sedimentYield) {
35 getPeer(sedimentYield);
36 }
37
38
39 public SedimentLoadLSValue getPeer(SedimentLoadLS sedimentYield) {
40 if (peer == null) {
41 Session session = ImporterSession.getInstance().getDatabaseSession();
42 Query query = session.createQuery(
43 "from SedimentYieldValue where " +
44 " sedimentYield=:sedimentYield and " +
45 " station=:station and " +
46 " value=:value"
47 );
48
49 query.setParameter("sedimentYield", sedimentYield);
50 query.setParameter("station", station);
51 query.setParameter("value", value);
52
53 List<SedimentLoadLSValue> values = query.list();
54 if (values.isEmpty()) {
55 peer = new SedimentLoadLSValue(sedimentYield, station, value);
56 session.save(peer);
57 }
58 else {
59 peer = values.get(0);
60 }
61 }
62
63 return peer;
64 }
65 }
66 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org