annotate backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadValue.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents e8d2042c9639
children 392bbcd8a88b
rev   line source
8841
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
1 /* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
2 * Software engineering by Intevation GmbH
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
3 *
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
6 * documentation coming with Dive4Elements River for details.
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
7 */
e8d2042c9639 Add missing copyright headers.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
8
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.importer;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
10
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
11 import java.util.List;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
12
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
13 import org.dive4elements.river.model.MeasurementStation;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
14 import org.dive4elements.river.model.SedimentLoad;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
15 import org.dive4elements.river.model.SedimentLoadValue;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
16 import org.hibernate.Query;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
17 import org.hibernate.Session;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
18
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
19 public class ImportSedimentLoadValue {
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
20
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
21 private SedimentLoadValue peer;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
22
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
23 private MeasurementStation station;
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
24 private Double value;
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
25
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
26 public ImportSedimentLoadValue() {
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
27 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
28
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
29 public ImportSedimentLoadValue(
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
30 MeasurementStation station,
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
31 Double value
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
32 ) {
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
33 this.station = station;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
34 this.value = value;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
35 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
36
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
37 protected SedimentLoadValue getPeer(SedimentLoad sedimentLoad) {
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
38
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
39 if (peer == null) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8841
diff changeset
40 Session session = ImporterSession.getInstance()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8841
diff changeset
41 .getDatabaseSession();
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
42 Query query = session.createQuery(
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
43 "from SedimentLoadValue where " +
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
44 " measurementStation = :station and " +
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
45 " sedimentLoad = :sedimentLoad and " +
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
46 " value = :value");
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
47
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
48 query.setParameter("station", station);
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
49 query.setParameter("sedimentLoad", sedimentLoad);
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
50 query.setParameter("value", value);
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
51
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
52 List<SedimentLoadValue> values = query.list();
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
53 if (values.isEmpty()) {
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
54 peer = new SedimentLoadValue(sedimentLoad, station, value);
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
55 session.save(peer);
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
56 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
57 else {
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
58 peer = values.get(0);
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
59 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
60 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
61
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
62 return peer;
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
63 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
64
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
65 public void storeDependencies(SedimentLoad sedimentLoad) {
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8028
diff changeset
66 getPeer(sedimentLoad);
8028
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
67 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
68 }
aa054f72e887 Added importer models for sediment load and sediment load values.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
69 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org