Mercurial > dive4elements > river
changeset 483:f1fd9cab6a07
Importer: parse and store fixation wst files as well
flys-backend/trunk@1805 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 May 2011 13:50:37 +0000 |
parents | 3a99d0295006 |
children | a9e9a8a44d19 |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java |
diffstat | 2 files changed, 60 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse and store fixation wst files as well. + 2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> * 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<ImportWst> extraWsts; + protected List<ImportWst> fixations; + protected ImportWst wst; protected River peer; public ImportRiver() { extraWsts = new ArrayList<ImportWst>(); + fixations = new ArrayList<ImportWst>(); } 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();