comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/DepthEvolutionKmLineImport.java @ 8971:50416a0df385

Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
author mschaefer
date Tue, 03 Apr 2018 10:18:30 +0200
parents
children
comparison
equal deleted inserted replaced
8970:da5dc7446652 8971:50416a0df385
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.importer.sinfo.importitem;
12
13 import java.util.List;
14
15 import org.dive4elements.river.importer.common.AbstractKmLineImport;
16 import org.dive4elements.river.model.sinfo.DepthEvolution;
17 import org.dive4elements.river.model.sinfo.DepthEvolutionValue;
18 import org.hibernate.Query;
19 import org.hibernate.Session;
20
21 /**
22 * Imported depth evolution values of a river station.
23 *
24 * @author Matthias Schäfer
25 *
26 */
27 public class DepthEvolutionKmLineImport extends AbstractKmLineImport<DepthEvolution, DepthEvolutionValue> {
28
29 /***** FIELDS *****/
30
31 private double total_change;
32
33 private double change_per_year;
34
35
36 /***** CONSTRUCTOR *****/
37
38 public DepthEvolutionKmLineImport(final Double km, final double total_change, final double change_per_year) {
39 super(km.doubleValue());
40 this.total_change = total_change;
41 this.change_per_year = change_per_year;
42 }
43
44 /***** METHODS *****/
45
46 public void setTotal_change(final double total_change) {
47 this.total_change = total_change;
48 }
49
50 public void setChange_per_year(final double change_per_year) {
51 this.change_per_year = change_per_year;
52 }
53
54 @Override
55 protected DepthEvolutionValue queryValueItem(final Session session, final DepthEvolution parent) {
56 final Query query = session.createQuery("FROM DepthEvolutionValue WHERE (DepthEvolution=:parent) AND (station=:station)");
57 query.setParameter("parent", parent);
58 query.setParameter("station", this.station);
59 final List rows = query.list();
60 if (!rows.isEmpty())
61 return (DepthEvolutionValue) rows.get(0);
62 else
63 return null;
64 }
65
66
67 @Override
68 protected DepthEvolutionValue createValueItem(final DepthEvolution parent) {
69 return new DepthEvolutionValue(parent, this.station, this.total_change, this.change_per_year);
70 }
71 }

http://dive4elements.wald.intevation.org