# HG changeset patch # User Felix Wolfsteller # 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 exportWsts() { + List wsts = new ArrayList(); + 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 {