# HG changeset patch # User Ingo Weinzierl # Date 1335266166 0 # Node ID c4db0f75a94afebf55c97600d473ec87da8631f3 # Parent 6a9f45697f817292c608a13fd7770a75e29e9135 Prepared the importer to import MINFO specific waterlevel values and added a stub for a parser. flys-backend/trunk@4287 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6a9f45697f81 -r c4db0f75a94a flys-backend/ChangeLog --- a/flys-backend/ChangeLog Fri Apr 20 08:16:39 2012 +0000 +++ b/flys-backend/ChangeLog Tue Apr 24 11:16:06 2012 +0000 @@ -1,3 +1,19 @@ +2012-04-24 Ingo Weinzierl + + * doc/schema/oracle-minfo.sql: Small type adaptions in the waterlevel_values + relation. + + * src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java: + First stub of a parser for MINFO specific waterlevel values. + + * src/main/java/de/intevation/flys/importer/Config.java: Added a new config + option to skip parsing MINFO specifc waterlevel_values: + + -Dflys.backend.importer.skip.waterlevels=True + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Added code + path to start parsing and storing MINFO specific waterlevel values. + 2012-04-20 Ingo Weinzierl * src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java, diff -r 6a9f45697f81 -r c4db0f75a94a flys-backend/doc/schema/oracle-minfo.sql --- a/flys-backend/doc/schema/oracle-minfo.sql Fri Apr 20 08:16:39 2012 +0000 +++ b/flys-backend/doc/schema/oracle-minfo.sql Tue Apr 24 11:16:06 2012 +0000 @@ -309,8 +309,8 @@ CREATE TABLE waterlevel_values( id NUMBER(38,0) NOT NULL, waterlevel_q_range_id NUMBER(38,0) NOT NULL, - station NUMBER(38,0) NOT NULL, - w NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + w NUMBER(38,2) NOT NULL, PRIMARY KEY (id), CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id) ); diff -r 6a9f45697f81 -r c4db0f75a94a flys-backend/src/main/java/de/intevation/flys/importer/Config.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Fri Apr 20 08:16:39 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Tue Apr 24 11:16:06 2012 +0000 @@ -59,6 +59,9 @@ public static final String SKIP_SEDIMENT_YIELD = "flys.backend.importer.skip.sediment.yield"; + public static final String SKIP_WATERLEVELS = + "flys.backend.importer.skip.waterlevels"; + public static final Config INSTANCE = new Config(); @@ -140,5 +143,9 @@ public boolean skipSedimentYield() { return Boolean.getBoolean(SKIP_SEDIMENT_YIELD); } + + public boolean skipWaterlevels() { + return Boolean.getBoolean(SKIP_WATERLEVELS); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 6a9f45697f81 -r c4db0f75a94a flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri Apr 20 08:16:39 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Tue Apr 24 11:16:06 2012 +0000 @@ -36,6 +36,7 @@ import de.intevation.flys.importer.parsers.SedimentDensityParser; import de.intevation.flys.importer.parsers.SedimentYieldParser; import de.intevation.flys.importer.parsers.WstParser; +import de.intevation.flys.importer.parsers.WaterlevelParser; import org.hibernate.Session; import org.hibernate.Query; @@ -88,6 +89,10 @@ public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen"; + public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse"; + + public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen"; + protected String name; @@ -127,6 +132,8 @@ protected List sedimentYields; + protected List waterlevels; + protected ImportWst wst; protected ImportUnit wstUnit; @@ -148,6 +155,7 @@ flowVelocityModels = new ArrayList(); flowVelocityMeasurements = new ArrayList(); sedimentYields = new ArrayList(); + waterlevels = new ArrayList(); } public ImportRiver( @@ -216,6 +224,7 @@ parseMorphologicalWidth(); parseFlowVelocity(); parseSedimentYield(); + parseWaterlevels(); } public void parseFloodProtection() throws IOException { @@ -262,8 +271,6 @@ public void parseBedHeight() throws IOException { - log.info("Parse bed height."); - File minfoDir = getMinfoDir(); File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR); File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR); @@ -273,6 +280,7 @@ log.info("skip parsing bed height single."); } else { + log.info("Parse bed height single."); parseBedHeightSingles(singlesDir); } @@ -280,10 +288,9 @@ log.info("skip parsing bed height epochs."); } else { + log.info("Parse bed height epochs."); parseBedHeightEpochs(epochDir); } - - log.info("Finished parsing bed heights."); } @@ -449,6 +456,35 @@ } + protected void parseWaterlevels() throws IOException { + if (Config.INSTANCE.skipWaterlevels()) { + log.info("skip parsing waterlevels"); + return; + } + + File minfo = getMinfoDir(); + File fixDir = new File(minfo, MINFO_FIXATIONS_DIR); + File wspDir = new File(minfo, MINFO_WATERLEVELS_DIR); + + File[] files = wspDir.listFiles(); + + if (files == null) { + log.warn("Cannot read directory '" + wspDir + "'"); + return; + } + + WaterlevelParser parser = new WaterlevelParser(); + + for (File file: files) { + parser.parse(file); + } + + log.info("Parse waterlevels"); + + waterlevels = parser.getWaterlevels(); + } + + protected void parseBedHeightSingles(File dir) throws IOException { log.debug("Parse bed height singles"); @@ -818,6 +854,7 @@ storeMorphologicalWidth(); storeFlowVelocity(); storeSedimentYield(); + storeWaterlevels(); } public void storeWstUnit() { @@ -1077,6 +1114,20 @@ } } + + public void storeWaterlevels() { + if (!Config.INSTANCE.skipWaterlevels()) { + log.info("store waterlevels"); + + River river = getPeer(); + + for (ImportWaterlevel waterlevel: waterlevels) { + waterlevel.storeDependencies(river); + } + } + } + + public void storeAnnotations() { if (!Config.INSTANCE.skipAnnotations()) { River river = getPeer(); diff -r 6a9f45697f81 -r c4db0f75a94a flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Tue Apr 24 11:16:06 2012 +0000 @@ -0,0 +1,37 @@ +package de.intevation.flys.importer.parsers; + +import java.util.List; + +import de.intevation.flys.importer.ImportWaterlevel; + + +public class WaterlevelParser extends LineParser { + + private List waterlevels; + + public WaterlevelParser() { + } + + + public List getWaterlevels() { + return waterlevels; + } + + + @Override + protected void reset() { + + } + + + @Override + protected void finish() { + + } + + @Override + protected void handleLine(String line) { + + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :