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;
sascha@703:
ingo@692: import de.intevation.flys.artifacts.model.FacetTypes;
ingo@696: import de.intevation.flys.artifacts.model.WaterlevelFacet;
sascha@703: import de.intevation.flys.artifacts.model.DataFacet;
sascha@711: import de.intevation.flys.artifacts.model.ReportFacet;
ingo@692: import de.intevation.flys.artifacts.model.WQKms;
sascha@709: import de.intevation.flys.artifacts.model.CalculationResult;
sascha@703:
ingo@692: import de.intevation.flys.artifacts.resources.Resources;
ingo@687:
sascha@703:
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@742: List facets,
sascha@697: Object old
sascha@697: ) {
sascha@697: WINFOArtifact winfo = (WINFOArtifact)artifact;
ingo@692:
sascha@709: CalculationResult res = old instanceof CalculationResult
sascha@709: ? (CalculationResult)old
sascha@709: : winfo.getComputedDischargeCurveData();
ingo@692:
sascha@709: WQKms [] wqkms = (WQKms [])res.getData();
ingo@692:
sascha@709: if (facets != null && wqkms.length > 0) {
sascha@709: for (int i = 0; i < wqkms.length; ++i) {
sascha@709:
sascha@709: Object[] args = new Object[] {
sascha@709: winfo.getRiver().getName(),
sascha@709: wqkms[i].getName()
sascha@709: };
sascha@709:
sascha@709: String name = Resources.getMsg(
sascha@709: context.getMeta(),
sascha@709: "chart.computed.discharge.curve.curve.label",
sascha@709: "",
sascha@709: args);
sascha@709:
sascha@709: facets.add(new WaterlevelFacet(i, COMPUTED_DISCHARGE_Q, name));
sascha@731: facets.add(new WaterlevelFacet(i, AT, "AT data"));
sascha@697: }
sascha@711:
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@697:
sascha@709: return res;
ingo@687: }
ingo@392: }
ingo@392: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :