changeset 1220:3c860d3e79d9

Importer: Parse HYKs from importer. flys-backend/trunk@2346 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 17 Jul 2011 22:45:00 +0000
parents d80997bd94ce
children 979ff070e368
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Sun Jul 17 22:30:09 2011 +0000
+++ b/flys-backend/ChangeLog	Sun Jul 17 22:45:00 2011 +0000
@@ -1,3 +1,8 @@
+2011-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/ImportRiver.java:
+	  Parse the HYKs from the importer. TODO: Store them in database.
+
 2011-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/parsers/HYKParser.java:
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Sun Jul 17 22:30:09 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Sun Jul 17 22:45:00 2011 +0000
@@ -21,6 +21,7 @@
 import de.intevation.flys.utils.FileTools.HashedFile;
 
 import de.intevation.flys.importer.parsers.PRFParser;
+import de.intevation.flys.importer.parsers.HYKParser;
 import de.intevation.flys.importer.parsers.AnnotationsParser;
 import de.intevation.flys.importer.parsers.AnnotationClassifier;
 import de.intevation.flys.importer.parsers.PegelGltParser;
@@ -62,6 +63,8 @@
 
     protected List<ImportAnnotation> annotations;
 
+    protected List<ImportHYK> hyks;
+
     protected List<ImportCrossSection> crossSections;
 
     protected List<ImportWst> extraWsts;
@@ -81,6 +84,7 @@
     protected River peer;
 
     public ImportRiver() {
+        hyks            = new ArrayList<ImportHYK>();
         crossSections   = new ArrayList<ImportCrossSection>();
         extraWsts       = new ArrayList<ImportWst>();
         fixations       = new ArrayList<ImportWst>();
@@ -138,6 +142,7 @@
         parseGauges();
         parseAnnotations();
         parsePRFs();
+        parseHYKs();
         parseWst();
         parseExtraWsts();
         parseFixations();
@@ -363,6 +368,38 @@
         annotations = aparser.getAnnotations();
     }
 
+    public void parseHYKs() {
+        log.info("looking for HYK files");
+        HYKParser parser = new HYKParser();
+        File riverDir = wstFile
+            .getParentFile()  // Basisdaten
+            .getParentFile()  // Hydrologie
+            .getParentFile(); // <river>
+
+        parser.parseHYKs(riverDir, new HYKParser.Callback() {
+
+            Set<HashedFile> hfs = new HashSet<HashedFile>();
+
+            @Override
+            public boolean hykAccept(File file) {
+                HashedFile hf = new HashedFile(file);
+                boolean success = hfs.add(hf);
+                if (!success) {
+                    log.warn("HYK file '" + file + "' seems to be a duplicate.");
+                }
+                return success;
+            }
+
+            @Override
+            public void hykParsed(HYKParser parser) {
+                log.debug("callback from HYK parser");
+                ImportHYK hyk = parser.getHYK();
+                hyk.setRiver(ImportRiver.this);
+                hyks.add(hyk);
+            }
+        });
+    }
+
     public void parsePRFs() {
         log.info("looking for PRF files");
         PRFParser parser = new PRFParser();

http://dive4elements.wald.intevation.org