teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5863: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5863: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model; felix@2723: felix@2723: import org.apache.log4j.Logger; felix@2723: teichmann@5831: import org.dive4elements.artifacts.Artifact; teichmann@5831: import org.dive4elements.artifacts.CallContext; felix@2723: teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; felix@2723: teichmann@5831: import org.dive4elements.river.artifacts.FLYSArtifact; teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; felix@2723: felix@2723: felix@2723: /** felix@2733: * Access Discharge Curve of a gauge. felix@2723: */ felix@2723: public class GaugeDischargeFacet extends DataFacet { felix@2723: felix@3047: /** Private logger. */ felix@2723: private static final Logger logger = felix@2723: Logger.getLogger(GaugeDischargeFacet.class); felix@2723: felix@2723: felix@2723: public GaugeDischargeFacet() { felix@2723: } felix@2723: felix@2723: felix@3047: /** felix@3047: * @param index Index translates to index of WQ-array. felix@3047: * @param name Name of the facet. felix@3047: * @param desc Description of the facet (visible in client). felix@3047: */ felix@2723: public GaugeDischargeFacet(int index, String name, String desc) { felix@3047: super(index, name, desc, ComputeType.ADVANCE, null, felix@3047: "state.gaugedischarge.init"); felix@2723: } felix@2723: felix@2723: felix@2723: public GaugeDischargeFacet( felix@2723: int index, felix@2723: String name, felix@2723: String description, felix@2723: ComputeType type, felix@2723: String stateID, felix@2723: String hash felix@2723: felix@2723: ) { felix@2723: super(index, name, description, type, hash, stateID); felix@2723: } felix@2723: felix@2723: felix@2723: @Override felix@2723: public Facet deepCopy() { felix@2723: GaugeDischargeFacet copy = new GaugeDischargeFacet(); felix@2723: copy.set(this); felix@2723: copy.type = type; felix@2723: copy.hash = hash; felix@2723: copy.stateId = stateId; felix@2723: return copy; felix@2723: } felix@2723: felix@2723: felix@3047: /** felix@3047: * @return wqkms corresponding to gauge of artifact and index of facet. felix@3047: */ felix@2723: @Override felix@2723: public Object getData(Artifact artifact, CallContext context) { felix@2723: if (logger.isDebugEnabled()) { felix@2723: logger.debug("Get data for discharge curves at index: " + felix@2723: index + " / stateId: " + stateId); felix@2723: } felix@2723: felix@2733: if (stateId == null) { felix@2733: logger.error("GaugeDischargeFacet.getData: stateId is null."); felix@2733: } felix@2723: FLYSArtifact flys = (FLYSArtifact) artifact; felix@2723: felix@2723: CalculationResult res = (CalculationResult) felix@3045: flys.compute(context, hash, stateId, type, true); felix@2723: felix@2723: WQKms[] discharge = (WQKms[]) res.getData(); felix@2723: felix@2723: return discharge[index]; felix@2723: } felix@2723: } felix@2723: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :