comparison 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
comparison
equal deleted inserted replaced
2838:75446c47ef77 2839:163c037f2c7e
79 79
80 public static final String FLOW_VELOCITY_MODEL = "Modellrechnungen"; 80 public static final String FLOW_VELOCITY_MODEL = "Modellrechnungen";
81 81
82 public static final String FLOW_VELOCITY_MEASUREMENTS = "v-Messungen"; 82 public static final String FLOW_VELOCITY_MEASUREMENTS = "v-Messungen";
83 83
84 public static final String SEDIMENT_YIELD_DIR = "Fracht";
85
86 public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre";
87
88 public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen";
89
84 90
85 protected String name; 91 protected String name;
86 92
87 protected File wstFile; 93 protected File wstFile;
88 94
115 protected List<ImportMorphWidth> morphologicalWidths; 121 protected List<ImportMorphWidth> morphologicalWidths;
116 122
117 protected List<ImportFlowVelocityModel> flowVelocityModels; 123 protected List<ImportFlowVelocityModel> flowVelocityModels;
118 124
119 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements; 125 protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements;
126
127 protected List<ImportSedimentYield> sedimentYields;
120 128
121 protected ImportWst wst; 129 protected ImportWst wst;
122 130
123 protected ImportUnit wstUnit; 131 protected ImportUnit wstUnit;
124 132
136 floodProtection = new ArrayList<ImportWst>(); 144 floodProtection = new ArrayList<ImportWst>();
137 sedimentDensities = new ArrayList<ImportSedimentDensity>(); 145 sedimentDensities = new ArrayList<ImportSedimentDensity>();
138 morphologicalWidths = new ArrayList<ImportMorphWidth>(); 146 morphologicalWidths = new ArrayList<ImportMorphWidth>();
139 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>(); 147 flowVelocityModels = new ArrayList<ImportFlowVelocityModel>();
140 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>(); 148 flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>();
149 sedimentYields = new ArrayList<ImportSedimentYield>();
141 } 150 }
142 151
143 public ImportRiver( 152 public ImportRiver(
144 String name, 153 String name,
145 File wstFile, 154 File wstFile,
203 parseFloodProtection(); 212 parseFloodProtection();
204 parseBedHeight(); 213 parseBedHeight();
205 parseSedimentDensity(); 214 parseSedimentDensity();
206 parseMorphologicalWidth(); 215 parseMorphologicalWidth();
207 parseFlowVelocity(); 216 parseFlowVelocity();
217 parseSedimentYield();
208 } 218 }
209 219
210 public void parseFloodProtection() throws IOException { 220 public void parseFloodProtection() throws IOException {
211 if (Config.INSTANCE.skipFloodProtection()) { 221 if (Config.INSTANCE.skipFloodProtection()) {
212 log.info("skip parsing flood protection"); 222 log.info("skip parsing flood protection");
377 log.debug("Parse file '" + measurement + "'"); 387 log.debug("Parse file '" + measurement + "'");
378 parser.parse(measurement); 388 parser.parse(measurement);
379 } 389 }
380 390
381 flowVelocityMeasurements = parser.getMeasurements(); 391 flowVelocityMeasurements = parser.getMeasurements();
392 }
393 }
394
395
396 protected void parseSedimentYield() throws IOException {
397 log.debug("Parse sediment yield data");
398
399 if (Config.INSTANCE.skipSedimentYield()) {
400 log.info("skip parsing sediment yield data");
401 return;
402 }
403
404 File minfoDir = getMinfoDir();
405 File sedimentYieldDir = new File(minfoDir, SEDIMENT_YIELD_DIR);
406
407 File singleDir = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR);
408 File epochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR);
409
410 File[] singles = singleDir.listFiles();
411 File[] epochs = epochDir.listFiles();
412
413 if (singles == null || singles.length == 0) {
414 log.warn("Cannot parse directory '" + singleDir + "'");
415 }
416 else {
417 // TODO
418 }
419
420 if (epochs == null || epochs.length == 0) {
421 log.warn("Cannot parse directory '" + epochDir + "'");
422 }
423 else {
424 // TODO
382 } 425 }
383 } 426 }
384 427
385 428
386 protected void parseBedHeightSingles(File dir) throws IOException { 429 protected void parseBedHeightSingles(File dir) throws IOException {
749 storeFloodProtection(); 792 storeFloodProtection();
750 storeBedHeight(); 793 storeBedHeight();
751 storeSedimentDensity(); 794 storeSedimentDensity();
752 storeMorphologicalWidth(); 795 storeMorphologicalWidth();
753 storeFlowVelocity(); 796 storeFlowVelocity();
797 storeSedimentYield();
754 } 798 }
755 799
756 public void storeWstUnit() { 800 public void storeWstUnit() {
757 if (wst == null) { 801 if (wst == null) {
758 wstUnit = new ImportUnit("NN + m"); 802 wstUnit = new ImportUnit("NN + m");
982 catch (SQLException sqle) { 1026 catch (SQLException sqle) {
983 log.error("Error while storing flow velocity measurement.", sqle); 1027 log.error("Error while storing flow velocity measurement.", sqle);
984 } 1028 }
985 catch (ConstraintViolationException cve) { 1029 catch (ConstraintViolationException cve) {
986 log.error("Error while storing flow velocity measurement.", cve); 1030 log.error("Error while storing flow velocity measurement.", cve);
1031 }
1032 }
1033 }
1034 }
1035
1036
1037 public void storeSedimentYield() {
1038 if (!Config.INSTANCE.skipSedimentYield()) {
1039 log.info("store sediment yield data");
1040
1041 River river = getPeer();
1042
1043 for (ImportSedimentYield sedimentYield: sedimentYields) {
1044 try {
1045 sedimentYield.storeDependencies(river);
1046 }
1047 catch (SQLException sqle) {
1048 log.error("Error while storing sediment yield.", sqle);
1049 }
1050 catch (ConstraintViolationException cve) {
1051 log.error("Error while storing sediment yield.", cve);
987 } 1052 }
988 } 1053 }
989 } 1054 }
990 } 1055 }
991 1056

http://dive4elements.wald.intevation.org