Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 1059:fdb0f4ef96f0
Made FLYS artifacts cloneable.
flys-artifacts/trunk@2531 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 23 Aug 2011 11:07:21 +0000 |
parents | d4a5d3941cc0 |
children | f364410c7bc9 |
comparison
equal
deleted
inserted
replaced
1058:c37084f31c84 | 1059:fdb0f4ef96f0 |
---|---|
119 /** | 119 /** |
120 * Returns the name of the concrete artifact. | 120 * Returns the name of the concrete artifact. |
121 * | 121 * |
122 * @return the name of the concrete artifact. | 122 * @return the name of the concrete artifact. |
123 */ | 123 */ |
124 public abstract String getName(); | 124 public String getName() { |
125 | 125 return name; |
126 } | |
126 | 127 |
127 /** | 128 /** |
128 * Returns the FLYSContext from context object. | 129 * Returns the FLYSContext from context object. |
129 * | 130 * |
130 * @param context The CallContext or the FLYSContext. | 131 * @param context The CallContext or the FLYSContext. |
188 } | 189 } |
189 | 190 |
190 filterFacets = buildFilterFacets(data); | 191 filterFacets = buildFilterFacets(data); |
191 } | 192 } |
192 | 193 |
194 protected List<String> clonePreviousStateIds() { | |
195 return new ArrayList<String>(previousStateIds); | |
196 } | |
197 | |
198 protected Map<String, StateData> cloneData() { | |
199 Map<String, StateData> copy = new TreeMap<String, StateData>(); | |
200 | |
201 for (Map.Entry<String, StateData> entry: data.entrySet()) { | |
202 copy.put(entry.getKey(), entry.getValue().deepCopy()); | |
203 } | |
204 | |
205 return copy; | |
206 } | |
207 | |
208 protected Map<String, List<Facet>> cloneFacets() { | |
209 Map copy = new HashMap<String, List<Facet>>(); | |
210 | |
211 for (Map.Entry<String, List<Facet>> entry: facets.entrySet()) { | |
212 List<Facet> facets = entry.getValue(); | |
213 List<Facet> facetCopies = new ArrayList<Facet>(facets.size()); | |
214 for (Facet facet: facets) { | |
215 facetCopies.add(facet.deepCopy()); | |
216 } | |
217 copy.put(entry.getKey(), facetCopies); | |
218 } | |
219 | |
220 return copy; | |
221 } | |
193 | 222 |
194 protected void initialize( | 223 protected void initialize( |
195 Artifact artifact, | 224 Artifact artifact, |
196 Object context, | 225 Object context, |
197 CallMeta callMeta) | 226 CallMeta callMeta) |
198 { | 227 { |
199 // do nothing here | 228 if (!(artifact instanceof FLYSArtifact)) { |
229 return; | |
230 } | |
231 | |
232 FLYSArtifact flys = (FLYSArtifact)artifact; | |
233 | |
234 currentStateId = flys.currentStateId; | |
235 previousStateIds = flys.clonePreviousStateIds(); | |
236 name = flys.name; | |
237 data = flys.cloneData(); | |
238 facets = flys.cloneFacets(); | |
239 // Do not clone filter facets! | |
200 } | 240 } |
201 | 241 |
202 protected Map<String, List<Facet>> buildFilterFacets(Document document) { | 242 protected Map<String, List<Facet>> buildFilterFacets(Document document) { |
203 | 243 |
204 NodeList nodes = (NodeList)XMLUtils.xpath( | 244 NodeList nodes = (NodeList)XMLUtils.xpath( |