Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/StaticMorphWidthArtifact.java @ 6693:88bb0c794833
issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
This allows us to use the GaugeDischargeArtifact for any discharge
tables that we have in our database. The name of the created facet
is taken from the ids string as is also usual in the WMS artifacts.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 29 Jul 2013 12:19:57 +0200 |
parents | af13ceeba52a |
children | 8d5ca5175038 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.dive4elements.artifactdatabase.state.DefaultOutput; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifactdatabase.state.FacetActivity; import org.dive4elements.artifacts.ArtifactFactory; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.river.artifacts.model.minfo.MorphologicWidthFacet; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.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 :