diff artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 5e38e2924c07
children
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java	Wed Feb 07 11:52:04 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java	Wed Feb 07 11:59:13 2018 +0100
@@ -30,6 +30,7 @@
 
     private static Logger log = Logger.getLogger(ModuleService.class);
 
+    @Override
     protected Document doProcess(
         Document      data,
         GlobalContext globalContext,
@@ -37,26 +38,25 @@
     ) {
         log.debug("ModuleService.process");
 
-        Document result = XMLUtils.newDocument();
+        final Document result = XMLUtils.newDocument();
 
-        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+        final XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
             result,
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
-        Element em = ec.create("modules");
-        List<Module> modules = (List<Module>)globalContext.get(
-            RiverContext.MODULES);
+        final Element em = ec.create("modules");
+        final List<Module> modules = (List<Module>)globalContext.get( RiverContext.MODULES);
 
-        for (Module module : modules) {
-            Element m = ec.create("module");
+        for (final Module module : modules) {
+            final Element m = ec.create("module");
             ec.addAttr(m, "name", module.getName(), true);
-            String localname = Resources.getMsg(callMeta,
-                    MODULE + "." + module.getName(), module.getName());
+
+            final String localname = Resources.getMsg(callMeta, MODULE + "." + module.getName(), module.getName());
             ec.addAttr(m, "localname", localname, true);
 
-            for (String river : module.getRivers()) {
-                Element r = ec.create("river");
+            for (final String river : module.getRivers()) {
+                final Element r = ec.create("river");
                 r.setAttribute("uuid", river);
                 m.appendChild(r);
             }
@@ -64,6 +64,13 @@
                 ec.addAttr(m, "selected", "true", true);
             }
 
+            final String group = module.getGroup();
+            if( group != null ) {
+                final String groupLabel = Resources.getMsg(callMeta, group);
+                ec.addAttr(m, "groupId", group, true);
+                ec.addAttr(m, "groupLabel", groupLabel, true);
+            }
+
             em.appendChild(m);
         }
 

http://dive4elements.wald.intevation.org