view artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java @ 370:203bd78def81

Improved ClientProtocolUtils to extract min and max values for items with two new functions. artifacts/trunk@3701 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 Jan 2012 09:23:43 +0000
parents 1d11a0531242
children 33176e6e3c37
line wrap: on
line source
package de.intevation.artifactdatabase.state;

import java.util.List;

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


/**
 * A bundle of a "native" Facet and its Artifact.
 */
public class ArtifactAndFacet implements DataProvider {
    /** The Artifact. */
    protected Artifact artifact;

    /** The (native) facet. */
    protected Facet    facet;

    
    /** Trivial constructor. */
    public ArtifactAndFacet(
        Artifact a,
        Facet f
    ) {
        this.artifact   = a;
        this.facet      = f;
    }


    /** Get data (to plot). */
    public Object getData(CallContext context) {
        return facet.getData(artifact, context);
    }


    /** Get data (for other facet). */
    public Object provideData(Object key, Object param, CallContext context) {
        return facet.provideBlackboardData(artifact, key, param, context);
    }


    /** (Maybe) Register on blackboard (depending on facet). */
    public void register(CallContext context) {
        List keys = facet.getDataProviderKeys(this.artifact);
        if (keys == null) {
            return;
        }
        for (Object key: keys) {
            context.registerDataProvider(key, this);
        }
    }


    /** Access the artifact. */
    public Artifact getArtifact() {
        return artifact;
    }


    /** Access the (native) facet. */
    public Facet getFacet() {
        return facet;
    }


    /** Shortcut to facets name. */
    public String getFacetName() {
        return facet.getName();
    }


    /** Shortcut to facets name. */
    public String getFacetDescription() {
        return facet.getDescription();
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org