Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 1966:f572536af56c
Configure cross_sections cache.
flys-artifacts/trunk@3377 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 09 Dec 2011 15:53:24 +0000 |
parents | 85e442933e6d |
children | 27bb2e24f7f8 |
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.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; import de.intevation.flys.artifacts.model.CrossSectionFacet; import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.states.StaticState; import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.State; import de.intevation.flys.artifacts.states.WMSBackgroundState; public class CrossSectionArtifact extends StaticFLYSArtifact { /** Access ids of doc. */ public static final String XPATH_IDS = "/art:action/art:ids/@value"; /** Name of Artifact. */ public static final String CS_ARTIFACT_NAME = "cross_section"; /** Name of state. */ public static final String STATIC_STATE_NAME = "state.cross_section"; /** Own logger. */ private static final Logger logger = Logger.getLogger(CrossSectionArtifact.class); /** Return given name. */ @Override public String getName() { return CS_ARTIFACT_NAME; } /** Store ids, create a (broken) CrossSectionFacet. */ @Override public void setup( String identifier, ArtifactFactory factory, Object context, CallMeta callMeta, Document data) { logger.info("CrossSectionArtifact.setup"); super.setup(identifier, factory, context, callMeta, data); String ids = XMLUtils.xpathString( data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE); if (ids != null && ids.length() > 0) { addStringData("ids", ids); } else { throw new IllegalArgumentException("No attribute 'ids' found!"); } List<Facet> fs = new ArrayList<Facet>(); fs.add(new CrossSectionFacet(0, "TODO GET NAME FROM DB")); StaticState state = (StaticState) getCurrentState(context); state.computeInit(this, hash(), context, callMeta, fs); if (!fs.isEmpty()) { facets.put(getCurrentStateId(), fs); } } /** Do not copy data from daddyfact. */ @Override protected void initialize( Artifact artifact, Object context, CallMeta callMeta) { // do nothing } /** * Create and return a new StaticState with charting output. */ @Override public State getCurrentState(Object cc) { State state = new StaticState(STATIC_STATE_NAME); List<Facet> fs = facets.get(getCurrentStateId()); DefaultOutput o = new DefaultOutput( "cross_section", "cross_section", "image/png", fs, "chart"); state.getOutputs().add(o); return state; } /** * Get a list containing the one and only State. * @param context ignored. * @return list with one and only state. */ @Override protected List<State> getStates(Object context) { ArrayList<State> states = new ArrayList<State>(); states.add(getCurrentState(context)); return states; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :