comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.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 3c006a53e551
children afc7bfb4800b
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
1 package de.intevation.flys.artifacts;
2
3 import de.intevation.artifactdatabase.state.DefaultFacet;
4 import de.intevation.artifactdatabase.state.Facet;
5
6 import de.intevation.artifacts.Artifact;
7 import de.intevation.artifacts.ArtifactFactory;
8 import de.intevation.artifacts.CallMeta;
9
10 import de.intevation.flys.artifacts.states.DefaultState;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 import org.apache.log4j.Logger;
16
17 import org.w3c.dom.Document;
18
19
20 /**
21 * Clone of an WINFOArtifact to expose exactly one waterlevel only.
22 * All Facets of the "longitudinal_section" output will be added to the
23 * "w_differences" output and filterFacets adjusted accordingly.
24 *
25 * @TODO Straighten inheritance-line (waterlevel-WINFO or vice versa).
26 */
27 public class WaterlevelArtifact extends WINFOArtifact {
28
29 /** The logger for this class. */
30 private static Logger logger = Logger.getLogger(WaterlevelArtifact.class);
31
32 /** The name of the artifact. */
33 public static final String ARTIFACT_NAME = "waterlevel";
34
35
36 /**
37 * The default constructor.
38 */
39 public WaterlevelArtifact() {
40 }
41
42
43 /**
44 * Setup and restate longitudinal_section filterfacets to apply to the
45 * w_differences output, too. Also, for w_differences, add respective q-
46 * filter facets.
47 */
48 public void setup(
49 String identifier,
50 ArtifactFactory factory,
51 Object context,
52 CallMeta callMeta,
53 Document data)
54 {
55 super.setup(identifier, factory, context, callMeta, data);
56 // For w_differences, also allow q-facets.
57 if(filterFacets != null) {
58 List<Facet> list = new ArrayList<Facet>();
59 List<Facet> wlist = filterFacets.get("longitudinal_section");
60 for (Facet f: wlist) {
61 if (!f.getName().equals("longitudinal_section.q")) {
62 DefaultFacet df = new DefaultFacet(f.getIndex(),
63 "longitudinal_section.q", "");
64 list.add(df);
65 }
66 }
67
68 list.addAll(wlist);
69
70 filterFacets.put("w_differences", list);
71 }
72 }
73
74
75 /**
76 * Clone important stuff of an WINFOArtifact.
77 * @param artifact the WINFOArtifact to clone stuff from.
78 */
79 protected void initialize(
80 Artifact artifact,
81 Object context,
82 CallMeta meta)
83 {
84 WINFOArtifact winfo = (WINFOArtifact) artifact;
85 this.data = winfo.cloneData();
86 logger.debug("Cloned data of winfo artifact.");
87 // Statically add Facets.
88 List<Facet> fs = new ArrayList<Facet>();
89 DefaultState state = (DefaultState) getCurrentState(context);
90 state.computeInit(this, hash(), context, meta, fs);
91 if (!fs.isEmpty()) {
92 logger.debug("Facets to add in WaterlevelArtifact.initialize .");
93 facets.put(getCurrentStateId(), fs);
94 }
95 else {
96 logger.debug("No facets to add in WaterlevelArtifact.initialize ("
97 + state.getID() + ").");
98 }
99 }
100
101
102 /**
103 * Returns the name of the concrete artifact.
104 *
105 * @return the name of the concrete artifact.
106 */
107 public String getName() {
108 return ARTIFACT_NAME;
109 }
110
111
112 /**
113 * Determines Facets initial disposition regarding activity (think of
114 * selection in Client ThemeList GUI).
115 * WaterlevelArtifact Facets should come to live "inactive" (always
116 * return 0).
117 *
118 * @param facetName name of the facet.
119 * @param index index of the facet.
120 *
121 * @return Always 0 to have Facets initial predisposition to "inactive".
122 */
123 @Override
124 public int getInitialFacetActivity(
125 String outputName,
126 String facetName,
127 int index)
128 {
129 return 0;
130 }
131 }
132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org