annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java @ 355:6bd37edd9a80

Added handy implementation of a DataProvider. artifacts/trunk@3333 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Nov 2011 08:28:04 +0000
parents
children 079ab7c971a4
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;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 /** The (native) facet. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 protected Facet facet;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
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 /** Trivial constructor. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 public ArtifactAndFacet(
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 Artifact a,
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 Facet f
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 ) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 this.artifact = a;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 this.facet = f;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 }
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 /** Get data (to plot). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 public Object getData(CallContext context) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 return facet.getData(artifact, context);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 }
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 /** Get data (for other facet). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 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
38 return facet.provideBlackboardData(artifact, key, param, context);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 }
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 /** (Maybe) Register on blackboard (depending on facet). */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 public void register(CallContext context) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 List keys = facet.getDataProviderKeys();
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 if (keys == null) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 return;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 for (Object key: keys) {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 context.registerDataProvider(key, this);
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 }
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 /** Access the artifact. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 public Artifact getArtifact() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 return artifact;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 }
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 /** Access the (native) facet. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 public Facet getFacet() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 return facet;
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 }
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 /** Shortcut to facets name. */
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 public String getFacetName() {
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 return facet.getName();
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 }
6bd37edd9a80 Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org