view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java @ 3078:0e0efd1acb4f

Added getter for current km in chart generator (used for navigation in fix analysis charts). flys-artifacts/trunk@4674 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 15 Jun 2012 12:16:49 +0000
parents 0d3dd8230064
children 8ad8a227d983
line wrap: on
line source
package de.intevation.flys.artifacts.states;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import de.intevation.artifacts.CallContext;

import de.intevation.artifactdatabase.state.Facet;

import de.intevation.flys.artifacts.FLYSArtifact;
import de.intevation.flys.artifacts.MINFOArtifact;
import de.intevation.flys.artifacts.model.DataFacet;
import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.model.CalculationResult;
import de.intevation.flys.artifacts.model.sq.SQCurveFacet;
import de.intevation.flys.artifacts.model.sq.SQMeasurementFacet;
import de.intevation.flys.artifacts.model.sq.SQOutlierFacet;
import de.intevation.flys.artifacts.model.sq.SQRelationCalculation;
import de.intevation.flys.artifacts.states.DefaultState;

/**
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class SQRelation extends DefaultState implements FacetTypes {

    private static Logger logger = Logger.getLogger(SQRelation.class);


    public SQRelation() {
    }


    @Override
    public Object computeAdvance(
        FLYSArtifact artifact,
        String       hash,
        CallContext  context,
        List<Facet>  facets,
        Object       old
    ) {
        logger.debug("SQRelation.computeAdvance");

        List<Facet> newFacets = new ArrayList<Facet>();

        CalculationResult res = old instanceof CalculationResult
            ? (CalculationResult) old
            : new SQRelationCalculation().calculate((MINFOArtifact) artifact);

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

        logger.error("Facet creation NOT IMPLEMENTED!");
        // TODO
        //for (int idx = 0; idx < res.length; idx++) {
            int idx = 0;
            createFacets(newFacets, idx);
        //}

        Facet csv = new DataFacet(
            CSV, "CSV data", ComputeType.ADVANCE, hash, id);

        Facet pdf = new DataFacet(
            PDF, "PDF data", ComputeType.ADVANCE, hash, id);

        newFacets.add(csv);
        newFacets.add(pdf);

        logger.debug("Created " + newFacets.size() + " new Facets.");

        facets.addAll(newFacets);

        return res;
    }


    protected void createFacets(List<Facet> container, int idx) {
        // TODO Create facets for each parameter type (A-F)
        Facet measurements, outliers, curve;
        measurements = new SQMeasurementFacet(idx, SQ_A_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_A_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_A_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);

        measurements = new SQMeasurementFacet(idx, SQ_B_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_B_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_B_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);

        measurements = new SQMeasurementFacet(idx, SQ_C_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_C_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_C_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);

        measurements = new SQMeasurementFacet(idx, SQ_D_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_D_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_D_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);

        measurements = new SQMeasurementFacet(idx, SQ_E_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_E_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_E_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);

        measurements = new SQMeasurementFacet(idx, SQ_F_MEASUREMENT, "TODO");
        outliers     = new SQOutlierFacet(idx, SQ_F_OUTLIER, "TODO");
        curve        = new SQCurveFacet(idx, SQ_F_CURVE, "TODO");

        container.add(measurements);
        container.add(outliers);
        container.add(curve);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org