annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java @ 357:1d11a0531242

Added artifact parameter to facets getDataProviderKeys. artifacts/trunk@3380 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 09 Dec 2011 16:03:19 +0000
parents 079ab7c971a4
children 33176e6e3c37
rev   line source
355
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.artifactdatabase.state;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.List;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.Artifact;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallContext;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import de.intevation.artifacts.DataProvider;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 /**
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 * A bundle of a "native" Facet and its Artifact.
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 public class ArtifactAndFacet implements DataProvider {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 /** The Artifact. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 protected Artifact artifact;
357
1d11a0531242 Added artifact parameter to facets getDataProviderKeys.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 356
diff changeset
16
355
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 /** The (native) facet. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 protected Facet facet;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 /** Trivial constructor. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 public ArtifactAndFacet(
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 Artifact a,
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 Facet f
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 ) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 this.artifact = a;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 this.facet = f;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 /** Get data (to plot). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 public Object getData(CallContext context) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 return facet.getData(artifact, context);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 /** Get data (for other facet). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 public Object provideData(Object key, Object param, CallContext context) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 return facet.provideBlackboardData(artifact, key, param, context);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 /** (Maybe) Register on blackboard (depending on facet). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 public void register(CallContext context) {
357
1d11a0531242 Added artifact parameter to facets getDataProviderKeys.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 356
diff changeset
45 List keys = facet.getDataProviderKeys(this.artifact);
355
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 if (keys == null) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 return;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 for (Object key: keys) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 context.registerDataProvider(key, this);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 /** Access the artifact. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 public Artifact getArtifact() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 return artifact;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 /** Access the (native) facet. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 public Facet getFacet() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 return facet;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 /** Shortcut to facets name. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 public String getFacetName() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 return facet.getName();
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 }
356
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
71
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
72
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
73 /** Shortcut to facets name. */
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
74 public String getFacetDescription() {
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
75 return facet.getDescription();
079ab7c971a4 Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 355
diff changeset
76 }
355
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org