Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 6724:0baf7abffcc6
issue1393/ImportRiver: Import official epochs from directory, minor refac.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 31 Jul 2013 11:13:41 +0200 |
parents | 75c483450c96 |
children | 827da1952ce2 0fe00824bd96 |
comparison
equal
deleted
inserted
replaced
6723:796750499cd2 | 6724:0baf7abffcc6 |
---|---|
106 public static final String SEDIMENT_YIELD_DIR = "Fracht"; | 106 public static final String SEDIMENT_YIELD_DIR = "Fracht"; |
107 | 107 |
108 public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre"; | 108 public static final String SEDIMENT_YIELD_SINGLE_DIR = "Einzeljahre"; |
109 | 109 |
110 public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen"; | 110 public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen"; |
111 | |
112 public static final String SEDIMENT_YIELD_OFF_EPOCH_DIR = "amtliche Epochen"; | |
111 | 113 |
112 public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse"; | 114 public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse"; |
113 | 115 |
114 public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen"; | 116 public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen"; |
115 | 117 |
500 flowVelocityMeasurements = parser.getMeasurements(); | 502 flowVelocityMeasurements = parser.getMeasurements(); |
501 } | 503 } |
502 } | 504 } |
503 | 505 |
504 | 506 |
507 private void parseSedimentYieldDir( | |
508 File[] files, | |
509 SedimentYieldParser parser | |
510 ) throws IOException { | |
511 for (File file: files) { | |
512 if (file.isDirectory()) { | |
513 for (File child: file.listFiles()) { | |
514 parser.parse(child); | |
515 } | |
516 } | |
517 else { | |
518 parser.parse(file); | |
519 } | |
520 } | |
521 } | |
522 | |
505 protected void parseSedimentYield() throws IOException { | 523 protected void parseSedimentYield() throws IOException { |
506 if (Config.INSTANCE.skipSedimentYield()) { | 524 if (Config.INSTANCE.skipSedimentYield()) { |
507 log.info("skip parsing sediment yield data"); | 525 log.info("skip parsing sediment yield data"); |
508 return; | 526 return; |
509 } | 527 } |
511 log.debug("Parse sediment yield data"); | 529 log.debug("Parse sediment yield data"); |
512 | 530 |
513 File minfoDir = getMinfoDir(); | 531 File minfoDir = getMinfoDir(); |
514 File sedimentYieldDir = new File(minfoDir, SEDIMENT_YIELD_DIR); | 532 File sedimentYieldDir = new File(minfoDir, SEDIMENT_YIELD_DIR); |
515 | 533 |
516 File singleDir = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR); | 534 File singleDir = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR); |
517 File epochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR); | 535 File epochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR); |
518 | 536 File offEpochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_OFF_EPOCH_DIR); |
519 File[] singles = singleDir.listFiles(); | 537 |
520 File[] epochs = epochDir.listFiles(); | 538 File[] singles = singleDir.listFiles(); |
539 File[] epochs = epochDir.listFiles(); | |
540 File[] offEpochs = offEpochDir.listFiles(); | |
521 | 541 |
522 SedimentYieldParser parser = new SedimentYieldParser(); | 542 SedimentYieldParser parser = new SedimentYieldParser(); |
523 | 543 |
524 if (singles == null || singles.length == 0) { | 544 if (singles == null || singles.length == 0) { |
525 log.warn("Cannot read directory '" + singleDir + "'"); | 545 log.warn("Cannot read directory '" + singleDir + "'"); |
526 } | 546 } |
527 else { | 547 else { |
528 for (File file: singles) { | 548 parseSedimentYieldDir(singles, parser); |
529 if (file.isDirectory()) { | |
530 for (File child: file.listFiles()) { | |
531 parser.parse(child); | |
532 } | |
533 } | |
534 else { | |
535 parser.parse(file); | |
536 } | |
537 } | |
538 } | 549 } |
539 | 550 |
540 if (epochs == null || epochs.length == 0) { | 551 if (epochs == null || epochs.length == 0) { |
541 log.warn("Cannot read directory '" + epochDir + "'"); | 552 log.warn("Cannot read directory '" + epochDir + "'"); |
542 } | 553 } |
543 else { | 554 else { |
544 for (File file: epochs) { | 555 parseSedimentYieldDir(epochs, parser); |
545 if (file.isDirectory()) { | 556 } |
546 for (File child: file.listFiles()) { | 557 |
547 parser.parse(child); | 558 if (offEpochs == null || offEpochs.length == 0) { |
548 } | 559 log.warn("Cannot read directory '" + offEpochDir + "'"); |
549 } | 560 } |
550 else { | 561 else { |
551 parser.parse(file); | 562 parseSedimentYieldDir(offEpochs, parser); |
552 } | |
553 } | |
554 } | 563 } |
555 | 564 |
556 sedimentYields = parser.getSedimentYields(); | 565 sedimentYields = parser.getSedimentYields(); |
557 } | 566 } |
558 | 567 |