view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java @ 2253:707b47d8c554

Dont sort the data series in reference curve. flys-artifacts/trunk@3903 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 03 Feb 2012 14:53:11 +0000
parents c9c788eea200
children 0dcb8326be08
line wrap: on
line source
package de.intevation.flys.artifacts.states;

import de.intevation.artifactdatabase.state.Facet;

import de.intevation.artifacts.CallContext;

import de.intevation.flys.artifacts.FLYSArtifact;
import de.intevation.flys.artifacts.WINFOArtifact;

import de.intevation.flys.artifacts.model.CalculationResult;
import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.model.ReferenceCurveFacet;
import de.intevation.flys.artifacts.model.ReportFacet;
import de.intevation.flys.artifacts.model.WW;

import de.intevation.flys.artifacts.resources.Resources;

import java.util.List;

import org.apache.log4j.Logger;


public class ReferenceCurveState
extends      DefaultState
implements   FacetTypes
{
    private static Logger log = Logger.getLogger(ReferenceCurveState.class);

    public ReferenceCurveState() {
    }

    @Override
    public Object computeAdvance(
        FLYSArtifact artifact,
        String       hash,
        CallContext  context,
        List<Facet>  facets,
        Object       old
    ) {

        if (!(artifact instanceof WINFOArtifact)) {
            return null;
        }

        WINFOArtifact winfo = (WINFOArtifact)artifact;

        CalculationResult res = old instanceof CalculationResult
            ? (CalculationResult)old
            : winfo.getReferenceCurveData();

        if (facets == null) {
            return res;
        }

        WW [] wws = (WW [])res.getData();

        for (int i = 0; i < wws.length; ++i) {
            facets.add(new ReferenceCurveFacet(i,
                REFERENCE_CURVE,
                Resources.getMsg(context.getMeta(), REFERENCE_CURVE, REFERENCE_CURVE)));
        }

        if (wws.length > 0) {
            // TODO: Add CSV/PDF facets.
        }

        if (res.getReport().hasProblems()) {
            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
        }

        return res;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org