Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 8755:30b1ddadf275
(issue1801) Unify reference gauge finding code
The basic way as described in the method comment of the
determineRefGauge method is now used in the WINFOArtifact,
MainValuesService and RiverUtils.getGauge method.
RiverUtils.getGauge previously just returned the first
gauge found. While this is now a behavior change I believe
that it is always more correct then the undeterministic
behavior of the previous implmenentation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 24 Jun 2015 14:07:26 +0200 |
parents | e4606eae8ea5 |
children | 5e38e2924c07 |
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); protected Document doProcess( Document data, GlobalContext globalContext, CallMeta callMeta ) { log.debug("ModuleService.process"); Document result = XMLUtils.newDocument(); 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); for (Module module : modules) { Element m = ec.create("module"); ec.addAttr(m, "name", module.getName(), true); 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"); r.setAttribute("uuid", river); m.appendChild(r); } if (module.isSelected()) { ec.addAttr(m, "selected", "true", true); } em.appendChild(m); } result.appendChild(em); return result; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80: