view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQMeasurementFacet.java @ 4255:670e98f5a441

Fixed leak while merging facets. The ThemeList that is used by OutputHelper to sort the Facets for an Output now uses a list to store the ManagedFacets. The correct order is made up by sorting the List using Collections.sort() function of the Java JDK. Therfore, the ManagedFacet class implements the Comparable interface. The return value of its compareTo(other) method depends on the value of the 'position' field.
author Ingo Weinzierl <weinzierl.ingo@googlemail.com>
date Thu, 25 Oct 2012 14:01:46 +0200
parents 1df6984628c3
children
line wrap: on
line source
package de.intevation.flys.artifacts.model.sq;

import org.apache.log4j.Logger;

import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;

import de.intevation.flys.artifacts.FLYSArtifact;
import de.intevation.flys.artifacts.model.CalculationResult;
import de.intevation.flys.artifacts.model.DataFacet;
import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.states.DefaultState.ComputeType;


/**
 * Facet to show the outliers in a sq relation.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class SQMeasurementFacet extends DataFacet implements FacetTypes {

    private static final Logger log = Logger.getLogger(SQMeasurementFacet.class);


    private int fractionIdx;


    public SQMeasurementFacet() {
    }


    public SQMeasurementFacet(
        int    idx,
        int    fractionIdx,
        String name,
        String description,
        String hash,
        String stateId
    ) {
        super(idx, name, description, ComputeType.ADVANCE, hash, stateId);
        this.fractionIdx = fractionIdx;
    }


    @Override
    public Object getData(Artifact artifact, CallContext context) {
        log.debug("SQMeasurementFacet.getData");

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

        FLYSArtifact flys = (FLYSArtifact) artifact;

        CalculationResult res = (CalculationResult) flys.compute(
            context, ComputeType.ADVANCE, false);

        SQResult[]       result  = (SQResult[]) res.getData();
        SQFractionResult fResult = result[index].getFraction(fractionIdx);

        return fResult.getMeasurements();
    }


    @Override
    public SQMeasurementFacet deepCopy() {
        SQMeasurementFacet copy = new SQMeasurementFacet();
        copy.set(this);

        return copy;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org