changeset 6004:ec54bb4fe407

Importer: use gauge official number as identifier, not name
author Tom Gottfried <tom.gottfried@intevation.de>
date Mon, 13 May 2013 11:14:38 +0200
parents 492a17232154
children d7eb007a57cc
files backend/src/main/java/org/dive4elements/river/importer/ImportGauge.java backend/src/main/java/org/dive4elements/river/importer/parsers/StaFileParser.java
diffstat 2 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportGauge.java	Mon May 13 10:10:09 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportGauge.java	Mon May 13 11:14:38 2013 +0200
@@ -267,9 +267,9 @@
         if (peer == null) {
             Session session = ImporterSession.getInstance().getDatabaseSession();
             Query query = session.createQuery(
-                "from Gauge where name=:name " +
+                "from Gauge where officialNumber=:officialNumber " +
                 "and river.id=:river");
-            query.setString("name", name);
+            query.setParameter("officialNumber", officialNumber);
             query.setParameter("river", river.getId());
             List<Gauge> gauges = query.list();
             if (gauges.isEmpty()) {
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/StaFileParser.java	Mon May 13 10:10:09 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/StaFileParser.java	Mon May 13 11:14:38 2013 +0200
@@ -42,9 +42,6 @@
     public static final String TYPES =
         System.getProperty("flys.backend.main.value.types", "QWTD");
 
-    public static final boolean NOT_PARSE_GAUGE_NUMBERS =
-        Boolean.getBoolean("flys.backend.sta.not.parse.gauge.numbers");
-
     public static final Pattern QWTD_ =
         Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([" +
             Pattern.quote(TYPES) + "]).*");
@@ -117,16 +114,14 @@
 
             Long gaugeNumber = null;
 
-            if (!NOT_PARSE_GAUGE_NUMBERS) {
-                String gaugeNumberString = line.substring(8, 16).trim();
+            String gaugeNumberString = line.substring(8, 16).trim();
 
-                try {
-                    gaugeNumber = Long.parseLong(gaugeNumberString);
-                }
-                catch (NumberFormatException nfe) {
-                    log.warn("STA: gauge number '" + gaugeNumberString +
-                        "' is not a valid long number.");
-                }
+            try {
+                gaugeNumber = Long.parseLong(gaugeNumberString);
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("STA: gauge number '" + gaugeNumberString +
+                         "' is not a valid long number.");
             }
 
             gauge.setName(gaugeName);

http://dive4elements.wald.intevation.org