# HG changeset patch # User Sascha L. Teichmann # Date 1304422331 0 # Node ID 3a99d029500690a7b99c74136446a0f37695da7a # Parent 73052199f9f6f5e2debc4ae98f3a86eb9a390e74 Importer: Support parsing "zusaetzliche Laengsschnitte". flys-backend/trunk@1801 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 73052199f9f6 -r 3a99d0295006 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Mon May 02 15:58:58 2011 +0000 +++ b/flys-backend/ChangeLog Tue May 03 11:32:11 2011 +0000 @@ -1,3 +1,11 @@ +2011-05-03 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse the "zusaetzliche Laengsschnitte", too. + + * src/main/java/de/intevation/flys/importer/ImportWst.java: + Add getter/setter for column 'kind'. + 2011-05-02 Sascha L. Teichmann * src/main/java/de/intevation/flys/importer/WstParser.java: diff -r 73052199f9f6 -r 3a99d0295006 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon May 02 15:58:58 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Tue May 03 11:32:11 2011 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.importer; import java.util.List; +import java.util.ArrayList; import java.io.File; import java.io.IOException; @@ -20,6 +21,9 @@ public static final String PEGEL_GLT = "PEGEL.GLT"; + public static final String EXTRA_LONGITUDINALS = + "Zus.L\u00e4ngsschnitte"; + protected String name; protected File wstFile; @@ -30,14 +34,18 @@ protected List annotations; + protected List extraWsts; + protected ImportWst wst; protected River peer; public ImportRiver() { + extraWsts = new ArrayList(); } public ImportRiver(String name, File wstFile, File bbInfoFile) { + this(); this.name = name; this.wstFile = wstFile; this.bbInfoFile = bbInfoFile; @@ -79,6 +87,46 @@ parseGauges(); parseAnnotations(); parseWst(); + parseExtraWsts(); + } + + public void parseExtraWsts() throws IOException { + log.info("Parse extra longitudinal wst files"); + + File riverDir = wstFile.getParentFile().getParentFile(); + + File extraDir = FileTools.repair( + new File(riverDir, EXTRA_LONGITUDINALS)); + + if (!extraDir.isDirectory() || !extraDir.canRead()) { + log.info("no extra longitudinal wst file directory found"); + return; + } + + File [] files = extraDir.listFiles(); + + if (files == null) { + log.warn("cannot read extra longitudinal wst file directory"); + return; + } + + for (File file: files) { + if (!file.isFile() || !file.canRead()) { + continue; + } + String name = file.getName().toLowerCase(); + if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { + continue; + } + log.debug("Found WST file: " + file); + + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(1); + extraWsts.add(iw); + } + } public void parseWst() throws IOException { @@ -118,6 +166,7 @@ storeAnnotations(); storeGauges(); storeWst(); + storeExtraWsts(); } public void storeWst() { @@ -125,6 +174,15 @@ wst.storeDependencies(river); } + public void storeExtraWsts() { + log.info("store extra wsts"); + River river = getPeer(); + for (ImportWst wst: extraWsts) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } + } + public void storeAnnotations() { River river = getPeer(); for (ImportAnnotation annotation: annotations) { diff -r 73052199f9f6 -r 3a99d0295006 flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java Mon May 02 15:58:58 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java Tue May 03 11:32:11 2011 +0000 @@ -49,6 +49,15 @@ return description; } + public Integer getKind() { + return kind; + } + + public void setKind(Integer kind) { + this.kind = kind; + } + + public void setDescription(String description) { this.description = description; }