Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/model/uinfo/VegetationType.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 | 361de818f76e |
children |
rev | line source |
---|---|
9014 | 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.model.uinfo; | |
12 | |
13 import java.io.Serializable; | |
14 import java.util.ArrayList; | |
15 import java.util.List; | |
9661
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
16 import java.util.Locale; |
9014 | 17 |
18 import javax.persistence.Column; | |
19 import javax.persistence.Entity; | |
20 import javax.persistence.Id; | |
21 import javax.persistence.Table; | |
22 | |
23 import org.dive4elements.river.backend.SessionHolder; | |
24 import org.hibernate.Query; | |
25 import org.hibernate.Session; | |
26 | |
27 /** | |
28 * Hibernate binding for the DB table vegetation_type | |
29 * | |
30 * @author Matthias Schäfer | |
31 * | |
32 */ | |
33 @Entity | |
34 @Table(name = "vegetation_type") | |
35 public class VegetationType implements Serializable { | |
36 | |
37 /***** FIELDS *****/ | |
38 | |
39 private static final long serialVersionUID = -845317173014273709L; | |
40 | |
41 private Integer id; | |
42 | |
43 private String name; | |
44 | |
9661
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
45 private String de_name; |
9014 | 46 |
47 /***** CONSTRUCTORS *****/ | |
48 | |
49 public VegetationType() { | |
50 } | |
51 | |
52 public VegetationType(final String name) { | |
53 this.name = name; | |
54 } | |
55 | |
56 /***** METHODS *****/ | |
57 | |
58 @Id | |
59 @Column(name = "id") | |
60 public Integer getId() { | |
61 return this.id; | |
62 } | |
63 | |
64 public void setId(final Integer id) { | |
65 this.id = id; | |
66 } | |
67 | |
68 @Column(name = "name") | |
69 public String getName() { | |
70 return this.name; | |
71 } | |
72 | |
73 public void setName(final String name) { | |
74 this.name = name; | |
75 } | |
9401
361de818f76e
Added color fields to the vegetation zone database table and importer, max days field changed from exclusive to inclusive
mschaefer
parents:
9014
diff
changeset
|
76 |
9661
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
77 @Column(name = "de_name") |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
78 public String getDe_name() { |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
79 return this.de_name; |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
80 } |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
81 |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
82 public void setDe_name(final String de_name) { |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
83 this.de_name = de_name; |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
84 } |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
85 |
9014 | 86 /** |
9401
361de818f76e
Added color fields to the vegetation zone database table and importer, max days field changed from exclusive to inclusive
mschaefer
parents:
9014
diff
changeset
|
87 * Queries all vegetation types from the database, ordered by id |
9014 | 88 */ |
89 public static List<VegetationType> getTypes() { | |
9661
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
90 return getTypes(SessionHolder.HOLDER.get()); |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
91 } |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
92 |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
93 /** |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
94 * Queries all vegetation types from the database, ordered by id |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
95 */ |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
96 public static List<VegetationType> getTypes(final Session session) { |
9014 | 97 final Query query = session.createQuery("FROM VegetationType ORDER BY id"); |
98 return new ArrayList<>(query.list()); | |
99 } | |
9661
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
100 |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
101 /** |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
102 * Localized name of the vegetation type |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
103 */ |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
104 public String getLocalizedName(final Locale locale) { |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
105 if ((locale == Locale.GERMAN) || (locale == Locale.GERMANY)) |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
106 return getDe_name(); |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
107 else |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
108 return getName(); |
9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
mschaefer
parents:
9401
diff
changeset
|
109 } |
9014 | 110 } |