[PATCH] Official lines: Use river id instead of river name to be more precise when finding out which main values has a official line

Wald Commits scm-commit at wald.intevation.org
Thu Jun 27 18:14:55 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1372349689 -7200
# Node ID b07cfc319781439a4e0b118ce267558e3a537676
# Parent  d19a0ffb9ccffc8594da994a58641d9da517c1bf
Official lines: Use river id instead of river name to be more precise when finding out which main values has a official line.

diff -r d19a0ffb9ccf -r b07cfc319781 artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java	Thu Jun 27 17:42:22 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java	Thu Jun 27 18:14:49 2013 +0200
@@ -206,7 +206,7 @@
         doc.appendChild(rootEl);
 
         appendMetaInformation(doc, rootEl, river, gauge, context);
-        appendMainValues(doc, rootEl, mainValues, river.getName(), context);
+        appendMainValues(doc, rootEl, mainValues, river.getId(), context);
 
         return doc;
     }
@@ -252,9 +252,9 @@
 
 
     /** Checks i a main value has an official associated, */
-    protected static boolean hasOfficialLine(NamedMainValue nmv, String river) {
+    protected static boolean hasOfficialLine(NamedMainValue nmv, Integer riverId) {
         for (OfficialLine ol: nmv.getOfficialLines()) {
-            if (river.equals(ol.getWstColumn().getWst().getRiver().getName())) {
+            if (ol.getWstColumn().getWst().getRiver().getId().equals(riverId)) {
                 return true;
             }
         }
@@ -266,7 +266,7 @@
         Document        doc,
         Element         root,
         List<MainValue> mainValues,
-        String          river,
+        Integer         riverId,
         Object          context)
     {
         logger.debug("MainValuesService.appendMainValues");
@@ -279,7 +279,7 @@
         Element list = cr.create("mainvalues");
 
         for (MainValue mainValue: mainValues) {
-            Element newEl = buildMainValueElement(doc, mainValue, river, context);
+            Element newEl = buildMainValueElement(doc, mainValue, riverId, context);
 
             if (newEl != null) {
                 list.appendChild(newEl);
@@ -303,7 +303,7 @@
     protected Element buildMainValueElement(
         Document  doc,
         MainValue mainValue,
-        String    river,
+        Integer   riverId,
         Object    context)
     {
         ElementCreator cr = new ElementCreator(
@@ -320,7 +320,7 @@
         cr.addAttr(el, "name", namedMainValue.getName());
         cr.addAttr(el, "type", mainValueType.getName());
 
-        if (hasOfficialLine(namedMainValue, river)) {
+        if (hasOfficialLine(namedMainValue, riverId)) {
             cr.addAttr(el, "official", "true");
         }
 


More information about the Dive4elements-commits mailing list