Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java @ 1769:bbe12d77710d
Prepare rendering of added other (static) WKms and Differences in LongitudinalSection Diagrams.
flys-artifacts/trunk@3090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 26 Oct 2011 12:54:22 +0000 |
parents | b2730e31ff5b |
children | c62ff9e72cea |
line wrap: on
line source
package de.intevation.flys.artifacts; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Document; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.model.River; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.states.DefaultState; public class RiverAxisArtifact extends StaticFLYSArtifact { public static final String NAME = "riveraxis"; public static final String XPATH_IDS = "/art:action/art:ids/@value"; private static final Logger logger = Logger.getLogger(RiverAxisArtifact.class); @Override public String getName() { return NAME; } @Override public void setup( String identifier, ArtifactFactory factory, Object context, CallMeta callMeta, Document data) { logger.debug("RiverAxisArtifact.setup"); super.setup(identifier, factory, context, callMeta, data); String ids = XMLUtils.xpathString( data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE); String[] splitted = ids != null ? ids.split(" ") : null; if (splitted != null && splitted.length > 0) { try { int river_id = Integer.parseInt(splitted[0]); River river = RiverFactory.getRiver(river_id); if (river == null) { throw new IllegalArgumentException( "No river found for id: " + river_id); } String name = river.getName(); addData("river", new DefaultStateData("river",null,null,name)); List<Facet> fs = new ArrayList<Facet>(); DefaultState state = (DefaultState) getCurrentState(context); state.computeInit(this, hash(), context, callMeta, fs); if (!fs.isEmpty()) { facets.addAll(fs); } } catch (NumberFormatException nfe) { logger.error("Could not create Artifact: " + nfe.getMessage()); throw new IllegalArgumentException("No river id given."); } } } @Override protected void initialize( Artifact artifact, Object context, CallMeta callMeta) { // do nothing } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :