changeset 1224:ca7d461a53f1

HYK importer: Various small fixes and some extra logging. flys-backend/trunk@2355 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 18 Jul 2011 16:43:27 +0000
parents 268f8da412e3
children d859c4bc6ace
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportHYK.java flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKEntry.java flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKFormation.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/HYKParser.java flys-backend/src/main/java/de/intevation/flys/model/HYK.java
diffstat 6 files changed, 49 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/ChangeLog	Mon Jul 18 16:43:27 2011 +0000
@@ -1,3 +1,12 @@
+2011-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/HYK.java
+	  src/main/java/de/intevation/flys/importer/parsers/HYKParser.java,
+	  src/main/java/de/intevation/flys/importer/ImportHYKFormation.java,
+	  src/main/java/de/intevation/flys/importer/ImportHYKEntry.java,
+	  src/main/java/de/intevation/flys/importer/ImportHYK.java:
+	  Various small fixes and some extra logging.
+
 2011-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/Config.java: New.
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYK.java	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYK.java	Mon Jul 18 16:43:27 2011 +0000
@@ -9,8 +9,12 @@
 import org.hibernate.Session;
 import org.hibernate.Query;
 
+import org.apache.log4j.Logger;
+
 public class ImportHYK
 {
+    private static Logger log = Logger.getLogger(ImportHYK.class);
+
     protected ImportRiver river;
     protected String      description;
 
@@ -42,8 +46,12 @@
     }
 
     public void storeDependencies() {
+        log.info("store HYK '" + description + "'");
         getPeer();
-        for (ImportHYKEntry entry: entries) {
+        for (int i = 0, N = entries.size(); i < N; ++i) {
+            ImportHYKEntry entry = entries.get(i);
+            log.info("  store km " + entry.getKm() +
+                " (" + (i+1) + " of " + N + ")");
             entry.storeDependencies();
         }
     }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKEntry.java	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKEntry.java	Mon Jul 18 16:43:27 2011 +0000
@@ -31,6 +31,7 @@
         BigDecimal km,
         Date       measure
     ) {
+        this();
         this.hyk     = hyk;
         this.km      = km;
         this.measure = measure;
@@ -44,6 +45,14 @@
         this.hyk = hyk;
     }
 
+    public BigDecimal getKm() {
+        return km;
+    }
+
+    public void setKm(BigDecimal km) {
+        this.km = km;
+    }
+
     public void addFormation(ImportHYKFormation formation) {
         int numFormation = formations.size();
         formations.add(formation);
@@ -64,7 +73,7 @@
             Session session = ImporterSession.getInstance()
                 .getDatabaseSession();
             Query query = session.createQuery(
-                "from HYKEntry where hyk=:hyk " +
+                "from HYKEntry where HYK=:hyk " +
                 "and km=:km and measure=:measure");
             query.setParameter("hyk", h);
             query.setParameter("km", km);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKFormation.java	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKFormation.java	Mon Jul 18 16:43:27 2011 +0000
@@ -69,6 +69,22 @@
         this.entry = entry;
     }
 
+    public BigDecimal getTop() {
+        return top;
+    }
+
+    public void setTop(BigDecimal top) {
+        this.top = top;
+    }
+
+    public BigDecimal getBottom() {
+        return bottom;
+    }
+
+    public void setBottom(BigDecimal bottom) {
+        this.bottom = bottom;
+    }
+
     public BigDecimal getDistanceVL() {
         return distanceVL;
     }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/HYKParser.java	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/HYKParser.java	Mon Jul 18 16:43:27 2011 +0000
@@ -179,7 +179,9 @@
                             return false;
                         }
                         formation = new ImportHYKFormation();
-                        formation.setEntry(entry);
+                        formation.setBottom(bottom);
+                        formation.setTop(top);
+                        entry.addFormation(formation);
 
                         state = State.LINE_3;
                         break;
@@ -255,7 +257,7 @@
                         try {
                             distanceVL = new BigDecimal(parts[0]);
                             distanceHF = new BigDecimal(parts[1]);
-                            distanceVL = new BigDecimal(parts[2]);
+                            distanceVR = new BigDecimal(parts[2]);
                         }
                         catch (NumberFormatException nfe) {
                             log.error("cannot parse number in line " +
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Mon Jul 18 15:52:42 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Mon Jul 18 16:43:27 2011 +0000
@@ -62,7 +62,7 @@
         this.river = river;
     }
 
-    @Column(name = "name")
+    @Column(name = "description")
     public String getDescription() {
         return description;
     }

http://dive4elements.wald.intevation.org