[PATCH 07 of 17] Read rivers supported by a module from config file

Wald Commits scm-commit at wald.intevation.org
Thu Feb 27 16:47:53 CET 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1393509396 -3600
# Node ID cd04a7389389060ed09f91f1fb028d0b11b7f777
# Parent  4a85cc6add7fe3e1218c68b30892f299434a01c3
Read rivers supported by a module from config file.

diff -r 4a85cc6add7f -r cd04a7389389 artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Thu Feb 27 14:55:38 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Thu Feb 27 14:56:36 2014 +0100
@@ -33,6 +33,7 @@
 import org.dive4elements.artifacts.common.utils.XMLUtils;
 
 import org.dive4elements.river.artifacts.model.Module;
+import org.dive4elements.river.artifacts.model.RiverFactory;
 import org.dive4elements.river.artifacts.model.ZoomScale;
 
 import org.dive4elements.river.artifacts.states.StateFactory;
@@ -42,6 +43,7 @@
 import org.dive4elements.river.exports.GeneratorLookup;
 import org.dive4elements.river.exports.OutGenerator;
 
+import org.dive4elements.river.model.River;
 import org.dive4elements.river.themes.Theme;
 import org.dive4elements.river.themes.ThemeFactory;
 import org.dive4elements.river.themes.ThemeGroup;
@@ -571,7 +573,28 @@
             boolean selected = attrselected == null ? false :
                 attrselected.equalsIgnoreCase("true");
             logger.debug("Loaded module " + modulename);
-            modules.add(new Module(modulename, selected));
+            NodeList children = e.getChildNodes();
+            List<String> rivers = new ArrayList<String>(children.getLength());
+            for (int j = 0; j < children.getLength(); j++) {
+                if (children.item(j).getNodeType() != Node.ELEMENT_NODE) {
+                    continue;
+                }
+                Element ce = (Element)children.item(j);
+                if (ce.hasAttribute("uuid")) {
+                    rivers.add(ce.getAttribute("uuid"));
+                }
+                else if (ce.hasAttribute("name")) {
+                    List<River> allRivers = RiverFactory.getRivers();
+                    String name = ce.getAttribute("name");
+                    for (River r: allRivers) {
+                        if (name.equals(r.getName())) {
+                            rivers.add(r.getModelUuid());
+                            break;
+                        }
+                    }
+                }
+            }
+            modules.add(new Module(modulename, selected, rivers));
         }
         context.put(RiverContext.MODULES, modules);
     }


More information about the Dive4elements-commits mailing list