changeset 5510:d4bee6d5c866

merged
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 28 Mar 2013 16:51:32 +0100
parents 627584bc0586 (current diff) c6e552348934 (diff)
children 4e166c514940
files
diffstat 5 files changed, 36 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/doc/schema/oracle-minfo.sql	Thu Mar 28 16:51:15 2013 +0100
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Thu Mar 28 16:51:32 2013 +0100
@@ -137,6 +137,7 @@
     id                  NUMBER(38,0) NOT NULL,
     sediment_density_id NUMBER(38,0) NOT NULL,
     station             NUMBER(38,2) NOT NULL,
+    shore_offset	NUMBER(38,2),
     density             NUMBER(38,2) NOT NULL,
     description         VARCHAR(256),
     year                NUMBER(38,0),
--- a/flys-backend/doc/schema/postgresql-minfo.sql	Thu Mar 28 16:51:15 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-minfo.sql	Thu Mar 28 16:51:32 2013 +0100
@@ -137,6 +137,7 @@
     id                  int NOT NULL,
     sediment_density_id int NOT NULL,
     station             NUMERIC NOT NULL,
+    shore_offset	NUMERIC,
     density             NUMERIC NOT NULL,
     description         VARCHAR(256),
     year                int,
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java	Thu Mar 28 16:51:15 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java	Thu Mar 28 16:51:32 2013 +0100
@@ -23,6 +23,8 @@
 
     protected BigDecimal station;
 
+    protected BigDecimal shoreOffset;
+
     protected BigDecimal density;
 
     private BigDecimal year;
@@ -32,11 +34,13 @@
 
     public ImportSedimentDensityValue(
         BigDecimal station,
+        BigDecimal shoreOffset,
         BigDecimal density,
         BigDecimal year,
         String     description
     ) {
         this.station     = station;
+        this.shoreOffset = shoreOffset;
         this.density     = density;
         this.year        = year;
         this.description = description;
@@ -60,12 +64,14 @@
                 "from SedimentDensityValue where " +
                 "   sedimentDensity=:sedimentDensity and " +
                 "   station=:station and " +
+                "   shoreOffset=:shoreOffset and " +
                 "   density=:density and " +
                 "   year=:year and " +
                 "   description=:description");
 
             query.setParameter("sedimentDensity", sedimentDensity);
             query.setParameter("station", station);
+            query.setParameter("shoreOffset", shoreOffset);
             query.setParameter("density", density);
             query.setParameter("year", year);
             query.setParameter("description", description);
@@ -77,6 +83,7 @@
                 peer = new SedimentDensityValue(
                     sedimentDensity,
                     station,
+                    shoreOffset,
                     density,
                     year,
                     description);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Thu Mar 28 16:51:15 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Thu Mar 28 16:51:32 2013 +0100
@@ -85,27 +85,12 @@
         if (handleMetaDepth(line)) {
             return;
         }
-        else if (handleMetaColumns(line)) {
-            return;
-        }
         else {
             log.warn("Unknown meta line: '" + line + "'");
         }
     }
 
 
-    private boolean handleMetaColumns(String line) {
-        String[] columns = line.split(";");
-        for (int i = 0; i < columns.length; i++) {
-            if (columns[i].contains("Sedimentdichte")) {
-                this.densitsyColumn = i;
-                return true;
-            }
-        }
-        return false;
-    }
-
-
     protected boolean handleMetaDepth(String line) {
         Matcher m = META_DEPTH.matcher(line);
 
@@ -145,40 +130,33 @@
             return;
         }
 
-        BigDecimal km;
-        BigDecimal density;
+        BigDecimal km = null;
+        BigDecimal shoreOffset = null;
+        BigDecimal density = null;
         try {
-            km      = new BigDecimal(nf.parse(vals[0]).doubleValue());
-            density = new BigDecimal(nf.parse(vals[this.densitsyColumn]).doubleValue());
-
+            km          = new BigDecimal(nf.parse(vals[0]).doubleValue());
+            density     = new BigDecimal(nf.parse(vals[2]).doubleValue());
+	    if (!vals[1].isEmpty()) {
+		shoreOffset = new BigDecimal(nf.parse(vals[1]).doubleValue());
+	    }
         }
         catch (ParseException pe) {
             log.warn("Unparseable numbers in '" + line + "'");
-            return;
         }
 
+	if (km == null || density == null) {
+	    log.warn("SDP: No km nor density given. Skip line");
+	    return;
+	}
+
         BigDecimal year = null;
-        try {
-            year =
-                new BigDecimal(nf.parse(vals[vals.length - 1]).doubleValue());
-        }
-        catch(ParseException pe) {
-            try {
-                Date d = DateGuesser.guessDate(vals[vals.length - 1]);
-                Calendar c = Calendar.getInstance();
-                c.setTime(d);
-                year = new BigDecimal(c.get(Calendar.YEAR));
-            }
-            catch (IllegalArgumentException iae) {
-                log.warn("Could not parse date in '" + line + "'");
-            }
-        }
 
         current.addValue(new ImportSedimentDensityValue(
             km,
+	    shoreOffset,
             density,
             year,
-            vals[vals.length - 1])
+	    currentDescription)
         );
     }
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensityValue.java	Thu Mar 28 16:51:15 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensityValue.java	Thu Mar 28 16:51:32 2013 +0100
@@ -23,6 +23,7 @@
     private SedimentDensity sedimentDensity;
 
     private BigDecimal station;
+    private BigDecimal shoreOffset;
     private BigDecimal density;
     private BigDecimal year;
 
@@ -36,12 +37,14 @@
     public SedimentDensityValue(
         SedimentDensity sedimentDensity,
         BigDecimal      station,
+	BigDecimal      shoreOffset,
         BigDecimal      density,
         BigDecimal      year,
         String          desc
     ) {
         this.sedimentDensity = sedimentDensity;
         this.station         = station;
+	this.shoreOffset     = shoreOffset;
         this.density         = density;
         this.year            = year;
         this.description     = desc;
@@ -83,6 +86,15 @@
         this.station = station;
     }
 
+    @Column(name = "shore_offset")
+    public BigDecimal getShoreOffset() {
+        return shoreOffset;
+    }
+
+    public void setShoreOffset(BigDecimal shoreOffset) {
+        this.shoreOffset = shoreOffset;
+    }
+
     @Column(name = "density")
     public BigDecimal getDensity() {
         return density;

http://dive4elements.wald.intevation.org