view flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java @ 4324:4980659b2f22

Add gauge name to the measurement station xml response The reference gauge should be displayed in the measurement station info panel. Therefore the artifact service must return the name of the gauge.
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 30 Oct 2012 12:49:17 +0100
parents 614ffddb860e
children
line wrap: on
line source
package de.intevation.flys.artifacts.services;

import java.util.List;

import org.apache.log4j.Logger;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import de.intevation.artifacts.CallMeta;
import de.intevation.artifacts.GlobalContext;

import de.intevation.artifacts.common.ArtifactNamespaceContext;
import de.intevation.artifacts.common.utils.XMLUtils;

import de.intevation.flys.model.River;

import de.intevation.flys.artifacts.model.RiverFactory;


/**
 * This service provides information about the supported rivers by this
 * application.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class RiverService extends FLYSService {

    /** The logger used in this service.*/
    private static Logger logger = Logger.getLogger(RiverService.class);


    protected Document doProcess(
        Document      data,
        GlobalContext globalContext,
        CallMeta      callMeta
    ) {
        logger.debug("RiverService.process");

        Document result = XMLUtils.newDocument();

        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
            result,
            ArtifactNamespaceContext.NAMESPACE_URI,
            ArtifactNamespaceContext.NAMESPACE_PREFIX);

        List<River> allRivers = RiverFactory.getRivers();

        Element rivers = ec.create("rivers");

        for (River river: allRivers) {
            Element r = ec.create("river");
            ec.addAttr(r, "name", river.getName(), true);

            rivers.appendChild(r);
        }

        result.appendChild(rivers);

        return result;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org