changeset 6482:b07cfc319781

Official lines: Use river id instead of river name to be more precise when finding out which main values has a official line.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 27 Jun 2013 18:14:49 +0200
parents d19a0ffb9ccf
children 0534ff91e499
files artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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");
         }
 

http://dive4elements.wald.intevation.org