Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9660:f0cad5212f49 | 9661:9b8ba3b83a15 |
---|---|
11 package org.dive4elements.river.model.uinfo; | 11 package org.dive4elements.river.model.uinfo; |
12 | 12 |
13 import java.io.Serializable; | 13 import java.io.Serializable; |
14 import java.util.ArrayList; | 14 import java.util.ArrayList; |
15 import java.util.List; | 15 import java.util.List; |
16 import java.util.Locale; | |
16 | 17 |
17 import javax.persistence.Column; | 18 import javax.persistence.Column; |
18 import javax.persistence.Entity; | 19 import javax.persistence.Entity; |
19 import javax.persistence.Id; | 20 import javax.persistence.Id; |
20 import javax.persistence.Table; | 21 import javax.persistence.Table; |
39 | 40 |
40 private Integer id; | 41 private Integer id; |
41 | 42 |
42 private String name; | 43 private String name; |
43 | 44 |
45 private String de_name; | |
44 | 46 |
45 /***** CONSTRUCTORS *****/ | 47 /***** CONSTRUCTORS *****/ |
46 | 48 |
47 public VegetationType() { | 49 public VegetationType() { |
48 } | 50 } |
70 | 72 |
71 public void setName(final String name) { | 73 public void setName(final String name) { |
72 this.name = name; | 74 this.name = name; |
73 } | 75 } |
74 | 76 |
77 @Column(name = "de_name") | |
78 public String getDe_name() { | |
79 return this.de_name; | |
80 } | |
81 | |
82 public void setDe_name(final String de_name) { | |
83 this.de_name = de_name; | |
84 } | |
85 | |
75 /** | 86 /** |
76 * Queries all vegetation types from the database, ordered by id | 87 * Queries all vegetation types from the database, ordered by id |
77 */ | 88 */ |
78 public static List<VegetationType> getTypes() { | 89 public static List<VegetationType> getTypes() { |
79 final Session session = SessionHolder.HOLDER.get(); | 90 return getTypes(SessionHolder.HOLDER.get()); |
91 } | |
92 | |
93 /** | |
94 * Queries all vegetation types from the database, ordered by id | |
95 */ | |
96 public static List<VegetationType> getTypes(final Session session) { | |
80 final Query query = session.createQuery("FROM VegetationType ORDER BY id"); | 97 final Query query = session.createQuery("FROM VegetationType ORDER BY id"); |
81 return new ArrayList<>(query.list()); | 98 return new ArrayList<>(query.list()); |
82 } | 99 } |
100 | |
101 /** | |
102 * Localized name of the vegetation type | |
103 */ | |
104 public String getLocalizedName(final Locale locale) { | |
105 if ((locale == Locale.GERMAN) || (locale == Locale.GERMANY)) | |
106 return getDe_name(); | |
107 else | |
108 return getName(); | |
109 } | |
83 } | 110 } |