# HG changeset patch # User Felix Wolfsteller # Date 1324371651 0 # Node ID 2bb160b2768e70a4abe8829bc98a7b6470d48d95 # Parent 7a7c5cad4fe13e65eefd39b8d2c6b9f14b21b391 New facet, will ease converting other facets to be able to contribute to area computations. flys-artifacts/trunk@3481 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7a7c5cad4fe1 -r 2bb160b2768e flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Dec 20 07:01:58 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Dec 20 09:00:51 2011 +0000 @@ -1,3 +1,13 @@ +2011-12-20 Felix Wolfsteller + + Introduced new Facet that will deliver whatever getData returns via + blackbord under key which is defined by convention. Attention, the + data is not cached if handled this way. + + * src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java: + New facet, will be useful for easing implementation of facets that + can contribute to area-computations. + 2011-12-20 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/VisibleAttribute.java: diff -r 7a7c5cad4fe1 -r 2bb160b2768e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java Tue Dec 20 09:00:51 2011 +0000 @@ -0,0 +1,55 @@ +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.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); + } + + + /** Hey, We can ArtifactUUID+FacetIndex (i.e. getData)! */ + public List getDataProviderKeys(Artifact art) { + List list = new ArrayList(); + list.add(art.identifier() + getIndex()); + return list; + } + + + /** + * Can provide whatever getData returns. + * @param key will respond on uuid+index + * @param param ignored + * @param context ignored + * @return whatever getData delivers. + */ + public Object provideBlackboardData(Artifact artifact, + Object key, + Object param, + CallContext context + ) { + if (key.equals(artifact.identifier() + getIndex())) { + return getData(artifact, context); + } + else { + return null; + } + } + +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :