view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/QSectorSingleState.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 6442f317a0c7
children e8a4d2fd25cc
line wrap: on
line source
package de.intevation.flys.artifacts.states;

import java.util.List;

import org.apache.log4j.Logger;

import de.intevation.artifacts.CallMeta;
import de.intevation.artifacts.CallContext;

import de.intevation.artifactdatabase.state.Facet;

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

import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.model.QSectorFacet;

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

/**
 * The only state for an QSectorArtifact.
 */
public class QSectorSingleState
extends      DefaultState
implements   FacetTypes
{
    /** Developer-centric description of facet. */
    public static final String I18N_DESCRIPTION
        = "facet.qsector";

    /** The logger that is used in this state. */
    private static final Logger logger =
        Logger.getLogger(QSectorSingleState.class);


    /**
     * Add QSectorFacets to list of Facets.
     *
     * @param artifact Ignored.
     * @param hash Ignored.
     * @param meta CallMeta to be used for internationalization.
     * @param facets List to add QSectorFacet to.
     *
     * @return null.
     */
    public Object compute(
        FLYSArtifact artifact,
        String       hash,
        CallMeta     meta,
        List<Facet>  facets
    ) {
        logger.debug("QSectorSingleState.compute()");
        QSectorArtifact points = (QSectorArtifact) artifact;

        QSectorFacet qfacet = new QSectorFacet(
            0,
            QSECTOR,
            Resources.getMsg(meta, "qsectors", "Q Sectors"));

        facets.add(qfacet);

        return null;
    }


    /** Call compute. */
    @Override
    public Object computeInit(
        FLYSArtifact artifact,
        String       hash,
        Object       context,
        CallMeta     meta,
        List<Facet>  facets
     ) {
        return compute(artifact, hash, meta, facets);
    }


    /** Call compute. */
    @Override
    public Object computeFeed(
        FLYSArtifact artifact,
        String hash,
        CallContext context,
        List<Facet> facets,
        Object old
    ) {
        return compute(artifact, hash, context.getMeta(), facets);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org