view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java @ 1057:d4a5d3941cc0

Build out/facet filter from XML document passed at creation time. flys-artifacts/trunk@2527 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 22 Aug 2011 16:37:12 +0000
parents eeebf8514c7f
children b1b0a0b61845
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

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

import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.ArtifactNamespaceContext;
import de.intevation.artifacts.CallContext;

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

import de.intevation.artifactdatabase.state.DefaultFacet;

import de.intevation.flys.artifacts.states.DefaultState.ComputeType;


public class WMSLayerFacet extends DefaultFacet {

    protected ComputeType  type;
    protected List<String> layers;
    protected String       stateId;
    protected String       hash;
    protected String       url;
    protected String       extent;
    protected String       srid;


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


    public WMSLayerFacet(int index, String name, String description) {
        this(index, name, description, ComputeType.FEED, null, null);
    }


    public WMSLayerFacet(
        int         index,
        String      name,
        String      description,
        ComputeType type,
        String      stateId,
        String      hash

    ) {
        super(index, name, description);
        this.layers  = new ArrayList<String>();
        this.type    = type;
        this.stateId = stateId;
        this.hash    = hash;
    }


    public WMSLayerFacet(
        int         index,
        String      name,
        String      description,
        ComputeType type,
        String      stateId,
        String      hash,
        String      url
    ) {
        this(index, name, description, type, stateId, hash);
        this.url = url;
    }


    public void addLayer(String name) {
        if (name != null && name.length() > 0) {
            layers.add(name);
        }
    }


    public void setExtent(String extent) {
        if (extent != null) {
            this.extent = extent;
        }
    }


    public void setSrid(String srid) {
        if (srid != null) {
            this.srid = srid;
        }
    }


    public Object getData(Artifact artifact, CallContext context) {
        return null;
    }


    @Override
    public Node toXML(Document doc) {
        ElementCreator ec = new ElementCreator(
            doc,
            ArtifactNamespaceContext.NAMESPACE_URI,
            ArtifactNamespaceContext.NAMESPACE_PREFIX);

        Element facet = ec.create("facet");
        ec.addAttr(facet, "description", description, true);
        ec.addAttr(facet, "index", String.valueOf(index), true);
        ec.addAttr(facet, "name", name, true);
        ec.addAttr(facet, "url", url, true);
        ec.addAttr(facet, "layers", layers.get(0), true);
        ec.addAttr(facet, "extent", extent != null ? extent : "", true);
        ec.addAttr(facet, "srid", srid != null ? srid : "", true);

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

http://dive4elements.wald.intevation.org