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.StringUtils;
19 import org.kuali.rice.krad.bo.BusinessObject;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
22
23
24
25
26
27
28
29
30
31 @BeanTag(name = "businessObjectEntry-bean")
32 public class BusinessObjectEntry extends DataObjectEntry {
33
34 protected Class<? extends BusinessObject> baseBusinessObjectClass;
35
36 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
37 super.setDataObjectClass(businessObjectClass);
38
39 if (businessObjectClass == null) {
40 throw new IllegalArgumentException("invalid (null) dataObjectClass");
41 }
42
43 if (getRelationships() != null) {
44 for (RelationshipDefinition rd : getRelationships()) {
45 rd.setSourceClass(businessObjectClass);
46 }
47 }
48 }
49
50 public Class<? extends BusinessObject> getBusinessObjectClass() {
51 return (Class<? extends BusinessObject>) super.getDataObjectClass();
52 }
53
54
55
56
57
58
59
60 public void setBaseBusinessObjectClass(Class<? extends BusinessObject> baseBusinessObjectClass) {
61 this.baseBusinessObjectClass = baseBusinessObjectClass;
62 }
63
64 @BeanTagAttribute(name = "baseBusinessObjectClass")
65 public Class<? extends BusinessObject> getBaseBusinessObjectClass() {
66 return baseBusinessObjectClass;
67 }
68
69
70
71
72 @Override
73 public void completeValidation() {
74 try {
75
76 super.completeValidation();
77
78 if (inactivationBlockingDefinitions != null && !inactivationBlockingDefinitions.isEmpty()) {
79 for (InactivationBlockingDefinition inactivationBlockingDefinition : inactivationBlockingDefinitions) {
80 inactivationBlockingDefinition.completeValidation(getDataObjectClass(), null);
81 }
82 }
83 } catch (DataDictionaryException ex) {
84
85 throw ex;
86 } catch (Exception ex) {
87 throw new DataDictionaryException("Exception validating " + this, ex);
88 }
89 }
90
91
92
93
94 @SuppressWarnings("unchecked")
95 @Override
96 public void afterPropertiesSet() throws Exception {
97 super.afterPropertiesSet();
98 if (inactivationBlockingDefinitions != null) {
99 for (InactivationBlockingDefinition ibd : inactivationBlockingDefinitions) {
100 ibd.setBusinessObjectClass(getBusinessObjectClass());
101 if (StringUtils.isNotBlank(ibd.getBlockedReferencePropertyName())
102 && ibd.getBlockedBusinessObjectClass() == null) {
103
104 ibd.setBlockedBusinessObjectClass(DataDictionary.getAttributeClass(getDataObjectClass(),
105 ibd.getBlockedReferencePropertyName()));
106 }
107 ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass());
108 }
109 }
110 }
111
112
113
114
115 @Override
116 public String toString() {
117 return "BusinessObjectEntry for " + getBusinessObjectClass();
118 }
119 }