Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | ccc955ef8811 |
children |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import de.intevation.artifacts.Artifact; | |
7 import de.intevation.artifacts.CallContext; | |
8 | |
9 import de.intevation.artifactdatabase.state.Facet; | |
10 import de.intevation.artifactdatabase.state.DefaultFacet; | |
11 | |
12 | |
13 /** | |
14 * Facet that writes artifact-uui and facet index on the blackboard, | |
15 * delivers data if asked so. | |
16 */ | |
17 public class BlackboardDataFacet extends DefaultFacet { | |
18 | |
19 public BlackboardDataFacet() {} | |
20 | |
21 /** Do not instantiate a BlackboardDataFacet, subclass it instead. */ | |
22 public BlackboardDataFacet(int idx, String name, String description) { | |
23 super(idx, name, description); | |
24 } | |
25 | |
26 | |
27 /** Do not instantiate a BlackboardDataFacet, subclass it instead. */ | |
28 public BlackboardDataFacet(String name, String description) { | |
29 super(0, name, description); | |
30 } | |
31 | |
32 | |
33 /** Define key to which to respond when asked for 'blackboard' | |
34 * (DataProvider)- data. */ | |
35 public String areaDataKey(Artifact art) { | |
36 return art.identifier() + ":" + getName() + ":" + getIndex(); | |
37 } | |
38 | |
39 | |
40 /** Hey, We can ArtifactUUID+:+FacetName+:+FacetIndex (i.e. getData)! */ | |
41 @Override | |
42 public List getStaticDataProviderKeys(Artifact art) { | |
43 List list = new ArrayList(); | |
44 list.add(areaDataKey(art)); | |
45 return list; | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Can provide whatever getData returns. | |
51 * @param key will respond on uuid+index | |
52 * @param param ignored | |
53 * @param context ignored | |
54 * @return whatever getData delivers. | |
55 */ | |
56 @Override | |
57 public Object provideBlackboardData(Artifact artifact, | |
58 Object key, | |
59 Object param, | |
60 CallContext context | |
61 ) { | |
62 if (key.equals(areaDataKey(artifact))) { | |
63 return getData(artifact, context); | |
64 } | |
65 else { | |
66 return null; | |
67 } | |
68 } | |
69 | |
70 /** Copy deeply. */ | |
71 @Override | |
72 public Facet deepCopy() { | |
73 BlackboardDataFacet copy = new BlackboardDataFacet(); | |
74 copy.set(this); | |
75 return copy; | |
76 } | |
77 } | |
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |