view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java @ 3057:febc39e77672

Make it compilable again flys-artifacts/trunk@4633 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 11 Jun 2012 09:58:54 +0000
parents ccc955ef8811
children
line wrap: on
line source
package de.intevation.flys.artifacts.model;

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

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

import de.intevation.artifactdatabase.state.Facet;
import de.intevation.artifactdatabase.state.DefaultFacet;


/**
 * Facet that writes artifact-uui and facet index on the blackboard,
 * delivers data if asked so.
 */
public class BlackboardDataFacet extends DefaultFacet {

    public BlackboardDataFacet() {}

    /** Do not instantiate a BlackboardDataFacet, subclass it instead. */
    public BlackboardDataFacet(int idx, String name, String description) {
        super(idx, name, description);
    }


    /** Do not instantiate a BlackboardDataFacet, subclass it instead. */
    public BlackboardDataFacet(String name, String description) {
        super(0, name, description);
    }


    /** Define key to which to respond when asked for 'blackboard'
     * (DataProvider)- data. */
    public String areaDataKey(Artifact art) {
        return art.identifier() + ":" + getName() + ":" + getIndex();
    }


    /** Hey, We can ArtifactUUID+:+FacetName+:+FacetIndex (i.e. getData)! */
    @Override
    public List getStaticDataProviderKeys(Artifact art) {
        List list = new ArrayList();
        list.add(areaDataKey(art));
        return list;
    }


    /**
     * Can provide whatever getData returns.
     * @param key      will respond on uuid+index
     * @param param    ignored
     * @param context  ignored
     * @return whatever getData delivers.
     */
    @Override
    public Object provideBlackboardData(Artifact artifact,
        Object key,
        Object param,
        CallContext context
    ) {
        if (key.equals(areaDataKey(artifact))) {
            return getData(artifact, context);
        }
        else {
            return null;
        }
    }

    /** Copy deeply. */
    @Override
    public Facet deepCopy() {
        BlackboardDataFacet copy = new BlackboardDataFacet();
        copy.set(this);
        return copy;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org