Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1222:1f21f162bcf3 | 1223:268f8da412e3 |
---|---|
150 parseFloodWater(); | 150 parseFloodWater(); |
151 parseFloodProtection(); | 151 parseFloodProtection(); |
152 } | 152 } |
153 | 153 |
154 public void parseFloodProtection() throws IOException { | 154 public void parseFloodProtection() throws IOException { |
155 if (Config.INSTANCE.skipFloodProtection()) { | |
156 log.info("skip parsing flood protection"); | |
157 return; | |
158 } | |
159 | |
155 log.info("Parse flood protection wst file"); | 160 log.info("Parse flood protection wst file"); |
156 | 161 |
157 File riverDir = wstFile.getParentFile().getParentFile(); | 162 File riverDir = wstFile.getParentFile().getParentFile(); |
158 | 163 |
159 File dir = FileTools.repair(new File(riverDir, FLOOD_PROTECTION)); | 164 File dir = FileTools.repair(new File(riverDir, FLOOD_PROTECTION)); |
187 floodProtection.add(iw); | 192 floodProtection.add(iw); |
188 } | 193 } |
189 } | 194 } |
190 | 195 |
191 public void parseFloodWater() throws IOException { | 196 public void parseFloodWater() throws IOException { |
197 if (Config.INSTANCE.skipFloodWater()) { | |
198 log.info("skip parsing flod water"); | |
199 return; | |
200 } | |
201 | |
192 log.info("Parse flood water wst file"); | 202 log.info("Parse flood water wst file"); |
193 | 203 |
194 File riverDir = wstFile.getParentFile().getParentFile(); | 204 File riverDir = wstFile.getParentFile().getParentFile(); |
195 | 205 |
196 File dir = FileTools.repair(new File(riverDir, FLOOD_WATER)); | 206 File dir = FileTools.repair(new File(riverDir, FLOOD_WATER)); |
224 floodWater.add(iw); | 234 floodWater.add(iw); |
225 } | 235 } |
226 } | 236 } |
227 | 237 |
228 public void parseOfficialLines() throws IOException { | 238 public void parseOfficialLines() throws IOException { |
239 if (Config.INSTANCE.skipOfficialLines()) { | |
240 log.info("skip parsing official lines"); | |
241 return; | |
242 } | |
243 | |
229 log.info("Parse official wst files"); | 244 log.info("Parse official wst files"); |
230 | 245 |
231 File riverDir = wstFile.getParentFile().getParentFile(); | 246 File riverDir = wstFile.getParentFile().getParentFile(); |
232 | 247 |
233 for (String folder: OFFICIAL_LINES_FOLDERS) { | 248 for (String folder: OFFICIAL_LINES_FOLDERS) { |
254 } // for all folders | 269 } // for all folders |
255 | 270 |
256 } | 271 } |
257 | 272 |
258 public void parseFixations() throws IOException { | 273 public void parseFixations() throws IOException { |
274 if (Config.INSTANCE.skipFixations()) { | |
275 log.info("skip parsing fixations"); | |
276 return; | |
277 } | |
278 | |
259 log.info("Parse fixation wst files"); | 279 log.info("Parse fixation wst files"); |
260 | 280 |
261 File riverDir = wstFile.getParentFile().getParentFile(); | 281 File riverDir = wstFile.getParentFile().getParentFile(); |
262 | 282 |
263 File fixDir = FileTools.repair( | 283 File fixDir = FileTools.repair( |
293 fixations.add(iw); | 313 fixations.add(iw); |
294 } | 314 } |
295 } | 315 } |
296 | 316 |
297 public void parseExtraWsts() throws IOException { | 317 public void parseExtraWsts() throws IOException { |
318 if (Config.INSTANCE.skipExtraWsts()) { | |
319 log.info("skip parsing extra WST files"); | |
320 return; | |
321 } | |
322 | |
298 log.info("Parse extra longitudinal wst files"); | 323 log.info("Parse extra longitudinal wst files"); |
299 | 324 |
300 File riverDir = wstFile.getParentFile().getParentFile(); | 325 File riverDir = wstFile.getParentFile().getParentFile(); |
301 | 326 |
302 File extraDir = FileTools.repair( | 327 File extraDir = FileTools.repair( |
333 } | 358 } |
334 | 359 |
335 } | 360 } |
336 | 361 |
337 public void parseWst() throws IOException { | 362 public void parseWst() throws IOException { |
363 if (Config.INSTANCE.skipWst()) { | |
364 log.info("skip parsing WST file"); | |
365 return; | |
366 } | |
367 | |
338 WstParser wstParser = new WstParser(); | 368 WstParser wstParser = new WstParser(); |
339 wstParser.parse(wstFile); | 369 wstParser.parse(wstFile); |
340 wst = wstParser.getWst(); | 370 wst = wstParser.getWst(); |
341 } | 371 } |
342 | 372 |
343 public void parseGauges() throws IOException { | 373 public void parseGauges() throws IOException { |
374 if (Config.INSTANCE.skipGauges()) { | |
375 log.info("skip parsing gauges"); | |
376 return; | |
377 } | |
378 | |
344 File gltFile = new File(wstFile.getParentFile(), PEGEL_GLT); | 379 File gltFile = new File(wstFile.getParentFile(), PEGEL_GLT); |
345 gltFile = FileTools.repair(gltFile); | 380 gltFile = FileTools.repair(gltFile); |
346 | 381 |
347 if (!gltFile.isFile() || !gltFile.canRead()) { | 382 if (!gltFile.isFile() || !gltFile.canRead()) { |
348 log.warn("cannot read gauges from '" + gltFile + "'"); | 383 log.warn("cannot read gauges from '" + gltFile + "'"); |
358 gauge.parseDependencies(); | 393 gauge.parseDependencies(); |
359 } | 394 } |
360 } | 395 } |
361 | 396 |
362 public void parseAnnotations() throws IOException { | 397 public void parseAnnotations() throws IOException { |
398 if (Config.INSTANCE.skipAnnotations()) { | |
399 log.info("skip parsing annotations"); | |
400 return; | |
401 } | |
402 | |
363 File riverDir = wstFile.getParentFile().getParentFile(); | 403 File riverDir = wstFile.getParentFile().getParentFile(); |
364 AnnotationsParser aparser = | 404 AnnotationsParser aparser = |
365 new AnnotationsParser(annotationClassifier); | 405 new AnnotationsParser(annotationClassifier); |
366 aparser.parse(riverDir); | 406 aparser.parse(riverDir); |
367 | 407 |
368 annotations = aparser.getAnnotations(); | 408 annotations = aparser.getAnnotations(); |
369 } | 409 } |
370 | 410 |
371 public void parseHYKs() { | 411 public void parseHYKs() { |
412 if (Config.INSTANCE.skipHYKs()) { | |
413 log.info("skip parsing HYK files"); | |
414 return; | |
415 } | |
416 | |
372 log.info("looking for HYK files"); | 417 log.info("looking for HYK files"); |
373 HYKParser parser = new HYKParser(); | 418 HYKParser parser = new HYKParser(); |
374 File riverDir = wstFile | 419 File riverDir = wstFile |
375 .getParentFile() // Basisdaten | 420 .getParentFile() // Basisdaten |
376 .getParentFile() // Hydrologie | 421 .getParentFile() // Hydrologie |
399 } | 444 } |
400 }); | 445 }); |
401 } | 446 } |
402 | 447 |
403 public void parsePRFs() { | 448 public void parsePRFs() { |
449 if (Config.INSTANCE.skipPRFs()) { | |
450 log.info("skip parsing PRFs"); | |
451 return; | |
452 } | |
453 | |
404 log.info("looking for PRF files"); | 454 log.info("looking for PRF files"); |
405 PRFParser parser = new PRFParser(); | 455 PRFParser parser = new PRFParser(); |
406 File riverDir = wstFile | 456 File riverDir = wstFile |
407 .getParentFile() // Basisdaten | 457 .getParentFile() // Basisdaten |
408 .getParentFile() // Hydrologie | 458 .getParentFile() // Hydrologie |
467 storeFloodWater(); | 517 storeFloodWater(); |
468 storeFloodProtection(); | 518 storeFloodProtection(); |
469 } | 519 } |
470 | 520 |
471 public void storeHYKs() { | 521 public void storeHYKs() { |
472 log.info("store HYKs"); | 522 if (!Config.INSTANCE.skipHYKs()) { |
473 getPeer(); | 523 log.info("store HYKs"); |
474 for (ImportHYK hyk: hyks) { | 524 getPeer(); |
475 hyk.storeDependencies(); | 525 for (ImportHYK hyk: hyks) { |
526 hyk.storeDependencies(); | |
527 } | |
476 } | 528 } |
477 } | 529 } |
478 | 530 |
479 public void storeCrossSections() { | 531 public void storeCrossSections() { |
480 log.info("store cross sections"); | 532 if (!Config.INSTANCE.skipPRFs()) { |
481 for (ImportCrossSection crossSection: crossSections) { | 533 log.info("store cross sections"); |
482 crossSection.storeDependencies(); | 534 getPeer(); |
535 for (ImportCrossSection crossSection: crossSections) { | |
536 crossSection.storeDependencies(); | |
537 } | |
483 } | 538 } |
484 } | 539 } |
485 | 540 |
486 public void storeWst() { | 541 public void storeWst() { |
487 River river = getPeer(); | 542 if (!Config.INSTANCE.skipWst()) { |
488 wst.storeDependencies(river); | 543 River river = getPeer(); |
544 wst.storeDependencies(river); | |
545 } | |
489 } | 546 } |
490 | 547 |
491 public void storeFixations() { | 548 public void storeFixations() { |
492 log.info("store fixation wsts"); | 549 if (!Config.INSTANCE.skipFixations()) { |
493 River river = getPeer(); | 550 log.info("store fixation wsts"); |
494 for (ImportWst wst: fixations) { | 551 River river = getPeer(); |
495 log.debug("name: " + wst.getDescription()); | 552 for (ImportWst wst: fixations) { |
496 wst.storeDependencies(river); | 553 log.debug("name: " + wst.getDescription()); |
554 wst.storeDependencies(river); | |
555 } | |
497 } | 556 } |
498 } | 557 } |
499 | 558 |
500 public void storeExtraWsts() { | 559 public void storeExtraWsts() { |
501 log.info("store extra wsts"); | 560 if (!Config.INSTANCE.skipExtraWsts()) { |
502 River river = getPeer(); | 561 log.info("store extra wsts"); |
503 for (ImportWst wst: extraWsts) { | 562 River river = getPeer(); |
504 log.debug("name: " + wst.getDescription()); | 563 for (ImportWst wst: extraWsts) { |
505 wst.storeDependencies(river); | 564 log.debug("name: " + wst.getDescription()); |
565 wst.storeDependencies(river); | |
566 } | |
506 } | 567 } |
507 } | 568 } |
508 | 569 |
509 public void storeOfficialLines() { | 570 public void storeOfficialLines() { |
510 log.info("store official lines wsts"); | 571 if (!Config.INSTANCE.skipOfficialLines()) { |
511 River river = getPeer(); | 572 log.info("store official lines wsts"); |
512 for (ImportWst wst: officialLines) { | 573 River river = getPeer(); |
513 log.debug("name: " + wst.getDescription()); | 574 for (ImportWst wst: officialLines) { |
514 wst.storeDependencies(river); | 575 log.debug("name: " + wst.getDescription()); |
576 wst.storeDependencies(river); | |
577 } | |
515 } | 578 } |
516 } | 579 } |
517 | 580 |
518 public void storeFloodWater() { | 581 public void storeFloodWater() { |
519 log.info("store flood water wsts"); | 582 if (!Config.INSTANCE.skipFloodWater()) { |
520 River river = getPeer(); | 583 log.info("store flood water wsts"); |
521 for (ImportWst wst: floodWater) { | 584 River river = getPeer(); |
522 log.debug("name: " + wst.getDescription()); | 585 for (ImportWst wst: floodWater) { |
523 wst.storeDependencies(river); | 586 log.debug("name: " + wst.getDescription()); |
587 wst.storeDependencies(river); | |
588 } | |
524 } | 589 } |
525 } | 590 } |
526 | 591 |
527 public void storeFloodProtection() { | 592 public void storeFloodProtection() { |
528 log.info("store flood protection wsts"); | 593 if (!Config.INSTANCE.skipFloodProtection()) { |
529 River river = getPeer(); | 594 log.info("store flood protection wsts"); |
530 for (ImportWst wst: floodProtection) { | 595 River river = getPeer(); |
531 log.debug("name: " + wst.getDescription()); | 596 for (ImportWst wst: floodProtection) { |
532 wst.storeDependencies(river); | 597 log.debug("name: " + wst.getDescription()); |
598 wst.storeDependencies(river); | |
599 } | |
533 } | 600 } |
534 } | 601 } |
535 | 602 |
536 public void storeAnnotations() { | 603 public void storeAnnotations() { |
537 River river = getPeer(); | 604 if (!Config.INSTANCE.skipAnnotations()) { |
538 for (ImportAnnotation annotation: annotations) { | 605 River river = getPeer(); |
539 annotation.getPeer(river); | 606 for (ImportAnnotation annotation: annotations) { |
607 annotation.getPeer(river); | |
608 } | |
540 } | 609 } |
541 } | 610 } |
542 | 611 |
543 public void storeGauges() { | 612 public void storeGauges() { |
544 log.info("store gauges:"); | 613 if (!Config.INSTANCE.skipGauges()) { |
545 River river = getPeer(); | 614 log.info("store gauges:"); |
546 Session session = ImporterSession.getInstance().getDatabaseSession(); | 615 River river = getPeer(); |
547 for (ImportGauge gauge: gauges) { | 616 Session session = ImporterSession.getInstance() |
548 log.info("\tgauge: " + gauge.getName()); | 617 .getDatabaseSession(); |
549 gauge.storeDependencies(river); | 618 for (ImportGauge gauge: gauges) { |
550 ImporterSession.getInstance().getDatabaseSession(); | 619 log.info("\tgauge: " + gauge.getName()); |
551 session.flush(); | 620 gauge.storeDependencies(river); |
621 ImporterSession.getInstance().getDatabaseSession(); | |
622 session.flush(); | |
623 } | |
552 } | 624 } |
553 } | 625 } |
554 | 626 |
555 public River getPeer() { | 627 public River getPeer() { |
556 if (peer == null) { | 628 if (peer == null) { |