Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java @ 4263:6abc8507e3c8
Add operator and station id to the artifact xml
Return also the operator and id in the xml description returned by
MeasurementStationInfoService.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 26 Oct 2012 11:15:10 +0200 |
parents | 5642a83420f2 |
children |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import java.util.List; import java.util.ArrayList; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifactdatabase.state.DefaultFacet; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; /** * Data of a duration curve. */ public class DurationCurveFacet extends DefaultFacet { private static Logger logger = Logger.getLogger(DurationCurveFacet.class); /** Blackboard data provider key for durationcurve (wqday) data. */ public static String BB_DURATIONCURVE = "durationcurve"; /** Blackboard data provider key for km of durationcurve. */ public static String BB_DURATIONCURVE_KM = "durationcurve.km"; public DurationCurveFacet() { } public DurationCurveFacet(String name, String description) { super(0, name, description); } /** * Expose state computation from WINFOArtifact. */ public Object getData(Artifact artifact, CallContext context) { logger.debug("Get data for duration curve data"); WINFOArtifact winfo = (WINFOArtifact)artifact; CalculationResult cr = (CalculationResult)winfo.compute( context, ComputeType.ADVANCE, false); return cr.getData(); } @Override public List getStaticDataProviderKeys(Artifact art) { List list = new ArrayList(); list.add(BB_DURATIONCURVE); list.add(BB_DURATIONCURVE_KM); return list; } /** * Can provide whatever getData returns and additionally the location. * @param key will respond on BB_DURATIONCURVE +KM * @param param ignored * @param context ignored * @return whatever getData delivers or location. */ @Override public Object provideBlackboardData(Artifact artifact, Object key, Object param, CallContext context ) { if (key.equals(BB_DURATIONCURVE)) { return getData(artifact, context); } else if (key.equals(BB_DURATIONCURVE_KM)) { return ((FLYSArtifact)artifact).getDataAsString("ld_locations"); } else { return null; } } /** Create a deep copy. */ @Override public Facet deepCopy() { DurationCurveFacet copy = new DurationCurveFacet(); copy.set(this); return copy; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :