[Dive4elements-commits] [PATCH 1 of 2] Importer: use gauge official number as identifier, not name

Wald Commits scm-commit at wald.intevation.org
Mon May 13 11:15:17 CEST 2013


# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1368436478 -7200
# Node ID ec54bb4fe407b28902cb46734d60db67b5584eb0
# Parent  492a172321544e1f8bc69608551a07540f1013d4
Importer: use gauge official number as identifier, not name

diff -r 492a17232154 -r ec54bb4fe407 backend/src/main/java/org/dive4elements/river/importer/ImportGauge.java
--- 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()) {
diff -r 492a17232154 -r ec54bb4fe407 backend/src/main/java/org/dive4elements/river/importer/parsers/StaFileParser.java
--- 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);


More information about the Dive4elements-commits mailing list