Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java @ 5181:9d36ddf7dbd3
Change IllegalArgumentException to HibernateException.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 07 Mar 2013 10:44:27 +0100 |
parents | cd44d28d0fbc |
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.BedHeightFacet; import de.intevation.flys.artifacts.model.minfo.BedHeightFactory; import de.intevation.flys.artifacts.states.StaticState; public class BedHeightsArtifact extends AbstractStaticStateArtifact { /** The logger for this class. */ private static Logger logger = Logger.getLogger(BedHeightsArtifact.class); private static final String NAME = "bedheights"; private static final String STATIC_FACET_NAME = "bedheight"; static { // TODO: Move to configuration. FacetActivity.Registry.getInstance() .register(NAME, FacetActivity.INACTIVE); } public static final String STATIC_STATE_NAME = "state.additional_bedheights.static"; /** Data Item name to know whether we are Heighmarks and reveive * some data slightly different. */ public static final String DATA_HEIGHT_TYPE = "height_marks"; /** * Trivial Constructor. */ public BedHeightsArtifact() { logger.debug("BedHeightsArtifact.BedHeightsArtifact"); } @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("BedHeightsArtifact.setup"); if (logger.isDebugEnabled()) { logger.debug(XMLUtils.toString(data)); } String code = getDatacageIDValue(data); if (code != null) { String [] parts = code.split("-"); if (parts.length >= 4) { String name = parts[0]; String type = parts[1]; String btype = type; int hId = Integer.parseInt(parts[2]); if (name.equals("bedheight")) { addStringData("type", type); addStringData("height_id", parts[2]); addStringData("time", parts[3]); } if (type.equals("singlevalues")) { btype = "single"; } String bedHName = BedHeightFactory.getHeightName(btype, hId); Facet facet = new BedHeightFacet( STATIC_FACET_NAME, bedHName, type); 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) { // do not clone facets, etc. from master artifact logger.debug("initialize"); importData((FLYSArtifact)artifact, "ld_from"); importData((FLYSArtifact)artifact, "ld_to"); logger.debug("ld_from " + getDataAsString("ld_from")); logger.debug("ld_to " + getDataAsString("ld_to")); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :