view flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticMorphWidthArtifact.java @ 5816:76d40d257c8c

Use the correct i18n string for gauge info grid header.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 24 Apr 2013 15:17:45 +0200
parents 4a1bd43e7aa6
children
line wrap: on
line source
package de.intevation.flys.artifacts;

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

import org.apache.log4j.Logger;
import org.w3c.dom.Document;

import de.intevation.artifactdatabase.state.DefaultOutput;
import de.intevation.artifactdatabase.state.Facet;
import de.intevation.artifactdatabase.state.FacetActivity;
import de.intevation.artifacts.ArtifactFactory;
import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallMeta;
import de.intevation.artifacts.common.utils.XMLUtils;
import de.intevation.flys.artifacts.model.minfo.MorphologicWidthFacet;
import de.intevation.flys.artifacts.resources.Resources;
import de.intevation.flys.artifacts.states.StaticState;

public class StaticMorphWidthArtifact
extends      AbstractStaticStateArtifact
{
    /** The logger for this class. */
    private static Logger logger =
        Logger.getLogger(StaticMorphWidthArtifact.class);

    private static final String NAME = "morph-width";
    private static final String STATIC_FACET_NAME = "morph-width";

    static {
        // TODO: Move to configuration.
        FacetActivity.Registry.getInstance()
            .register(NAME, FacetActivity.INACTIVE);
    }

    public static final String STATIC_STATE_NAME =
        "state.morph-width.static";

    /**
     * Trivial Constructor.
     */
    public StaticMorphWidthArtifact() {
    }

    @Override
    public String getName() {
        return NAME;
    }

    /**
     * Gets called from factory, to set things up.
     */
    @Override
    public void setup(
        String          identifier,
        ArtifactFactory factory,
        Object          context,
        CallMeta        callMeta,
        Document        data)
    {
        logger.debug("setup");

        if (logger.isDebugEnabled()) {
            logger.debug(XMLUtils.toString(data));
        }

        String code = getDatacageIDValue(data);

        if (code != null) {
                Facet facet = new MorphologicWidthFacet(
                        STATIC_FACET_NAME,
                        Resources.getMsg(
                            callMeta,
                            "facet.morphologic.width",
                            "morphologische Breite"));
                addStringData("width_id", code);
                ArrayList<Facet> facets = new ArrayList<Facet>(1);
                facets.add(facet);

                addFacets(STATIC_STATE_NAME, facets);
        }
        super.setup(identifier, factory, context, callMeta, data);
    }

    @Override
    protected void initStaticState() {

        logger.debug("initStaticState " + getName() + " " + identifier());

        StaticState state = new StaticState(STATIC_STATE_NAME);
        DefaultOutput output = new DefaultOutput(
                "general",
                "general",
                "image/png",
                "chart");

        List<Facet> facets = getFacets(STATIC_STATE_NAME);
        output.addFacets(facets);
        state.addOutput(output);

        setStaticState(state);
    }

    @Override
    protected void initialize(Artifact artifact, Object context, CallMeta meta) {
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org