Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java @ 453:a2efc9d65a11 2.9.8
Doc.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 28 Dec 2012 13:32:32 +0100 |
parents | 71ff234713a6 |
children |
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 |
377
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
20 /** An alternative facet description that might be set from outside. */ |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
21 protected String facetDescription; |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
22 |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
23 |
355
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 /** Trivial constructor. */ |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 public ArtifactAndFacet( |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 Artifact a, |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 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 this.artifact = a; |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 this.facet = f; |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 } |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
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 /** Get data (to plot). */ |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 public Object getData(CallContext context) { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 return facet.getData(artifact, context); |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 } |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 |
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 /** Get data (for other facet). */ |
375
33176e6e3c37
Added Override annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
357
diff
changeset
|
41 @Override |
355
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 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
|
43 return facet.provideBlackboardData(artifact, key, param, context); |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 } |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 /** (Maybe) Register on blackboard (depending on facet). */ |
375
33176e6e3c37
Added Override annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
357
diff
changeset
|
48 @Override |
355
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 public void register(CallContext context) { |
378
71ff234713a6
Pass context when asking facets for keys to write on blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
377
diff
changeset
|
50 List keys = facet.getDataProviderKeys(this.artifact, context); |
355
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 if (keys == null) { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 return; |
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 for (Object key: keys) { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 context.registerDataProvider(key, this); |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 } |
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 artifact. */ |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 public Artifact getArtifact() { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 return artifact; |
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 /** Access the (native) facet. */ |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 public Facet getFacet() { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 return facet; |
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 |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 /** Shortcut to facets name. */ |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 public String getFacetName() { |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 return facet.getName(); |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 } |
356
079ab7c971a4
Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
355
diff
changeset
|
76 |
079ab7c971a4
Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
355
diff
changeset
|
77 |
377
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
78 /** |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
79 * Returns the description for a facet. The return value depends on the |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
80 * internal <i>facetDescription</i> instance variable. If this has been set |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
81 * by setFacetDescription, this value is returned, otherwise the return |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
82 * value of facet.getDescription(). |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
83 */ |
356
079ab7c971a4
Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
355
diff
changeset
|
84 public String getFacetDescription() { |
377
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
85 if (facetDescription == null) { |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
86 return facet.getDescription(); |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
87 } |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
88 |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
89 return facetDescription; |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
90 } |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
91 |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
92 |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
93 public void setFacetDescription(String facetDescription) { |
1ffc09fec1c8
Added a method ArtifactAndFacet.setFacetDescription().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
375
diff
changeset
|
94 this.facetDescription = facetDescription; |
356
079ab7c971a4
Implemented getFacetDescription in ArtifactAndFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
355
diff
changeset
|
95 } |
355
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 } |
6bd37edd9a80
Added handy implementation of a DataProvider.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |