ingo@392: package de.intevation.flys.artifacts.states;
ingo@392:
ingo@687: import java.util.List;
ingo@687:
ingo@392: import org.apache.log4j.Logger;
ingo@392:
ingo@692: import de.intevation.artifacts.CallContext;
ingo@692:
ingo@687: import de.intevation.artifactdatabase.state.Facet;
ingo@687:
ingo@687: import de.intevation.flys.artifacts.FLYSArtifact;
ingo@687: import de.intevation.flys.artifacts.WINFOArtifact;
ingo@692: import de.intevation.flys.artifacts.model.FacetTypes;
ingo@696: import de.intevation.flys.artifacts.model.WaterlevelFacet;
ingo@692: import de.intevation.flys.artifacts.model.WQKms;
ingo@692: import de.intevation.flys.artifacts.resources.Resources;
ingo@687:
ingo@392: /**
ingo@392: * The final state that will be reached after the discharge curve calculation
ingo@392: * mode has been chosen.
ingo@392: *
ingo@392: * @author Ingo Weinzierl
ingo@392: */
ingo@692: public class ComputedDischargeCurveState
ingo@692: extends DefaultState
ingo@692: implements FacetTypes
ingo@692: {
ingo@392: /** The logger that is used in this state.*/
ingo@392: private static Logger logger =
ingo@392: Logger.getLogger(ComputedDischargeCurveState.class);
ingo@392:
sascha@660: public ComputedDischargeCurveState() {
ingo@392: }
ingo@687:
ingo@687:
ingo@687: @Override
sascha@697: public Object computeAdvance(
sascha@697: FLYSArtifact artifact,
sascha@697: String hash,
sascha@697: CallContext context,
sascha@697: List facets,
sascha@697: Object old
sascha@697: ) {
sascha@697: WINFOArtifact winfo = (WINFOArtifact)artifact;
ingo@692:
sascha@697: WQKms res;
ingo@692:
sascha@697: if (old instanceof WQKms []) {
sascha@697: res = ((WQKms [])old)[0];
sascha@697: }
sascha@697: else {
sascha@697: res = winfo.getComputedDischargeCurveData();
ingo@692:
sascha@697: if (res == null) {
sascha@697: logger.debug("No results given.");
sascha@697: return null;
sascha@697: }
sascha@697: }
ingo@692:
sascha@697: Object[] args = new Object[] {
sascha@697: winfo.getRiver().getName(),
sascha@697: res.getName()
sascha@697: };
ingo@692:
sascha@697: String name = Resources.getMsg(
sascha@697: context.getMeta(),
sascha@697: "chart.computed.discharge.curve.curve.label",
sascha@697: "",
sascha@697: args);
sascha@697:
sascha@697: Facet q = new WaterlevelFacet(0, COMPUTED_DISCHARGE_Q, name);
sascha@697:
sascha@697: facets.add(q);
sascha@697:
sascha@697: return new WQKms[] { res };
ingo@687: }
ingo@392: }
ingo@392: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :