teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model; felix@2133: teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; teichmann@5831: import org.dive4elements.artifacts.Artifact; teichmann@5831: import org.dive4elements.artifacts.CallContext; teichmann@5831: import org.dive4elements.artifacts.DataProvider; teichmann@5831: import org.dive4elements.river.artifacts.HYKArtifact; teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; teichmann@5831: import org.dive4elements.river.model.FastCrossSectionLine; christian@3602: felix@2133: import java.util.List; felix@2133: felix@2133: import org.apache.log4j.Logger; felix@2133: felix@2133: felix@2133: /** felix@2133: * Trival Facet for HYKs felix@2133: */ felix@2133: public class HYKFacet felix@2133: extends DataFacet felix@2133: implements FacetTypes { felix@2133: teichmann@8202: /** House log. */ teichmann@8202: private static Logger log = Logger.getLogger(HYKFacet.class); felix@2133: felix@2133: /** Trivial constructor, set (maybe localized) description. */ felix@2133: public HYKFacet(int idx, String description) { felix@2133: super(idx, HYK, description, ComputeType.FEED, null, null); felix@2133: } felix@2133: felix@2133: felix@2133: /** felix@2150: * Set km from cross section- master to HYKArtifact, then fire up felix@2150: * computation. felix@2150: * felix@2133: * @param art artifact to get data from. felix@2133: * @param context ignored felix@2133: */ christian@3602: @Override christian@3602: public Object getData(Artifact art, CallContext context) { teichmann@8202: log.debug("HYKFacet.getData"); felix@2133: felix@2133: String dataKey = CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA; felix@2133: felix@2133: List providers = context.getDataProvider(dataKey); felix@2133: if (providers.size() < 1) { tom@8856: log.warn("Could not find Cross-Section data provider " tom@8856: + "to get master cs km."); felix@2133: return null; felix@2133: } sascha@3076: tom@8856: FastCrossSectionLine crossSection = tom@8856: (FastCrossSectionLine)providers.get(0).provideData( tom@8856: dataKey, null, context); felix@2133: christian@3602: if(crossSection == null) { teichmann@8202: log.debug("getData: crossSection is null"); christian@3602: return null; christian@3602: } christian@3602: felix@2133: double km = crossSection.getKm(); teichmann@8202: log.debug("HYKFacet.getData: Master Cross Section is at km: " + km); felix@2133: felix@2133: // Set this km at hyk artifact to be evaluated. felix@2133: HYKArtifact hyk = (HYKArtifact) art; felix@2133: hyk.setKm(km); felix@2133: felix@2133: return hyk.compute(context, hash, stateId, type, false); felix@2133: } felix@2133: felix@2133: felix@2133: /** Do a deep copy. */ sascha@3076: @Override felix@2133: public Facet deepCopy() { felix@2133: HYKFacet copy = new HYKFacet(this.index, this.description); felix@2133: copy.set(this); felix@2133: return copy; felix@2133: } felix@2133: } felix@2133: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :