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.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
19 import org.kuali.rice.krad.datadictionary.exception.ClassValidationException;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
22 import org.kuali.rice.krad.document.Document;
23 import org.kuali.rice.krad.maintenance.Maintainable;
24 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizer;
25 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizerBase;
26 import org.kuali.rice.krad.maintenance.MaintenanceDocumentBase;
27 import org.kuali.rice.krad.maintenance.MaintenanceDocumentPresentationControllerBase;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35
36
37 @BeanTag(name = "maintenanceDocumentEntry-bean", parent = "uifMaintenanceDocumentEntry")
38 public class MaintenanceDocumentEntry extends DocumentEntry {
39 private static final long serialVersionUID = 4990040987835057251L;
40
41 protected Class<?> dataObjectClass;
42 protected Class<? extends Maintainable> maintainableClass;
43
44 protected List<String> lockingKeys = new ArrayList<String>();
45
46 protected boolean allowsNewOrCopy = true;
47 protected boolean preserveLockingKeysOnCopy = false;
48 protected boolean allowsRecordDeletion = false;
49
50 public MaintenanceDocumentEntry() {
51 super();
52
53 setDocumentClass(getStandardDocumentBaseClass());
54 documentAuthorizerClass = MaintenanceDocumentAuthorizerBase.class;
55 documentPresentationControllerClass = MaintenanceDocumentPresentationControllerBase.class;
56 }
57
58 public Class<? extends Document> getStandardDocumentBaseClass() {
59 return MaintenanceDocumentBase.class;
60 }
61
62
63
64
65
66 public void setDataObjectClass(Class<?> dataObjectClass) {
67 if (dataObjectClass == null) {
68 throw new IllegalArgumentException("invalid (null) dataObjectClass");
69 }
70
71 this.dataObjectClass = dataObjectClass;
72 }
73
74 @BeanTagAttribute(name = "dataObjectClass")
75 public Class<?> getDataObjectClass() {
76 return dataObjectClass;
77 }
78
79
80
81
82 @SuppressWarnings("unchecked")
83 @Override
84 public Class getEntryClass() {
85 return dataObjectClass;
86 }
87
88
89
90
91
92
93
94 public void setMaintainableClass(Class<? extends Maintainable> maintainableClass) {
95 if (maintainableClass == null) {
96 throw new IllegalArgumentException("invalid (null) maintainableClass");
97 }
98 this.maintainableClass = maintainableClass;
99 }
100
101 @BeanTagAttribute(name = "maintainableClass")
102 public Class<? extends Maintainable> getMaintainableClass() {
103 return maintainableClass;
104 }
105
106
107
108
109
110 public List<String> getLockingKeyFieldNames() {
111 return lockingKeys;
112 }
113
114
115
116
117
118
119 @BeanTagAttribute(name = "allowsNewOrCopy")
120 public boolean getAllowsNewOrCopy() {
121 return allowsNewOrCopy;
122 }
123
124
125
126
127
128
129 public void setAllowsNewOrCopy(boolean allowsNewOrCopy) {
130 this.allowsNewOrCopy = allowsNewOrCopy;
131 }
132
133
134
135
136
137
138 public void completeValidation() {
139 super.completeValidation();
140
141 for (String lockingKey : lockingKeys) {
142 if (!DataDictionary.isPropertyOf(dataObjectClass, lockingKey)) {
143 throw new AttributeValidationException(
144 "unable to find attribute '" + lockingKey + "' for lockingKey in dataObjectClass '" +
145 dataObjectClass.getName());
146 }
147 }
148
149 for (ReferenceDefinition reference : defaultExistenceChecks) {
150 reference.completeValidation(dataObjectClass, null);
151 }
152
153 if (documentAuthorizerClass != null && !MaintenanceDocumentAuthorizer.class.isAssignableFrom(
154 documentAuthorizerClass)) {
155 throw new ClassValidationException(
156 "This maintenance document for '" + getDataObjectClass().getName() + "' has an invalid " +
157 "documentAuthorizerClass ('" + documentAuthorizerClass.getName() + "'). " +
158 "Maintenance Documents must use an implementation of MaintenanceDocumentAuthorizer.");
159 }
160 }
161
162
163
164
165 public String toString() {
166 return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName();
167 }
168
169 @BeanTagAttribute(name = "lockingKeys", type = BeanTagAttribute.AttributeType.LISTVALUE)
170 public List<String> getLockingKeys() {
171 return lockingKeys;
172 }
173
174
175
176
177
178
179 public void setLockingKeys(List<String> lockingKeys) {
180 for (String lockingKey : lockingKeys) {
181 if (lockingKey == null) {
182 throw new IllegalArgumentException("invalid (null) lockingKey");
183 }
184 }
185 this.lockingKeys = lockingKeys;
186 }
187
188
189
190
191 @BeanTagAttribute(name = "preserveLockingKeysOnCopy")
192 public boolean getPreserveLockingKeysOnCopy() {
193 return this.preserveLockingKeysOnCopy;
194 }
195
196
197
198
199 public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) {
200 this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;
201 }
202
203
204
205
206 @BeanTagAttribute(name = "allowsRecordDeletion")
207 public boolean getAllowsRecordDeletion() {
208 return this.allowsRecordDeletion;
209 }
210
211
212
213
214 public void setAllowsRecordDeletion(boolean allowsRecordDeletion) {
215 this.allowsRecordDeletion = allowsRecordDeletion;
216 }
217
218 }