Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 1223:268f8da412e3
Importer: Added a central configuration to allow skipping of parsing/storing individual sub systems.
flys-backend/trunk@2354 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 18 Jul 2011 15:52:42 +0000 |
parents | 979ff070e368 |
children | c5c48f52dc7b |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Jul 18 09:06:40 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Jul 18 15:52:42 2011 +0000 @@ -152,6 +152,11 @@ } public void parseFloodProtection() throws IOException { + if (Config.INSTANCE.skipFloodProtection()) { + log.info("skip parsing flood protection"); + return; + } + log.info("Parse flood protection wst file"); File riverDir = wstFile.getParentFile().getParentFile(); @@ -189,6 +194,11 @@ } public void parseFloodWater() throws IOException { + if (Config.INSTANCE.skipFloodWater()) { + log.info("skip parsing flod water"); + return; + } + log.info("Parse flood water wst file"); File riverDir = wstFile.getParentFile().getParentFile(); @@ -226,6 +236,11 @@ } public void parseOfficialLines() throws IOException { + if (Config.INSTANCE.skipOfficialLines()) { + log.info("skip parsing official lines"); + return; + } + log.info("Parse official wst files"); File riverDir = wstFile.getParentFile().getParentFile(); @@ -256,6 +271,11 @@ } public void parseFixations() throws IOException { + if (Config.INSTANCE.skipFixations()) { + log.info("skip parsing fixations"); + return; + } + log.info("Parse fixation wst files"); File riverDir = wstFile.getParentFile().getParentFile(); @@ -295,6 +315,11 @@ } public void parseExtraWsts() throws IOException { + if (Config.INSTANCE.skipExtraWsts()) { + log.info("skip parsing extra WST files"); + return; + } + log.info("Parse extra longitudinal wst files"); File riverDir = wstFile.getParentFile().getParentFile(); @@ -335,12 +360,22 @@ } public void parseWst() throws IOException { + if (Config.INSTANCE.skipWst()) { + log.info("skip parsing WST file"); + return; + } + WstParser wstParser = new WstParser(); wstParser.parse(wstFile); wst = wstParser.getWst(); } public void parseGauges() throws IOException { + if (Config.INSTANCE.skipGauges()) { + log.info("skip parsing gauges"); + return; + } + File gltFile = new File(wstFile.getParentFile(), PEGEL_GLT); gltFile = FileTools.repair(gltFile); @@ -360,6 +395,11 @@ } public void parseAnnotations() throws IOException { + if (Config.INSTANCE.skipAnnotations()) { + log.info("skip parsing annotations"); + return; + } + File riverDir = wstFile.getParentFile().getParentFile(); AnnotationsParser aparser = new AnnotationsParser(annotationClassifier); @@ -369,6 +409,11 @@ } public void parseHYKs() { + if (Config.INSTANCE.skipHYKs()) { + log.info("skip parsing HYK files"); + return; + } + log.info("looking for HYK files"); HYKParser parser = new HYKParser(); File riverDir = wstFile @@ -401,6 +446,11 @@ } public void parsePRFs() { + if (Config.INSTANCE.skipPRFs()) { + log.info("skip parsing PRFs"); + return; + } + log.info("looking for PRF files"); PRFParser parser = new PRFParser(); File riverDir = wstFile @@ -469,86 +519,108 @@ } public void storeHYKs() { - log.info("store HYKs"); - getPeer(); - for (ImportHYK hyk: hyks) { - hyk.storeDependencies(); + if (!Config.INSTANCE.skipHYKs()) { + log.info("store HYKs"); + getPeer(); + for (ImportHYK hyk: hyks) { + hyk.storeDependencies(); + } } } public void storeCrossSections() { - log.info("store cross sections"); - for (ImportCrossSection crossSection: crossSections) { - crossSection.storeDependencies(); + if (!Config.INSTANCE.skipPRFs()) { + log.info("store cross sections"); + getPeer(); + for (ImportCrossSection crossSection: crossSections) { + crossSection.storeDependencies(); + } } } public void storeWst() { - River river = getPeer(); - wst.storeDependencies(river); - } - - public void storeFixations() { - log.info("store fixation wsts"); - River river = getPeer(); - for (ImportWst wst: fixations) { - log.debug("name: " + wst.getDescription()); + if (!Config.INSTANCE.skipWst()) { + River river = getPeer(); wst.storeDependencies(river); } } + public void storeFixations() { + if (!Config.INSTANCE.skipFixations()) { + 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(); - for (ImportWst wst: extraWsts) { - log.debug("name: " + wst.getDescription()); - wst.storeDependencies(river); + if (!Config.INSTANCE.skipExtraWsts()) { + log.info("store extra wsts"); + River river = getPeer(); + for (ImportWst wst: extraWsts) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } } } public void storeOfficialLines() { - log.info("store official lines wsts"); - River river = getPeer(); - for (ImportWst wst: officialLines) { - log.debug("name: " + wst.getDescription()); - wst.storeDependencies(river); + if (!Config.INSTANCE.skipOfficialLines()) { + log.info("store official lines wsts"); + River river = getPeer(); + for (ImportWst wst: officialLines) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } } } public void storeFloodWater() { - log.info("store flood water wsts"); - River river = getPeer(); - for (ImportWst wst: floodWater) { - log.debug("name: " + wst.getDescription()); - wst.storeDependencies(river); + if (!Config.INSTANCE.skipFloodWater()) { + log.info("store flood water wsts"); + River river = getPeer(); + for (ImportWst wst: floodWater) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } } } public void storeFloodProtection() { - log.info("store flood protection wsts"); - River river = getPeer(); - for (ImportWst wst: floodProtection) { - log.debug("name: " + wst.getDescription()); - wst.storeDependencies(river); + if (!Config.INSTANCE.skipFloodProtection()) { + log.info("store flood protection wsts"); + River river = getPeer(); + for (ImportWst wst: floodProtection) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } } } public void storeAnnotations() { - River river = getPeer(); - for (ImportAnnotation annotation: annotations) { - annotation.getPeer(river); + if (!Config.INSTANCE.skipAnnotations()) { + River river = getPeer(); + for (ImportAnnotation annotation: annotations) { + annotation.getPeer(river); + } } } public void storeGauges() { - log.info("store gauges:"); - River river = getPeer(); - Session session = ImporterSession.getInstance().getDatabaseSession(); - for (ImportGauge gauge: gauges) { - log.info("\tgauge: " + gauge.getName()); - gauge.storeDependencies(river); - ImporterSession.getInstance().getDatabaseSession(); - session.flush(); + if (!Config.INSTANCE.skipGauges()) { + log.info("store gauges:"); + River river = getPeer(); + Session session = ImporterSession.getInstance() + .getDatabaseSession(); + for (ImportGauge gauge: gauges) { + log.info("\tgauge: " + gauge.getName()); + gauge.storeDependencies(river); + ImporterSession.getInstance().getDatabaseSession(); + session.flush(); + } } }