# HG changeset patch # User Sascha L. Teichmann # Date 1304430637 0 # Node ID f1fd9cab6a070bc381e3115bd99ed73eb8334329 # Parent 3a99d029500690a7b99c74136446a0f37695da7a Importer: parse and store fixation wst files as well flys-backend/trunk@1805 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3a99d0295006 -r f1fd9cab6a07 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Tue May 03 11:32:11 2011 +0000 +++ b/flys-backend/ChangeLog Tue May 03 13:50:37 2011 +0000 @@ -1,3 +1,8 @@ +2011-05-03 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse and store fixation wst files as well. + 2011-05-03 Sascha L. Teichmann * src/main/java/de/intevation/flys/importer/ImportRiver.java: diff -r 3a99d0295006 -r f1fd9cab6a07 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Tue May 03 11:32:11 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Tue May 03 13:50:37 2011 +0000 @@ -21,6 +21,8 @@ public static final String PEGEL_GLT = "PEGEL.GLT"; + public static final String FIXATIONS = "Fixierungen"; + public static final String EXTRA_LONGITUDINALS = "Zus.L\u00e4ngsschnitte"; @@ -36,12 +38,15 @@ protected List extraWsts; + protected List fixations; + protected ImportWst wst; protected River peer; public ImportRiver() { extraWsts = new ArrayList(); + fixations = new ArrayList(); } public ImportRiver(String name, File wstFile, File bbInfoFile) { @@ -88,6 +93,46 @@ parseAnnotations(); parseWst(); parseExtraWsts(); + parseFixations(); + } + + public void parseFixations() throws IOException { + log.info("Parse fixation wst files"); + + File riverDir = wstFile.getParentFile().getParentFile(); + + File fixDir = FileTools.repair( + new File(riverDir, FIXATIONS)); + + if (!fixDir.isDirectory() || !fixDir.canRead()) { + log.info("no fixation wst file directory found"); + return; + } + + File [] files = fixDir.listFiles(); + + if (files == null) { + log.warn("cannot read fixations wst file directory"); + return; + } + + for (File file: files) { + if (!file.isFile() || !file.canRead()) { + continue; + } + String name = file.getName().toLowerCase(); + if (!name.endsWith(".wst")) { + continue; + } + log.debug("Found WST file: " + file); + + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(2); + iw.setDescription("Fix: " + iw.getDescription()); + fixations.add(iw); + } } public void parseExtraWsts() throws IOException { @@ -167,6 +212,7 @@ storeGauges(); storeWst(); storeExtraWsts(); + storeFixations(); } public void storeWst() { @@ -174,6 +220,15 @@ wst.storeDependencies(river); } + public void storeFixations() { + log.info("store fixation wsts"); + River river = getPeer(); + for (ImportWst wst: fixations) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } + } + public void storeExtraWsts() { log.info("store extra wsts"); River river = getPeer();