1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.lifecycle;
17
18 import java.beans.PropertyEditor;
19 import java.io.Serializable;
20 import java.util.Collections;
21 import java.util.HashMap;
22 import java.util.HashSet;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Set;
26
27 import org.kuali.rice.krad.uif.component.Component;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class ViewPostMetadata implements Serializable {
43 private static final long serialVersionUID = -515221881981451818L;
44
45 private String id;
46
47 private Map<String, ComponentPostMetadata> componentPostMetadataMap;
48
49 private Map<String, PropertyEditor> fieldPropertyEditors;
50 private Map<String, PropertyEditor> secureFieldPropertyEditors;
51
52 private Set<String> inputFieldIds;
53 private Set<String> allDataFieldPropertyPaths;
54 private Map<String, List<Object>> addedCollectionObjects;
55
56 private Set<String> accessibleBindingPaths;
57 private Set<String> accessibleMethodToCalls;
58
59
60
61
62 public ViewPostMetadata() {
63 fieldPropertyEditors = Collections.synchronizedMap(new HashMap<String, PropertyEditor>());
64 secureFieldPropertyEditors = Collections.synchronizedMap(new HashMap<String, PropertyEditor>());
65 inputFieldIds = Collections.synchronizedSet(new HashSet<String>());
66 allDataFieldPropertyPaths = Collections.synchronizedSet(new HashSet<String>());
67 addedCollectionObjects = Collections.synchronizedMap(new HashMap<String, List<Object>>());
68 accessibleBindingPaths = Collections.synchronizedSet(new HashSet<String>());
69 accessibleMethodToCalls = Collections.synchronizedSet(new HashSet<String>());
70 }
71
72
73
74
75
76
77 public ViewPostMetadata(String id) {
78 this();
79
80 this.id = id;
81 }
82
83
84
85
86 public void cleanAfterLifecycle() {
87 allDataFieldPropertyPaths = Collections.synchronizedSet(new HashSet<String>());
88 addedCollectionObjects = Collections.synchronizedMap(new HashMap<String, List<Object>>());
89 }
90
91
92
93
94
95
96 public String getId() {
97 return id;
98 }
99
100
101
102
103 public void setId(String id) {
104 this.id = id;
105 }
106
107
108
109
110
111
112 public Map<String, ComponentPostMetadata> getComponentPostMetadataMap() {
113 return componentPostMetadataMap;
114 }
115
116
117
118
119 public void setComponentPostMetadataMap(Map<String, ComponentPostMetadata> componentPostMetadataMap) {
120 this.componentPostMetadataMap = componentPostMetadataMap;
121 }
122
123
124
125
126
127
128
129 public ComponentPostMetadata getComponentPostMetadata(String componentId) {
130 ComponentPostMetadata componentPostMetadata = null;
131
132 if (componentPostMetadataMap != null && (componentPostMetadataMap.containsKey(componentId))) {
133 componentPostMetadata = componentPostMetadataMap.get(componentId);
134 }
135
136 return componentPostMetadata;
137 }
138
139
140
141
142
143
144
145
146 public void addComponentPostData(Component component, String key, Object value) {
147 if (component == null) {
148 throw new IllegalArgumentException("Component must not be null for adding post data");
149 }
150
151 addComponentPostData(component.getId(), key, value);
152 }
153
154
155
156
157
158
159
160
161 public void addComponentPostData(String componentId, String key, Object value) {
162 if (value == null) {
163 return;
164 }
165
166 ComponentPostMetadata componentPostMetadata = initializeComponentPostMetadata(componentId);
167
168 componentPostMetadata.addData(key, value);
169 }
170
171
172
173
174
175
176
177
178 public Object getComponentPostData(String componentId, String key) {
179 ComponentPostMetadata componentPostMetadata = getComponentPostMetadata(componentId);
180
181 if (componentPostMetadata != null) {
182 return componentPostMetadata.getData(key);
183 }
184
185 return null;
186 }
187
188
189
190
191
192
193
194 public ComponentPostMetadata initializeComponentPostMetadata(Component component) {
195 if (component == null) {
196 throw new IllegalArgumentException("Component must not be null to initialize post metadata");
197 }
198
199 return initializeComponentPostMetadata(component.getId());
200 }
201
202
203
204
205
206
207
208 public ComponentPostMetadata initializeComponentPostMetadata(String componentId) {
209 ComponentPostMetadata componentPostMetadata;
210
211 if (componentPostMetadataMap == null) {
212 synchronized (this) {
213 if (componentPostMetadataMap == null) {
214 componentPostMetadataMap = new HashMap<String, ComponentPostMetadata>();
215 }
216 }
217 }
218
219 componentPostMetadata = componentPostMetadataMap.get(componentId);
220
221 if (componentPostMetadata == null) {
222 synchronized (componentPostMetadataMap) {
223 componentPostMetadata = new ComponentPostMetadata(componentId);
224 componentPostMetadataMap.put(componentId, componentPostMetadata);
225 }
226 }
227
228 return componentPostMetadata;
229 }
230
231
232
233
234
235
236
237
238
239
240
241 public Map<String, PropertyEditor> getFieldPropertyEditors() {
242 return fieldPropertyEditors;
243 }
244
245
246
247
248
249
250
251 public void addFieldPropertyEditor(String propertyPath, PropertyEditor propertyEditor) {
252 if (fieldPropertyEditors == null) {
253 fieldPropertyEditors = new HashMap<String, PropertyEditor>();
254 }
255
256 fieldPropertyEditors.put(propertyPath, propertyEditor);
257 }
258
259
260
261
262
263
264
265
266
267
268
269 public Map<String, PropertyEditor> getSecureFieldPropertyEditors() {
270 return secureFieldPropertyEditors;
271 }
272
273
274
275
276
277
278
279 public void addSecureFieldPropertyEditor(String propertyPath, PropertyEditor propertyEditor) {
280 if (secureFieldPropertyEditors == null) {
281 secureFieldPropertyEditors = new HashMap<String, PropertyEditor>();
282 }
283
284 secureFieldPropertyEditors.put(propertyPath, propertyEditor);
285 }
286
287
288
289
290
291
292 public Set<String> getInputFieldIds() {
293 return inputFieldIds;
294 }
295
296
297
298
299 public void setInputFieldIds(Set<String> inputFieldIds) {
300 this.inputFieldIds = inputFieldIds;
301 }
302
303
304
305
306
307
308
309
310
311
312 public Set<String> getAllDataFieldPropertyPaths() {
313 return allDataFieldPropertyPaths;
314 }
315
316
317
318
319 public void setAllDataFieldPropertyPaths(Set<String> allDataFieldPropertyPaths) {
320 this.allDataFieldPropertyPaths = Collections.synchronizedSet(new HashSet<String>(allDataFieldPropertyPaths));
321 }
322
323
324
325
326
327
328
329 public void addDataFieldPropertyPath(String propertyPath) {
330 if (this.allDataFieldPropertyPaths == null) {
331 this.allDataFieldPropertyPaths = Collections.synchronizedSet(new HashSet<String>());
332 }
333
334 this.allDataFieldPropertyPaths.add(propertyPath);
335 }
336
337
338
339
340
341
342
343
344
345
346
347
348 public Map<String, List<Object>> getAddedCollectionObjects() {
349 return addedCollectionObjects;
350 }
351
352
353
354
355 public void setAddedCollectionObjects(Map<String, List<Object>> addedCollectionObjects) {
356 this.addedCollectionObjects = addedCollectionObjects;
357 }
358
359
360
361
362
363
364
365
366
367 public Set<String> getAccessibleBindingPaths() {
368 return accessibleBindingPaths;
369 }
370
371
372
373
374 public void setAccessibleBindingPaths(Set<String> accessibleBindingPaths) {
375 this.accessibleBindingPaths = accessibleBindingPaths;
376 }
377
378
379
380
381
382
383
384 public void addAccessibleBindingPath(String accessibleBindingPath) {
385 if (this.accessibleBindingPaths == null) {
386 this.accessibleBindingPaths = Collections.synchronizedSet(new HashSet<String>());
387 }
388
389 this.accessibleBindingPaths.add(accessibleBindingPath);
390 }
391
392
393
394
395
396
397
398
399
400 public Set<String> getAccessibleMethodToCalls() {
401 return accessibleMethodToCalls;
402 }
403
404
405
406
407 public void setAccessibleMethodToCalls(Set<String> accessibleMethodToCalls) {
408 this.accessibleMethodToCalls = accessibleMethodToCalls;
409 }
410
411
412
413
414
415
416
417 public void addAccessibleMethodToCall(String methodToCall) {
418 if (this.accessibleMethodToCalls == null) {
419 this.accessibleMethodToCalls = Collections.synchronizedSet(new HashSet<String>());
420 }
421
422 this.accessibleMethodToCalls.add(methodToCall);
423 }
424 }