comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2844:c4db0f75a94a

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
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 24 Apr 2012 11:16:06 +0000
parents 71175502d868
children a65b5b0ade6f
comparison
equal deleted inserted replaced
2843:6a9f45697f81 2844:c4db0f75a94a
34 import de.intevation.flys.importer.parsers.AnnotationClassifier; 34 import de.intevation.flys.importer.parsers.AnnotationClassifier;
35 import de.intevation.flys.importer.parsers.PegelGltParser; 35 import de.intevation.flys.importer.parsers.PegelGltParser;
36 import de.intevation.flys.importer.parsers.SedimentDensityParser; 36 import de.intevation.flys.importer.parsers.SedimentDensityParser;
37 import de.intevation.flys.importer.parsers.SedimentYieldParser; 37 import de.intevation.flys.importer.parsers.SedimentYieldParser;
38 import de.intevation.flys.importer.parsers.WstParser; 38 import de.intevation.flys.importer.parsers.WstParser;
39 import de.intevation.flys.importer.parsers.WaterlevelParser;
39 40
40 import org.hibernate.Session; 41 import org.hibernate.Session;
41 import org.hibernate.Query; 42 import org.hibernate.Query;
42 import org.hibernate.exception.ConstraintViolationException; 43 import org.hibernate.exception.ConstraintViolationException;
43 44
86 87
87 public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre"; 88 public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre";
88 89
89 public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen"; 90 public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen";
90 91
92 public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse";
93
94 public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen";
95
91 96
92 protected String name; 97 protected String name;
93 98
94 protected File wstFile; 99 protected File wstFile;
95 100
124 protected List<ImportFlowVelocityModel> flowVelocityModels; 129 protected List<ImportFlowVelocityModel> flowVelocityModels;
125 130
126 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; 131 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements;
127 132
128 protected List<ImportSedimentYield> sedimentYields; 133 protected List<ImportSedimentYield> sedimentYields;
134
135 protected List<ImportWaterlevel> waterlevels;
129 136
130 protected ImportWst wst; 137 protected ImportWst wst;
131 138
132 protected ImportUnit wstUnit; 139 protected ImportUnit wstUnit;
133 140
146 sedimentDensities = new ArrayList<ImportSedimentDensity>(); 153 sedimentDensities = new ArrayList<ImportSedimentDensity>();
147 morphologicalWidths = new ArrayList<ImportMorphWidth>(); 154 morphologicalWidths = new ArrayList<ImportMorphWidth>();
148 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); 155 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>();
149 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); 156 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>();
150 sedimentYields = new ArrayList<ImportSedimentYield>(); 157 sedimentYields = new ArrayList<ImportSedimentYield>();
158 waterlevels = new ArrayList<ImportWaterlevel>();
151 } 159 }
152 160
153 public ImportRiver( 161 public ImportRiver(
154 String name, 162 String name,
155 File wstFile, 163 File wstFile,
214 parseBedHeight(); 222 parseBedHeight();
215 parseSedimentDensity(); 223 parseSedimentDensity();
216 parseMorphologicalWidth(); 224 parseMorphologicalWidth();
217 parseFlowVelocity(); 225 parseFlowVelocity();
218 parseSedimentYield(); 226 parseSedimentYield();
227 parseWaterlevels();
219 } 228 }
220 229
221 public void parseFloodProtection() throws IOException { 230 public void parseFloodProtection() throws IOException {
222 if (Config.INSTANCE.skipFloodProtection()) { 231 if (Config.INSTANCE.skipFloodProtection()) {
223 log.info("skip parsing flood protection"); 232 log.info("skip parsing flood protection");
260 } 269 }
261 } 270 }
262 271
263 272
264 public void parseBedHeight() throws IOException { 273 public void parseBedHeight() throws IOException {
265 log.info("Parse bed height.");
266
267 File minfoDir = getMinfoDir(); 274 File minfoDir = getMinfoDir();
268 File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR); 275 File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR);
269 File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR); 276 File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR);
270 File epochDir = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR); 277 File epochDir = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR);
271 278
272 if (Config.INSTANCE.skipBedHeightSingle()) { 279 if (Config.INSTANCE.skipBedHeightSingle()) {
273 log.info("skip parsing bed height single."); 280 log.info("skip parsing bed height single.");
274 } 281 }
275 else { 282 else {
283 log.info("Parse bed height single.");
276 parseBedHeightSingles(singlesDir); 284 parseBedHeightSingles(singlesDir);
277 } 285 }
278 286
279 if (Config.INSTANCE.skipBedHeightEpoch()) { 287 if (Config.INSTANCE.skipBedHeightEpoch()) {
280 log.info("skip parsing bed height epochs."); 288 log.info("skip parsing bed height epochs.");
281 } 289 }
282 else { 290 else {
291 log.info("Parse bed height epochs.");
283 parseBedHeightEpochs(epochDir); 292 parseBedHeightEpochs(epochDir);
284 } 293 }
285
286 log.info("Finished parsing bed heights.");
287 } 294 }
288 295
289 296
290 protected void parseSedimentDensity() throws IOException { 297 protected void parseSedimentDensity() throws IOException {
291 log.debug("Parse sediment density"); 298 log.debug("Parse sediment density");
444 } 451 }
445 } 452 }
446 } 453 }
447 454
448 sedimentYields = parser.getSedimentYields(); 455 sedimentYields = parser.getSedimentYields();
456 }
457
458
459 protected void parseWaterlevels() throws IOException {
460 if (Config.INSTANCE.skipWaterlevels()) {
461 log.info("skip parsing waterlevels");
462 return;
463 }
464
465 File minfo = getMinfoDir();
466 File fixDir = new File(minfo, MINFO_FIXATIONS_DIR);
467 File wspDir = new File(minfo, MINFO_WATERLEVELS_DIR);
468
469 File[] files = wspDir.listFiles();
470
471 if (files == null) {
472 log.warn("Cannot read directory '" + wspDir + "'");
473 return;
474 }
475
476 WaterlevelParser parser = new WaterlevelParser();
477
478 for (File file: files) {
479 parser.parse(file);
480 }
481
482 log.info("Parse waterlevels");
483
484 waterlevels = parser.getWaterlevels();
449 } 485 }
450 486
451 487
452 protected void parseBedHeightSingles(File dir) throws IOException { 488 protected void parseBedHeightSingles(File dir) throws IOException {
453 log.debug("Parse bed height singles"); 489 log.debug("Parse bed height singles");
816 storeBedHeight(); 852 storeBedHeight();
817 storeSedimentDensity(); 853 storeSedimentDensity();
818 storeMorphologicalWidth(); 854 storeMorphologicalWidth();
819 storeFlowVelocity(); 855 storeFlowVelocity();
820 storeSedimentYield(); 856 storeSedimentYield();
857 storeWaterlevels();
821 } 858 }
822 859
823 public void storeWstUnit() { 860 public void storeWstUnit() {
824 if (wst == null) { 861 if (wst == null) {
825 wstUnit = new ImportUnit("NN + m"); 862 wstUnit = new ImportUnit("NN + m");
1074 log.error("Error while storing sediment yield.", cve); 1111 log.error("Error while storing sediment yield.", cve);
1075 } 1112 }
1076 } 1113 }
1077 } 1114 }
1078 } 1115 }
1116
1117
1118 public void storeWaterlevels() {
1119 if (!Config.INSTANCE.skipWaterlevels()) {
1120 log.info("store waterlevels");
1121
1122 River river = getPeer();
1123
1124 for (ImportWaterlevel waterlevel: waterlevels) {
1125 waterlevel.storeDependencies(river);
1126 }
1127 }
1128 }
1129
1079 1130
1080 public void storeAnnotations() { 1131 public void storeAnnotations() {
1081 if (!Config.INSTANCE.skipAnnotations()) { 1132 if (!Config.INSTANCE.skipAnnotations()) {
1082 River river = getPeer(); 1133 River river = getPeer();
1083 for (ImportAnnotation annotation: annotations) { 1134 for (ImportAnnotation annotation: annotations) {

http://dive4elements.wald.intevation.org