Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2821:0a536eb5d668
Added parser for parsing morphological widths.
flys-backend/trunk@4238 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 13 Apr 2012 13:22:54 +0000 |
parents | 8979f2294af9 |
children | c3f8cf0cdf69 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri Apr 13 13:05:14 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri Apr 13 13:22:54 2012 +0000 @@ -27,6 +27,7 @@ import de.intevation.flys.importer.parsers.BedHeightSingleParser; import de.intevation.flys.importer.parsers.PRFParser; import de.intevation.flys.importer.parsers.HYKParser; +import de.intevation.flys.importer.parsers.MorphologicalWidthParser; import de.intevation.flys.importer.parsers.AnnotationsParser; import de.intevation.flys.importer.parsers.AnnotationClassifier; import de.intevation.flys.importer.parsers.PegelGltParser; @@ -70,6 +71,8 @@ public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte"; + public static final String MORPHOLOGICAL_WIDTH_DIR = "morphologische_Breite"; + protected String name; @@ -101,6 +104,8 @@ protected List<ImportSedimentDensity> sedimentDensities; + protected List<ImportMorphWidth> morphologicalWidths; + protected ImportWst wst; protected ImportUnit wstUnit; @@ -110,14 +115,15 @@ protected River peer; public ImportRiver() { - hyks = new ArrayList<ImportHYK>(); - crossSections = new ArrayList<ImportCrossSection>(); - extraWsts = new ArrayList<ImportWst>(); - fixations = new ArrayList<ImportWst>(); - officialLines = new ArrayList<ImportWst>(); - floodWater = new ArrayList<ImportWst>(); - floodProtection = new ArrayList<ImportWst>(); - sedimentDensities = new ArrayList<ImportSedimentDensity>(); + hyks = new ArrayList<ImportHYK>(); + crossSections = new ArrayList<ImportCrossSection>(); + extraWsts = new ArrayList<ImportWst>(); + fixations = new ArrayList<ImportWst>(); + officialLines = new ArrayList<ImportWst>(); + floodWater = new ArrayList<ImportWst>(); + floodProtection = new ArrayList<ImportWst>(); + sedimentDensities = new ArrayList<ImportSedimentDensity>(); + morphologicalWidths = new ArrayList<ImportMorphWidth>(); } public ImportRiver( @@ -183,6 +189,7 @@ parseFloodProtection(); parseBedHeight(); parseSedimentDensity(); + parseMorphologicalWidth(); } public void parseFloodProtection() throws IOException { @@ -284,6 +291,36 @@ } + protected void parseMorphologicalWidth() throws IOException { + log.debug("Parse morphological width"); + + if (Config.INSTANCE.skipMorphologicalWidth()) { + log.info("skip parsing morphological width."); + return; + } + + File minfoDir = getMinfoDir(); + File morphDir = new File(minfoDir, MORPHOLOGICAL_WIDTH_DIR); + + File[] files = morphDir.listFiles(); + + if (files == null) { + log.warn("Cannot parse directory '" + morphDir + "'"); + return; + } + + MorphologicalWidthParser parser = new MorphologicalWidthParser(); + + for (File file: files) { + parser.parse(file); + } + + morphologicalWidths = parser.getMorphologicalWidths(); + + log.info("Parsed " + morphologicalWidths.size() + " morph. widths files."); + } + + protected void parseBedHeightSingles(File dir) throws IOException { log.debug("Parse bed height singles"); @@ -650,6 +687,7 @@ storeFloodProtection(); storeBedHeight(); storeSedimentDensity(); + storeMorphologicalWidth(); } public void storeWstUnit() { @@ -836,6 +874,26 @@ } } + public void storeMorphologicalWidth() { + if (!Config.INSTANCE.skipMorphologicalWidth()) { + log.info("store morphological width"); + + River river = getPeer(); + + for (ImportMorphWidth width: morphologicalWidths) { + try { + width.storeDependencies(river); + } + catch (SQLException sqle) { + log.error("Error while parsing file for morph. width."); + } + catch (ConstraintViolationException cve) { + log.error("Error while parsing file for morph. width."); + } + } + } + } + public void storeAnnotations() { if (!Config.INSTANCE.skipAnnotations()) { River river = getPeer();