changeset 7756:cd04a7389389

Read rivers supported by a module from config file.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 27 Feb 2014 14:56:36 +0100
parents 4a85cc6add7f
children f4e4ee473472
files artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);
     }

http://dive4elements.wald.intevation.org