diff 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
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/uinfo/VegetationType.java	Mon Mar 23 15:40:12 2020 +0100
+++ b/backend/src/main/java/org/dive4elements/river/model/uinfo/VegetationType.java	Mon Mar 23 16:38:12 2020 +0100
@@ -13,6 +13,7 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
@@ -41,6 +42,7 @@
 
     private String  name;
 
+    private String de_name;
 
     /***** CONSTRUCTORS *****/
 
@@ -72,12 +74,37 @@
         this.name = name;
     }
 
+    @Column(name = "de_name")
+    public String getDe_name() {
+        return this.de_name;
+    }
+
+    public void setDe_name(final String de_name) {
+        this.de_name = de_name;
+    }
+
     /**
      * Queries all vegetation types from the database, ordered by id
      */
     public static List<VegetationType> getTypes() {
-        final Session session = SessionHolder.HOLDER.get();
+        return getTypes(SessionHolder.HOLDER.get());
+    }
+
+    /**
+     * Queries all vegetation types from the database, ordered by id
+     */
+    public static List<VegetationType> getTypes(final Session session) {
         final Query query = session.createQuery("FROM VegetationType ORDER BY id");
         return new ArrayList<>(query.list());
     }
+
+    /**
+     * Localized name of the vegetation type
+     */
+    public String getLocalizedName(final Locale locale) {
+        if ((locale == Locale.GERMAN) || (locale == Locale.GERMANY))
+            return getDe_name();
+        else
+            return getName();
+    }
 }

http://dive4elements.wald.intevation.org