changeset 7751:24408bce2fdb

Parse and import model_uuid for rivers.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 27 Feb 2014 14:46:30 +0100
parents 6ff574778491
children b73b1ab2155c
files backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java backend/src/main/java/org/dive4elements/river/importer/parsers/InfoGewParser.java
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Thu Feb 27 14:45:22 2014 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Thu Feb 27 14:46:30 2014 +0100
@@ -131,6 +131,8 @@
 
     protected String name;
 
+    protected String modelUuid;
+
     protected Long officialNumber;
 
     protected File wstFile;
@@ -295,12 +297,14 @@
 
     public ImportRiver(
         String               name,
+        String               modelUuid,
         File                 wstFile,
         File                 bbInfoFile,
         AnnotationClassifier annotationClassifier
     ) {
         this();
         this.name                 = name;
+        this.modelUuid            = modelUuid;
         this.wstFile              = wstFile;
         this.bbInfoFile           = bbInfoFile;
         this.annotationClassifier = annotationClassifier;
@@ -314,6 +318,14 @@
         this.name = name;
     }
 
+    public String getModelUuid() {
+        return modelUuid;
+    }
+
+    public void setModelUuid(String modelUuid) {
+        this.modelUuid = modelUuid;
+    }
+
     public Long getOfficialNumber() {
         return this.officialNumber;
     }
@@ -1582,7 +1594,7 @@
             List<River> rivers = query.list();
             if (rivers.isEmpty()) {
                 log.info("Store new river '" + name + "'");
-                peer = new River(name, u);
+                peer = new River(name, u, modelUuid);
                 if (!Config.INSTANCE.skipBWASTR()) {
                     peer.setOfficialNumber(officialNumber);
                 }
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/InfoGewParser.java	Thu Feb 27 14:45:22 2014 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/InfoGewParser.java	Thu Feb 27 14:46:30 2014 +0100
@@ -44,6 +44,9 @@
     public static final Pattern BB_INFO =
         Pattern.compile("^\\s*B\\+B-Info\\s*:\\s*(.+)");
 
+    public static final Pattern GEW_UUID =
+        Pattern.compile("^\\s*uuid\\s*:\\s*(.+)");
+
     protected ArrayList<ImportRiver> rivers;
 
     protected AnnotationClassifier annotationClassifier;
@@ -81,6 +84,7 @@
             String line = null;
 
             String riverName  = null;
+            String modelUuid  = null;
             File   wstFile    = null;
             File   bbInfoFile = null;
 
@@ -96,11 +100,13 @@
                     if (riverName != null) {
                         rivers.add(new ImportRiver(
                             riverName,
+                            modelUuid,
                             wstFile,
                             bbInfoFile,
                             annotationClassifier));
                     }
                     riverName  = river;
+                    modelUuid  = null;
                     wstFile    = null;
                     bbInfoFile = null;
                 }
@@ -118,6 +124,11 @@
                     }
                     wstFile = wst;
                 }
+                else if ((m = GEW_UUID.matcher(line)).matches()) {
+                    modelUuid = m.group(1);
+                    log.debug("Found model uuid " + modelUuid +
+                        " for river " + riverName);
+                }
                 else if ((m = BB_INFO.matcher(line)).matches()) {
                     //TODO: Make it relative to the wst file.
                     String bbInfo = m.group(1);
@@ -127,6 +138,7 @@
             if (riverName != null) {
                 rivers.add(new ImportRiver(
                     riverName,
+                    modelUuid,
                     wstFile,
                     bbInfoFile,
                     annotationClassifier));

http://dive4elements.wald.intevation.org