Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticMorphWidthArtifact.java @ 5777:e95427ed80e5
Merged
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 21 Apr 2013 10:46:59 +0200 |
parents | 7ac111db8a07 |
children | 4a1bd43e7aa6 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticMorphWidthArtifact.java Sun Apr 21 10:46:59 2013 +0200 @@ -0,0 +1,110 @@ +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.BedHeightFacet; +import de.intevation.flys.artifacts.model.minfo.BedHeightFactory; +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 :