1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.impl;
17
18 import java.lang.reflect.InvocationTargetException;
19 import java.util.List;
20
21 import org.apache.commons.beanutils.BeanUtils;
22 import org.apache.commons.beanutils.PropertyUtils;
23 import org.apache.log4j.Logger;
24 import org.kuali.rice.kns.datadictionary.BeanOverride;
25 import org.kuali.rice.kns.datadictionary.FieldOverride;
26
27
28
29
30
31
32
33 public class BeanOverrideImpl implements BeanOverride {
34 private static final Logger LOG = Logger.getLogger(BeanOverrideImpl.class);
35 private String beanName;
36 private List<FieldOverride> fieldOverrides;
37
38
39
40
41
42 public List<FieldOverride> getFieldOverrides() {
43 return this.fieldOverrides;
44 }
45
46 public void setFieldOverrides(List<FieldOverride> fieldOverirdes) {
47 this.fieldOverrides = fieldOverirdes;
48 }
49
50
51
52
53
54 public String getBeanName() {
55 return this.beanName;
56 }
57
58 public void setBeanName(String beanName) {
59 this.beanName = beanName;
60 }
61
62
63
64
65
66 public void performOverride(Object bean)
67 {
68 try
69 {
70 for (FieldOverride fieldOverride: fieldOverrides)
71 {
72 Object property = PropertyUtils.getProperty(bean, fieldOverride.getPropertyName());
73 Object newProperty = fieldOverride.performFieldOverride(bean, property);
74 BeanUtils.setProperty(bean, fieldOverride.getPropertyName(), newProperty);
75 }
76 }
77 catch(IllegalAccessException e )
78 {
79 throw new RuntimeException(e);
80 }
81 catch(InvocationTargetException e)
82 {
83 throw new RuntimeException(e);
84
85 }
86 catch (NoSuchMethodException e)
87 {
88 throw new RuntimeException(e);
89 }
90 }
91 }