1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.datadictionary; |
17 | |
|
18 | |
import org.apache.commons.lang.ClassUtils; |
19 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
20 | |
import org.kuali.rice.core.api.util.ClassLoaderUtils; |
21 | |
import org.kuali.rice.krad.bo.BusinessObject; |
22 | |
import org.kuali.rice.krad.datadictionary.exception.ClassValidationException; |
23 | |
|
24 | |
import java.util.Map; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class KimDataDictionaryAttributeDefinition extends KimAttributeDefinition { |
30 | |
private static final long serialVersionUID = 7006569761728813805L; |
31 | |
|
32 | |
protected Map<String, String> lookupInputPropertyConversions; |
33 | |
protected Map<String, String> lookupReturnPropertyConversions; |
34 | |
protected String lookupBoClass; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public KimDataDictionaryAttributeDefinition() { |
40 | 0 | } |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public Map<String, String> getLookupInputPropertyConversions() { |
46 | 0 | return this.lookupInputPropertyConversions; |
47 | |
} |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public void setLookupInputPropertyConversions(Map<String, String> lookupInputPropertyConversions) { |
54 | 0 | this.lookupInputPropertyConversions = lookupInputPropertyConversions; |
55 | 0 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public Map<String, String> getLookupReturnPropertyConversions() { |
61 | 0 | return this.lookupReturnPropertyConversions; |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public void setLookupReturnPropertyConversions(Map<String, String> lookupReturnPropertyConversions) { |
69 | 0 | this.lookupReturnPropertyConversions = lookupReturnPropertyConversions; |
70 | 0 | } |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public String toString() { |
76 | 0 | return new ToStringBuilder( this ) |
77 | |
.append( "name", getName() ) |
78 | |
.append( "label", getLabel() ) |
79 | |
.append( "lookupBoClass", this.lookupBoClass ) |
80 | |
.append( "required", isRequired() ) |
81 | |
.append( "lookupInputPropertyConversions", this.lookupInputPropertyConversions ) |
82 | |
.append( "lookupReturnPropertyConversions", this.lookupReturnPropertyConversions ) |
83 | |
.toString(); |
84 | |
} |
85 | |
|
86 | |
public String getLookupBoClass() { |
87 | 0 | return this.lookupBoClass; |
88 | |
} |
89 | |
|
90 | |
public void setLookupBoClass(String lookupBoClass) { |
91 | 0 | this.lookupBoClass = lookupBoClass; |
92 | 0 | } |
93 | |
|
94 | |
@Override |
95 | |
public boolean isHasLookupBoDefinition() { |
96 | 0 | return true; |
97 | |
} |
98 | |
|
99 | |
|
100 | |
@SuppressWarnings("unchecked") |
101 | |
@Override |
102 | |
public void completeValidation(Class rootObjectClass, Class otherObjectClass) { |
103 | 0 | if (lookupBoClass != null) { |
104 | |
try { |
105 | 0 | Class lookupBoClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass()); |
106 | 0 | if (!BusinessObject.class.isAssignableFrom(lookupBoClassObject)) { |
107 | 0 | throw new ClassValidationException("lookupBoClass is not a valid instance of " + BusinessObject.class.getName() + " instead was: " + lookupBoClassObject.getName()); |
108 | |
} |
109 | 0 | } catch (ClassNotFoundException e) { |
110 | 0 | throw new ClassValidationException("lookupBoClass could not be found: " + getLookupBoClass(), e); |
111 | 0 | } |
112 | |
} |
113 | 0 | super.completeValidation(rootObjectClass, otherObjectClass); |
114 | 0 | } |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
} |