diff flys-aft/src/main/java/de/intevation/aft/River.java @ 4098:9215253ad0be

Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates. flys-aft/trunk@3619 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 06 Jan 2012 18:54:00 +0000
parents 83c72bc07591
children 006e99437fb9
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Fri Jan 06 18:32:08 2012 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Fri Jan 06 18:54:00 2012 +0000
@@ -152,7 +152,43 @@
             DischargeTable.loadAftDischargeTables(
                 context, gauge.getOfficialNumber());
 
-        // TODO: Do pairing
+        Map<String, DischargeTable> desc2FlysDT =
+            new HashMap<String, DischargeTable>();
+
+        for (DischargeTable dt: flysDTs) {
+            String description = dt.getDescription();
+            if (description == null) {
+                log.warn("FLYS: discharge table " + dt.getId() 
+                    + " has no description. Ignored.");
+                continue;
+            }
+            desc2FlysDT.put(description, dt);
+        }
+
+        List<DischargeTable> createDTs = new ArrayList<DischargeTable>();
+
+        for (DischargeTable dt: aftDTs) {
+            String description = dt.getDescription();
+            DischargeTable flysDT = desc2FlysDT.remove(description);
+            if (flysDT != null) {
+                // Found in AFT and FLYS.
+                log.info("FLYS: Discharge table '" + description
+                    + "' found in AFT and FLYS. -> update");
+                // TODO: Create the W/Q diff.
+            }
+            else {
+                log.info("FLYS: Discharge table '" + description
+                    + "' not found in FLYS. -> create");
+                createDTs.add(dt);
+            }
+        }
+
+        for (String description: desc2FlysDT.keySet()) {
+            log.info("FLYS: Discharge table '" + description
+                + "' found in FLYS but not in AFT. -> ignore");
+        }
+
+        // TODO: Create the new discharge tables.
 
         return modified;
     }

http://dive4elements.wald.intevation.org