ingo@383: package de.intevation.flys.artifacts.states;
ingo@383:
ingo@687: import java.util.List;
ingo@687:
ingo@383: import org.apache.log4j.Logger;
ingo@383:
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@696: import de.intevation.flys.artifacts.model.DurationCurveFacet;
ingo@692: import de.intevation.flys.artifacts.model.FacetTypes;
ingo@692: import de.intevation.flys.artifacts.model.WQDay;
ingo@692: import de.intevation.flys.artifacts.resources.Resources;
ingo@687:
ingo@383: /**
ingo@383: * The final state that will be reached after the duration curve calculation
ingo@383: * mode has been chosen.
ingo@383: *
ingo@383: * @author Ingo Weinzierl
ingo@383: */
ingo@692: public class DurationCurveState
ingo@692: extends DefaultState
ingo@692: implements FacetTypes
ingo@692: {
ingo@383: /** The logger that is used in this state.*/
ingo@383: private static Logger logger = Logger.getLogger(DurationCurveState.class);
ingo@383:
sascha@660: public DurationCurveState() {
ingo@383: }
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: WQDay res;
ingo@692:
sascha@697: if (old instanceof WQDay []) {
sascha@697: res = ((WQDay [])old)[0];
sascha@697: }
sascha@697: else {
sascha@697: res = winfo.getDurationCurveData();
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: };
ingo@692:
sascha@697: String nameW = Resources.getMsg(
sascha@697: context.getMeta(),
sascha@697: "chart.duration.curve.curve.w",
sascha@697: "",
sascha@697: args);
ingo@692:
sascha@697: String nameQ = Resources.getMsg(
sascha@697: context.getMeta(),
sascha@697: "chart.duration.curve.curve.q",
sascha@697: "",
sascha@697: args);
sascha@697:
sascha@697: Facet w = new DurationCurveFacet(0, DURATION_W, nameW);
sascha@697: Facet q = new DurationCurveFacet(0, DURATION_Q, nameQ);
sascha@697:
sascha@697: facets.add(w);
sascha@697: facets.add(q);
sascha@697:
sascha@697: return new WQDay[] { res };
ingo@687: }
ingo@383: }
ingo@383: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :