ingo@696: package de.intevation.flys.artifacts.model; ingo@696: felix@2746: import java.util.List; felix@2746: import java.util.ArrayList; felix@2746: ingo@696: import org.apache.log4j.Logger; ingo@696: ingo@696: import de.intevation.artifacts.Artifact; ingo@696: import de.intevation.artifacts.CallContext; ingo@696: ingo@696: import de.intevation.artifactdatabase.state.DefaultFacet; sascha@1061: import de.intevation.artifactdatabase.state.Facet; ingo@696: felix@2746: import de.intevation.flys.artifacts.FLYSArtifact; ingo@696: import de.intevation.flys.artifacts.WINFOArtifact; sascha@697: sascha@697: import de.intevation.flys.artifacts.states.DefaultState.ComputeType; ingo@696: ingo@696: felix@2746: /** felix@2746: * Data of a duration curve. felix@2746: */ ingo@696: public class DurationCurveFacet extends DefaultFacet { ingo@696: ingo@696: private static Logger logger = Logger.getLogger(DurationCurveFacet.class); ingo@696: felix@2746: /** Blackboard data provider key for durationcurve (wqday) data. */ felix@2746: public static String BB_DURATIONCURVE = "durationcurve"; felix@2746: felix@2746: /** Blackboard data provider key for km of durationcurve. */ felix@2746: public static String BB_DURATIONCURVE_KM = "durationcurve.km"; felix@2746: sascha@1061: public DurationCurveFacet() { sascha@1061: } ingo@696: sascha@709: public DurationCurveFacet(String name, String description) { sascha@709: super(0, name, description); ingo@696: } ingo@696: ingo@696: felix@2746: /** felix@2746: * Expose state computation from WINFOArtifact. felix@2746: */ ingo@696: public Object getData(Artifact artifact, CallContext context) { sascha@709: logger.debug("Get data for duration curve data"); ingo@696: sascha@709: WINFOArtifact winfo = (WINFOArtifact)artifact; ingo@696: sascha@709: CalculationResult cr = (CalculationResult)winfo.compute( sascha@709: context, ComputeType.ADVANCE, false); sascha@709: sascha@709: return cr.getData(); ingo@696: } sascha@1061: felix@2746: felix@2746: @Override felix@2746: public List getStaticDataProviderKeys(Artifact art) { felix@2746: List list = new ArrayList(); felix@2746: list.add(BB_DURATIONCURVE); felix@2746: list.add(BB_DURATIONCURVE_KM); felix@2746: return list; felix@2746: } felix@2746: felix@2746: felix@2746: /** felix@2746: * Can provide whatever getData returns and additionally the location. felix@2746: * @param key will respond on BB_DURATIONCURVE +KM felix@2746: * @param param ignored felix@2746: * @param context ignored felix@2746: * @return whatever getData delivers or location. felix@2746: */ felix@2746: @Override felix@2746: public Object provideBlackboardData(Artifact artifact, felix@2746: Object key, felix@2746: Object param, felix@2746: CallContext context felix@2746: ) { felix@2746: if (key.equals(BB_DURATIONCURVE)) { felix@2746: return getData(artifact, context); felix@2746: } felix@2746: else if (key.equals(BB_DURATIONCURVE_KM)) { felix@2746: return ((FLYSArtifact)artifact).getDataAsString("ld_locations"); felix@2746: } felix@2746: else { felix@2746: return null; felix@2746: } felix@2746: } felix@2746: felix@2746: felix@2746: /** Create a deep copy. */ sascha@3076: @Override sascha@1061: public Facet deepCopy() { sascha@1061: DurationCurveFacet copy = new DurationCurveFacet(); sascha@1061: copy.set(this); sascha@1061: return copy; sascha@1061: } ingo@696: } ingo@696: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :