Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2839:163c037f2c7e
Added config option to skip parsing sediment yield data and prepared the importer to read/store those data.
flys-backend/trunk@4272 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 19 Apr 2012 07:34:50 +0000 |
parents | ac5bd90697c1 |
children | 71175502d868 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Thu Apr 19 07:15:25 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Thu Apr 19 07:34:50 2012 +0000 @@ -81,6 +81,12 @@ public static final String FLOW_VELOCITY_MEASUREMENTS = "v-Messungen"; + public static final String SEDIMENT_YIELD_DIR = "Fracht"; + + public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre"; + + public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen"; + protected String name; @@ -118,6 +124,8 @@ protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; + protected List<ImportSedimentYield> sedimentYields; + protected ImportWst wst; protected ImportUnit wstUnit; @@ -138,6 +146,7 @@ morphologicalWidths = new ArrayList<ImportMorphWidth>(); flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); + sedimentYields = new ArrayList<ImportSedimentYield>(); } public ImportRiver( @@ -205,6 +214,7 @@ parseSedimentDensity(); parseMorphologicalWidth(); parseFlowVelocity(); + parseSedimentYield(); } public void parseFloodProtection() throws IOException { @@ -383,6 +393,39 @@ } + protected void parseSedimentYield() throws IOException { + log.debug("Parse sediment yield data"); + + if (Config.INSTANCE.skipSedimentYield()) { + log.info("skip parsing sediment yield data"); + return; + } + + File minfoDir = getMinfoDir(); + File sedimentYieldDir = new File(minfoDir, SEDIMENT_YIELD_DIR); + + File singleDir = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR); + File epochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR); + + File[] singles = singleDir.listFiles(); + File[] epochs = epochDir.listFiles(); + + if (singles == null || singles.length == 0) { + log.warn("Cannot parse directory '" + singleDir + "'"); + } + else { + // TODO + } + + if (epochs == null || epochs.length == 0) { + log.warn("Cannot parse directory '" + epochDir + "'"); + } + else { + // TODO + } + } + + protected void parseBedHeightSingles(File dir) throws IOException { log.debug("Parse bed height singles"); @@ -751,6 +794,7 @@ storeSedimentDensity(); storeMorphologicalWidth(); storeFlowVelocity(); + storeSedimentYield(); } public void storeWstUnit() { @@ -989,6 +1033,27 @@ } } + + public void storeSedimentYield() { + if (!Config.INSTANCE.skipSedimentYield()) { + log.info("store sediment yield data"); + + River river = getPeer(); + + for (ImportSedimentYield sedimentYield: sedimentYields) { + try { + sedimentYield.storeDependencies(river); + } + catch (SQLException sqle) { + log.error("Error while storing sediment yield.", sqle); + } + catch (ConstraintViolationException cve) { + log.error("Error while storing sediment yield.", cve); + } + } + } + } + public void storeAnnotations() { if (!Config.INSTANCE.skipAnnotations()) { River river = getPeer();