Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2851:acb8d08f59a2
Parse and store MINFO waterlevel differences; added config option to skip this process.
flys-backend/trunk@4305 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 26 Apr 2012 09:48:49 +0000 |
parents | a65b5b0ade6f |
children | 2f874d14ac68 |
comparison
equal
deleted
inserted
replaced
2850:a1402c16152f | 2851:acb8d08f59a2 |
---|---|
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.WaterlevelDifferencesParser; | |
39 import de.intevation.flys.importer.parsers.WaterlevelParser; | 40 import de.intevation.flys.importer.parsers.WaterlevelParser; |
40 | 41 |
41 import org.hibernate.Session; | 42 import org.hibernate.Session; |
42 import org.hibernate.Query; | 43 import org.hibernate.Query; |
43 import org.hibernate.exception.ConstraintViolationException; | 44 import org.hibernate.exception.ConstraintViolationException; |
91 | 92 |
92 public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse"; | 93 public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse"; |
93 | 94 |
94 public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen"; | 95 public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen"; |
95 | 96 |
97 public static final String MINFO_WATERLEVEL_DIFF_DIR = "Wasserspiegeldifferenzen"; | |
98 | |
96 | 99 |
97 protected String name; | 100 protected String name; |
98 | 101 |
99 protected File wstFile; | 102 protected File wstFile; |
100 | 103 |
131 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; | 134 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; |
132 | 135 |
133 protected List<ImportSedimentYield> sedimentYields; | 136 protected List<ImportSedimentYield> sedimentYields; |
134 | 137 |
135 protected List<ImportWaterlevel> waterlevels; | 138 protected List<ImportWaterlevel> waterlevels; |
139 | |
140 protected List<ImportWaterlevelDifference> waterlevelDiffs; | |
136 | 141 |
137 protected ImportWst wst; | 142 protected ImportWst wst; |
138 | 143 |
139 protected ImportUnit wstUnit; | 144 protected ImportUnit wstUnit; |
140 | 145 |
154 morphologicalWidths = new ArrayList<ImportMorphWidth>(); | 159 morphologicalWidths = new ArrayList<ImportMorphWidth>(); |
155 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); | 160 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); |
156 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); | 161 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); |
157 sedimentYields = new ArrayList<ImportSedimentYield>(); | 162 sedimentYields = new ArrayList<ImportSedimentYield>(); |
158 waterlevels = new ArrayList<ImportWaterlevel>(); | 163 waterlevels = new ArrayList<ImportWaterlevel>(); |
164 waterlevelDiffs = new ArrayList<ImportWaterlevelDifference>(); | |
159 } | 165 } |
160 | 166 |
161 public ImportRiver( | 167 public ImportRiver( |
162 String name, | 168 String name, |
163 File wstFile, | 169 File wstFile, |
223 parseSedimentDensity(); | 229 parseSedimentDensity(); |
224 parseMorphologicalWidth(); | 230 parseMorphologicalWidth(); |
225 parseFlowVelocity(); | 231 parseFlowVelocity(); |
226 parseSedimentYield(); | 232 parseSedimentYield(); |
227 parseWaterlevels(); | 233 parseWaterlevels(); |
234 parseWaterlevelDifferences(); | |
228 } | 235 } |
229 | 236 |
230 public void parseFloodProtection() throws IOException { | 237 public void parseFloodProtection() throws IOException { |
231 if (Config.INSTANCE.skipFloodProtection()) { | 238 if (Config.INSTANCE.skipFloodProtection()) { |
232 log.info("skip parsing flood protection"); | 239 log.info("skip parsing flood protection"); |
460 if (Config.INSTANCE.skipWaterlevels()) { | 467 if (Config.INSTANCE.skipWaterlevels()) { |
461 log.info("skip parsing waterlevels"); | 468 log.info("skip parsing waterlevels"); |
462 return; | 469 return; |
463 } | 470 } |
464 | 471 |
472 log.info("Parse waterlevels"); | |
473 | |
465 File minfo = getMinfoDir(); | 474 File minfo = getMinfoDir(); |
466 File fixDir = new File(minfo, MINFO_FIXATIONS_DIR); | 475 File fixDir = new File(minfo, MINFO_FIXATIONS_DIR); |
467 File wspDir = new File(fixDir, MINFO_WATERLEVELS_DIR); | 476 File wspDir = new File(fixDir, MINFO_WATERLEVELS_DIR); |
468 | 477 |
469 File[] files = wspDir.listFiles(); | 478 File[] files = wspDir.listFiles(); |
477 | 486 |
478 for (File file: files) { | 487 for (File file: files) { |
479 parser.parse(file); | 488 parser.parse(file); |
480 } | 489 } |
481 | 490 |
482 log.info("Parse waterlevels"); | |
483 | |
484 waterlevels = parser.getWaterlevels(); | 491 waterlevels = parser.getWaterlevels(); |
492 } | |
493 | |
494 | |
495 protected void parseWaterlevelDifferences() throws IOException { | |
496 if (Config.INSTANCE.skipWaterlevelDifferences()) { | |
497 log.info("skip parsing waterlevel differences"); | |
498 return; | |
499 } | |
500 | |
501 log.info("Parse waterlevel differences"); | |
502 | |
503 File minfo = getMinfoDir(); | |
504 File fixDir = new File(minfo, MINFO_FIXATIONS_DIR); | |
505 File diffDir = new File(fixDir, MINFO_WATERLEVEL_DIFF_DIR); | |
506 | |
507 File[] files = diffDir.listFiles(); | |
508 | |
509 if (files == null) { | |
510 log.warn("Cannot read directory '" + diffDir + "'"); | |
511 return; | |
512 } | |
513 | |
514 WaterlevelDifferencesParser parser = new WaterlevelDifferencesParser(); | |
515 | |
516 for (File file: files) { | |
517 parser.parse(file); | |
518 } | |
519 | |
520 waterlevelDiffs = parser.getDifferences(); | |
485 } | 521 } |
486 | 522 |
487 | 523 |
488 protected void parseBedHeightSingles(File dir) throws IOException { | 524 protected void parseBedHeightSingles(File dir) throws IOException { |
489 log.debug("Parse bed height singles"); | 525 log.debug("Parse bed height singles"); |
853 storeSedimentDensity(); | 889 storeSedimentDensity(); |
854 storeMorphologicalWidth(); | 890 storeMorphologicalWidth(); |
855 storeFlowVelocity(); | 891 storeFlowVelocity(); |
856 storeSedimentYield(); | 892 storeSedimentYield(); |
857 storeWaterlevels(); | 893 storeWaterlevels(); |
894 storeWaterlevelDifferences(); | |
858 } | 895 } |
859 | 896 |
860 public void storeWstUnit() { | 897 public void storeWstUnit() { |
861 if (wst == null) { | 898 if (wst == null) { |
862 wstUnit = new ImportUnit("NN + m"); | 899 wstUnit = new ImportUnit("NN + m"); |
1121 | 1158 |
1122 River river = getPeer(); | 1159 River river = getPeer(); |
1123 | 1160 |
1124 for (ImportWaterlevel waterlevel: waterlevels) { | 1161 for (ImportWaterlevel waterlevel: waterlevels) { |
1125 waterlevel.storeDependencies(river); | 1162 waterlevel.storeDependencies(river); |
1163 } | |
1164 } | |
1165 } | |
1166 | |
1167 | |
1168 public void storeWaterlevelDifferences() { | |
1169 if (!Config.INSTANCE.skipWaterlevelDifferences()) { | |
1170 log.info("store waterlevel differences"); | |
1171 | |
1172 River river = getPeer(); | |
1173 | |
1174 for (ImportWaterlevelDifference diff: waterlevelDiffs) { | |
1175 try { | |
1176 diff.storeDependencies(river); | |
1177 } | |
1178 catch (SQLException sqle) { | |
1179 log.error("Error while storing waterlevel diff.", sqle); | |
1180 } | |
1181 catch (ConstraintViolationException cve) { | |
1182 log.error("Error while storing waterlevel diff.", cve); | |
1183 } | |
1126 } | 1184 } |
1127 } | 1185 } |
1128 } | 1186 } |
1129 | 1187 |
1130 | 1188 |