diff flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java @ 759:9f2204ed79ed

Import edges to database. flys-backend/trunk@2107 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 14 Jun 2011 13:13:58 +0000
parents d37ccb04ab5d
children 8076f6a689d0
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java	Tue Jun 14 12:34:08 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java	Tue Jun 14 13:13:58 2011 +0000
@@ -90,10 +90,42 @@
                     continue;
                 }
 
+                ImportEdge edge = null;
+
+                if (parts.length == 4) { // Only 'Unterkante'
+                    try {
+                        edge = new ImportEdge(
+                            null,
+                            new BigDecimal(parts[3].trim().replace(',', '.')));
+                    }
+                    catch (NumberFormatException nfe) {
+                        log.warn("cannot parse 'Unterkante' in line " +
+                            in.getLineNumber());
+                    }
+                }
+                else if (parts.length > 4) { // 'Unterkante' and 'Oberkante'
+                    String bottom = parts[3].trim().replace(',', '.');
+                    String top    = parts[4].trim().replace(',', '.');
+                    try {
+                        BigDecimal b = bottom.length() == 0
+                            ? null
+                            : new BigDecimal(bottom);
+                        BigDecimal t = top.length() == 0
+                            ? null
+                            : new BigDecimal(top);
+                        edge = new ImportEdge(t, b);
+                    }
+                    catch (NumberFormatException nfe) {
+                        log.warn(
+                            "cannot parse 'Unterkante' or 'Oberkante' in line "
+                            + in.getLineNumber());
+                    }
+                }
+
                 ImportRange range = new ImportRange(from, to);
 
                 ImportAnnotation annotation = new ImportAnnotation(
-                    attribute, position, range);
+                    attribute, position, range, edge);
 
                 if (!annotations.add(annotation)) {
                     log.debug("duplicated annotation in line "

http://dive4elements.wald.intevation.org