view flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java @ 455:7137ef65c17c

Reintroduced titles for the "W for unausgeglichene Abfluesse". flys-artifacts/trunk@1952 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 19 May 2011 09:54:57 +0000
parents 4aa078e28cfd
children a63d79107289
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.common.ArtifactNamespaceContext;
import de.intevation.artifacts.common.utils.XMLUtils;

import de.intevation.artifactdatabase.DefaultService;

import de.intevation.flys.backend.SessionHolder;
import de.intevation.flys.model.River;

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

import org.hibernate.Session;

/**
 * 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 DefaultService {

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


    /**
     * The default constructor.
     */
    public RiverService() {
    }


    public Document process(
        Document data,
        Object   globalContext,
        CallMeta callMeta)
    {
        logger.debug("RiverService.process");

        Document result = XMLUtils.newDocument();

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

        Session session = SessionHolder.acquire();
        try {
            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);
        }
        finally {
            session.close();
            SessionHolder.release();
        }

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

http://dive4elements.wald.intevation.org