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;
sascha@709:
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@687:
sascha@703: import de.intevation.flys.artifacts.model.DataFacet;
sascha@711: import de.intevation.flys.artifacts.model.ReportFacet;
sascha@709: import de.intevation.flys.artifacts.model.CalculationResult;
sascha@709:
sascha@709: import de.intevation.flys.artifacts.resources.Resources;
sascha@703:
sascha@703:
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: {
felix@1029: /** 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@742: List facets,
sascha@697: Object old
sascha@697: ) {
sascha@697: WINFOArtifact winfo = (WINFOArtifact)artifact;
ingo@692:
sascha@709: CalculationResult res;
ingo@692:
sascha@709: if (old instanceof CalculationResult) {
sascha@709: res = (CalculationResult)old;
sascha@697: }
sascha@697: else {
sascha@697: res = winfo.getDurationCurveData();
sascha@697: }
ingo@692:
sascha@709: WQDay wqday = (WQDay)res.getData();
sascha@709:
sascha@709: if (wqday != null && facets != null) {
sascha@705: Object[] args = new Object[] {
sascha@705: winfo.getRiver().getName()
sascha@705: };
ingo@692:
sascha@705: String nameW = Resources.getMsg(
sascha@705: context.getMeta(),
sascha@705: "chart.duration.curve.curve.w",
sascha@705: "",
sascha@705: args);
sascha@697:
sascha@705: String nameQ = Resources.getMsg(
sascha@705: context.getMeta(),
sascha@705: "chart.duration.curve.curve.q",
sascha@705: "",
sascha@705: args);
sascha@697:
sascha@709: Facet w = new DurationCurveFacet(DURATION_W, nameW);
sascha@709: Facet q = new DurationCurveFacet(DURATION_Q, nameQ);
sascha@697:
sascha@705: facets.add(w);
sascha@705: facets.add(q);
sascha@705:
sascha@705: facets.add(new DataFacet(CSV, "CSV data"));
sascha@711:
sascha@711: if (res.getReport().hasProblems()) {
sascha@711: facets.add(new ReportFacet());
sascha@711: }
sascha@705: }
sascha@703:
sascha@709: return res;
ingo@687: }
ingo@383: }
ingo@383: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :