annotate backend/src/main/java/org/dive4elements/river/importer/uinfo/importitem/VegetationSeriesImport.java @ 9661:9b8ba3b83a15

Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name, localized vegetation type names by querying the database instead of translating by resource property, detecting and cancelling the import of a second vegetation zone file for a river, detecting, logging, cancelling in case of wrong column titles, detecting, logging and ignoring lines with missing (color) values, comparing vegetation zone name and class with the database and logging+ignoring in case of inconsistencies, starting the most elevated zone with 0 instead of -1 overflow days
author mschaefer
date Mon, 23 Mar 2020 16:38:12 +0100
parents 4c5eeaff554c
children
rev   line source
9014
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
2 * Software engineering by
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
5 *
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
9 */
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
10
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
11 package org.dive4elements.river.importer.uinfo.importitem;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
12
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
13 import java.util.List;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
14
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
15 import org.apache.log4j.Logger;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
16 import org.dive4elements.river.importer.common.AbstractSeriesImport;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
17 import org.dive4elements.river.model.River;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
18 import org.dive4elements.river.model.uinfo.Vegetation;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
19 import org.dive4elements.river.model.uinfo.VegetationZone;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
20 import org.hibernate.Query;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
21 import org.hibernate.Session;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
22
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
23 /**
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
24 * Imported vegetation data series of a river
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
25 *
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
26 * @author Matthias Schäfer
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
27 *
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
28 */
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
29 public class VegetationSeriesImport extends AbstractSeriesImport<Vegetation, VegetationZone, VegetationZoneImport> {
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
30
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
31 /***** FIELDS *****/
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
32
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
33 private static Logger log = Logger.getLogger(VegetationSeriesImport.class);
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
34
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
35 private String name;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
36
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
37
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
38 /***** CONSTRUCTORS *****/
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
39
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
40 public VegetationSeriesImport(final String filename) {
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
41 super(filename);
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
42 }
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
43
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
44
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
45 /***** METHODS *****/
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
46
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
47 public void setName(final String name) {
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
48 this.name = name;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
49 }
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
50
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
51 @Override
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
52 public Logger getLog() {
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
53 return log;
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
54 }
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
55
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
56 @Override
9661
9b8ba3b83a15 Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents: 9038
diff changeset
57 public List<Vegetation> querySeriesItem(final Session session, final River river, final boolean doQueryParent) {
9b8ba3b83a15 Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents: 9038
diff changeset
58 final Query query = session.createQuery("FROM Vegetation WHERE river=:river");
9014
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
59 query.setParameter("river", river);
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
60 return query.list();
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
61 }
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
62
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
63
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
64 @Override
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
65 public Vegetation createSeriesItem(final River river) {
9038
4c5eeaff554c Database column "comment" renamed to "notes" (restrictions in Oracle)
mschaefer
parents: 9014
diff changeset
66 return new Vegetation(river, this.filename, this.name, this.notes);
9014
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
67 }
201817aa7b1c Added the missing vegetation import classes
mschaefer
parents:
diff changeset
68 }

http://dive4elements.wald.intevation.org