Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 490:13af9318a4a2
Import "Hochwasser-Marken", too.
flys-backend/trunk@1838 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 05 May 2011 14:46:41 +0000 |
parents | a9e9a8a44d19 |
children | 738140fe56fe |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Thu May 05 09:45:13 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Thu May 05 14:46:41 2011 +0000 @@ -33,6 +33,8 @@ public static final String OFFICIAL_LINES = "Amtl_Linien.wst"; + public static final String FLOOD_WATER = "HW-Marken"; + protected String name; protected File wstFile; @@ -49,6 +51,8 @@ protected List<ImportWst> officialLines; + protected List<ImportWst> floodWater; + protected ImportWst wst; protected River peer; @@ -57,6 +61,7 @@ extraWsts = new ArrayList<ImportWst>(); fixations = new ArrayList<ImportWst>(); officialLines = new ArrayList<ImportWst>(); + floodWater = new ArrayList<ImportWst>(); } public ImportRiver(String name, File wstFile, File bbInfoFile) { @@ -105,6 +110,44 @@ parseExtraWsts(); parseFixations(); parseOfficialLines(); + parseFloodWater(); + } + + public void parseFloodWater() throws IOException { + log.info("Parse flood water wst file"); + + File riverDir = wstFile.getParentFile().getParentFile(); + + File dir = FileTools.repair(new File(riverDir, FLOOD_WATER)); + + if (!dir.isDirectory() || !dir.canRead()) { + log.info("no directory '" + dir + "' found"); + return; + } + + File [] files = dir.listFiles(); + + if (files == null) { + log.warn("cannot read '" + dir + "'"); + 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.info("found file '" + file.getName() + "'"); + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(4); + iw.setDescription(FLOOD_WATER + "/" + iw.getDescription()); + floodWater.add(iw); + } } public void parseOfficialLines() throws IOException { @@ -171,7 +214,7 @@ wstParser.parse(file); ImportWst iw = wstParser.getWst(); iw.setKind(2); - iw.setDescription("Fix: " + iw.getDescription()); + iw.setDescription(FIXATIONS+ "/" + iw.getDescription()); fixations.add(iw); } } @@ -255,6 +298,7 @@ storeExtraWsts(); storeFixations(); storeOfficialLines(); + storeFloodWater(); } public void storeWst() { @@ -289,6 +333,15 @@ } } + public void storeFloodWater() { + log.info("store flood water wsts"); + River river = getPeer(); + for (ImportWst wst: floodWater) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } + } + public void storeAnnotations() { River river = getPeer(); for (ImportAnnotation annotation: annotations) {