Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadLSValue.java @ 9038:4c5eeaff554c
Database column "comment" renamed to "notes" (restrictions in Oracle)
author | mschaefer |
---|---|
date | Wed, 02 May 2018 06:56:21 +0200 |
parents | 392bbcd8a88b |
children |
rev | line source |
---|---|
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.importer; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.List; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
13 import org.dive4elements.river.importer.common.StoreMode; |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import org.dive4elements.river.model.SedimentLoadLS; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.dive4elements.river.model.SedimentLoadLSValue; |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
16 import org.hibernate.Query; |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
17 import org.hibernate.Session; |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 public class ImportSedimentLoadLSValue { |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
22 private final Double station; |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
23 private final Double value; |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 private SedimentLoadLSValue peer; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
28 public ImportSedimentLoadLSValue(final Double station, final Double value) { |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 this.station = station; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 this.value = value; |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
34 public void storeDependencies(final SedimentLoadLS sedimentLoadLS, final StoreMode parentStoreMode) { |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
35 getPeer(sedimentLoadLS, parentStoreMode); |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
39 public SedimentLoadLSValue getPeer(final SedimentLoadLS sedimentLoadLS, final StoreMode parentStoreMode) { |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
40 if (this.peer == null) { |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
41 List<SedimentLoadLSValue> values; |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
42 final Session session = ImporterSession.getInstance().getDatabaseSession(); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
43 if (parentStoreMode == StoreMode.INSERT) |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
44 values = null; |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
45 else { |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
46 final Query query = session.createQuery( |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
47 "from SedimentLoadLSValue where " + |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
48 " sedimentLoadLS=:sedimentLoadLS and " + |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
49 " station=:station and " + |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
50 " value=:value" |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
51 ); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
52 query.setParameter("sedimentLoadLS", sedimentLoadLS); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
53 query.setParameter("station", this.station); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
54 query.setParameter("value", this.value); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
55 values = query.list(); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
56 } |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
57 if ((values == null) || values.isEmpty()) { |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
58 this.peer = new SedimentLoadLSValue(sedimentLoadLS, this.station, this.value); |
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
59 session.save(this.peer); |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 else { |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
62 this.peer = values.get(0); |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 |
8986
392bbcd8a88b
Database inserts accelerated by suppressing unnecessary database queries for new data series
mschaefer
parents:
8856
diff
changeset
|
66 return this.peer; |
8025
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
c915e99d9e52
Renamed SedimentYield to SedimentLoadLS and SedimentYieldValue to SedimentLoadLSValue. Adjust the names of the parsers and the rest of the glue.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |