view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java @ 985:8094ba4ab873

Datacage SQL schema: Using sequences for id generation now to make schema more compatible. flys-artifacts/trunk@2417 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Jul 2011 14:38:51 +0000
parents ae198bef4ba0
children e7c1ebfc2701
line wrap: on
line source
package de.intevation.flys.artifacts.states;

import java.util.List;

import org.apache.log4j.Logger;

import org.w3c.dom.Node;

import de.intevation.artifacts.CallMeta;

import de.intevation.artifacts.common.utils.Config;

import de.intevation.artifactdatabase.state.Facet;

import de.intevation.flys.artifacts.FLYSArtifact;
import de.intevation.flys.artifacts.model.WMSLayerFacet;
import de.intevation.flys.artifacts.resources.Resources;
import de.intevation.flys.artifacts.states.DefaultState.ComputeType;


public class WMSBackgroundState extends OutputState {

    public static final String I18N_DESCRIPTION = "floodmap.wmsbackground";

    public static final String XPATH_WMS_URL =
        "/artifact-database/floodmap/background-layer/@url";

    public static final String XPATH_WMS_LAYER =
        "/artifact-database/floodmap/background-layer/@layer";


    protected String url;
    protected String layer;


    private static final Logger logger = Logger.getLogger(WMSBackgroundState.class);


    @Override
    public void setup(Node config) {
        super.setup(config);

        logger.debug("WMSBackgroundState.setup()");

        this.url   = Config.getStringXPath(XPATH_WMS_URL);
        this.layer = Config.getStringXPath(XPATH_WMS_LAYER);
    }


    @Override
    public Object computeInit(
        FLYSArtifact artifact,
        String       hash,
        Object       context,
        CallMeta     meta,
        List<Facet>  facets
    ) {
        logger.debug("WMSBackgroundState.computeInit()");

        if (url == null || layer == null) {
            logger.warn("No background layers currently configured:");
            logger.warn("... add config for WMS url: " + XPATH_WMS_URL);
            logger.warn("... add config for WMS layer: " + XPATH_WMS_LAYER);
            return null;
        }

        WMSLayerFacet facet = new WMSLayerFacet(
            0,
            FLOODMAP_WMSBACKGROUND,
            Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION),
            ComputeType.INIT,
            getID(), hash,
            url);

        facet.addLayer(layer);

        facets.add(facet);

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

http://dive4elements.wald.intevation.org