Mercurial > dive4elements > river
view 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 source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.services; import java.util.List; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.GlobalContext; import org.dive4elements.artifacts.ArtifactNamespaceContext; import org.dive4elements.river.artifacts.model.Module; import org.dive4elements.river.artifacts.context.RiverContext; import org.dive4elements.river.artifacts.resources.Resources; public class ModuleService extends D4EService { private static final String MODULE = "module"; private static Logger log = Logger.getLogger(ModuleService.class); @Override protected Document doProcess( Document data, GlobalContext globalContext, CallMeta callMeta ) { log.debug("ModuleService.process"); final Document result = XMLUtils.newDocument(); final XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( result, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); final Element em = ec.create("modules"); final List<Module> modules = (List<Module>)globalContext.get( RiverContext.MODULES); for (final Module module : modules) { final Element m = ec.create("module"); ec.addAttr(m, "name", module.getName(), true); final String localname = Resources.getMsg(callMeta, MODULE + "." + module.getName(), module.getName()); ec.addAttr(m, "localname", localname, true); for (final String river : module.getRivers()) { final Element r = ec.create("river"); r.setAttribute("uuid", river); m.appendChild(r); } if (module.isSelected()) { 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); } result.appendChild(em); return result; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80: