[Dive4elements-commits] [PATCH 3 of 8] WaterlevelDifferencesParser: In analogy to WaterlevelParser, allow model

Wald Commits scm-commit at wald.intevation.org
Tue Mar 12 09:34:32 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1363010893 -3600
# Node ID 016616df35dc6736f86a4b1fc799e147c3a74b26
# Parent  8320427ecd5c3ba1e474a7da9ee1ff6e775c949c
WaterlevelDifferencesParser: In analogy to WaterlevelParser, allow model
conversion to Wst.

diff -r 8320427ecd5c -r 016616df35dc flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java	Mon Mar 11 15:07:19 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java	Mon Mar 11 15:08:13 2013 +0100
@@ -2,6 +2,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.text.NumberFormat;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -16,7 +17,13 @@
 import de.intevation.flys.importer.ImportWaterlevelDifferenceColumn;
 import de.intevation.flys.importer.ImportWaterlevelDifferenceValue;
 
+import de.intevation.flys.importer.ImportWst;
+import de.intevation.flys.importer.ImportWstColumn;
 
+
+/**
+ * Parse WaterlevelDifferences CSV file.
+ */
 public class WaterlevelDifferencesParser extends LineParser {
 
     private static final Logger log =
@@ -45,6 +52,35 @@
         return differences;
     }
 
+    public List<ImportWst> exportWsts() {
+        List<ImportWst> wsts = new ArrayList<ImportWst>();
+        for(ImportWaterlevelDifference waterlevel: getDifferences()) {
+            String description = waterlevel.getDescription();
+            ImportWst wst = new ImportWst();
+            wsts.add(wst);
+            wst.setDescription(description);
+            // Fixation kind.
+            wst.setKind(7);
+            wst.setUnit(waterlevel.getUnit());
+            wst.setNumberColumns(waterlevel.getColumns().size());
+
+            int i = 0;
+            for (ImportWaterlevelDifferenceColumn wdc: waterlevel.getColumns()) {
+                ImportWstColumn column = wst.getColumn(i);
+                column.setDescription(wdc.getDescription());
+                column.setName(wdc.getDescription());
+                column.setPosition(i);
+                for (ImportWaterlevelDifferenceValue val: wdc.getValues()) {
+                    column.addColumnValue(BigDecimal.valueOf(val.getStation()),
+                        BigDecimal.valueOf(val.getValue()));
+                
+                }
+                i++;
+            }
+        }
+        return wsts;
+    }
+
 
     @Override
     public void parse(File file) throws IOException {


More information about the Dive4elements-commits mailing list