teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.services; ingo@118: ingo@133: import java.util.List; ingo@133: ingo@118: import org.apache.log4j.Logger; ingo@118: ingo@118: import org.w3c.dom.Document; ingo@118: import org.w3c.dom.Element; ingo@118: teichmann@5831: import org.dive4elements.artifacts.CallMeta; teichmann@5831: import org.dive4elements.artifacts.GlobalContext; ingo@118: teichmann@5831: import org.dive4elements.artifacts.common.ArtifactNamespaceContext; teichmann@5831: import org.dive4elements.artifacts.common.utils.XMLUtils; ingo@118: teichmann@5831: import org.dive4elements.river.model.River; ingo@133: teichmann@5831: import org.dive4elements.river.artifacts.model.RiverFactory; ingo@133: ingo@118: ingo@118: /** ingo@118: * This service provides information about the supported rivers by this ingo@118: * application. ingo@118: * ingo@118: * @author Ingo Weinzierl ingo@118: */ teichmann@5868: public class RiverService extends D4EService { ingo@118: teichmann@8202: /** The log used in this service.*/ teichmann@8202: private static Logger log = Logger.getLogger(RiverService.class); ingo@118: tom@8479: @Override ingo@1631: protected Document doProcess( sascha@966: Document data, sascha@966: GlobalContext globalContext, sascha@966: CallMeta callMeta sascha@966: ) { teichmann@8202: log.debug("RiverService.process"); ingo@118: ingo@118: Document result = XMLUtils.newDocument(); ingo@118: ingo@118: XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( ingo@118: result, ingo@118: ArtifactNamespaceContext.NAMESPACE_URI, ingo@118: ArtifactNamespaceContext.NAMESPACE_PREFIX); ingo@118: ingo@1631: List allRivers = RiverFactory.getRivers(); ingo@118: ingo@1631: Element rivers = ec.create("rivers"); sascha@314: ingo@1631: for (River river: allRivers) { ingo@1631: Element r = ec.create("river"); ingo@1631: ec.addAttr(r, "name", river.getName(), true); rrenkert@7753: ec.addAttr(r, "modeluuid", river.getModelUuid(), true); sascha@314: ingo@1631: rivers.appendChild(r); ingo@133: } ingo@1631: ingo@1631: result.appendChild(rivers); ingo@118: ingo@118: return result; ingo@118: } ingo@118: } ingo@118: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :