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 java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
23 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
24 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
25 import org.kuali.rice.krad.document.Document;
26 import org.kuali.rice.krad.maintenance.Maintainable;
27 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizer;
28 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizerBase;
29 import org.kuali.rice.krad.maintenance.MaintenanceDocumentBase;
30 import org.kuali.rice.krad.maintenance.MaintenanceDocumentPresentationControllerBase;
31
32
33
34
35
36
37 @BeanTag(name = "maintenanceDocumentEntry", 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 protected List<String> clearValueOnCopyPropertyNames = new ArrayList<String>();
46
47 protected boolean allowsNewOrCopy = true;
48 protected boolean preserveLockingKeysOnCopy = false;
49 protected boolean allowsRecordDeletion = false;
50
51 public MaintenanceDocumentEntry() {
52 super();
53
54 setDocumentClass(getStandardDocumentBaseClass());
55 documentAuthorizerClass = MaintenanceDocumentAuthorizerBase.class;
56 documentPresentationControllerClass = MaintenanceDocumentPresentationControllerBase.class;
57 }
58
59 public Class<? extends Document> getStandardDocumentBaseClass() {
60 return MaintenanceDocumentBase.class;
61 }
62
63
64
65
66
67 public void setDataObjectClass(Class<?> dataObjectClass) {
68 this.dataObjectClass = dataObjectClass;
69 }
70
71 @BeanTagAttribute(name = "dataObjectClass")
72 public Class<?> getDataObjectClass() {
73 return dataObjectClass;
74 }
75
76
77
78
79 @SuppressWarnings("unchecked")
80 @Override
81 public Class getEntryClass() {
82 return dataObjectClass;
83 }
84
85
86
87
88
89
90
91 public void setMaintainableClass(Class<? extends Maintainable> maintainableClass) {
92 this.maintainableClass = maintainableClass;
93 }
94
95 @BeanTagAttribute(name = "maintainableClass")
96 public Class<? extends Maintainable> getMaintainableClass() {
97 return maintainableClass;
98 }
99
100
101
102
103
104 public List<String> getLockingKeyFieldNames() {
105 return lockingKeys;
106 }
107
108
109
110
111
112
113 @BeanTagAttribute(name = "allowsNewOrCopy")
114 public boolean getAllowsNewOrCopy() {
115 return allowsNewOrCopy;
116 }
117
118
119
120
121
122
123 public void setAllowsNewOrCopy(boolean allowsNewOrCopy) {
124 this.allowsNewOrCopy = allowsNewOrCopy;
125 }
126
127
128
129
130
131
132 @Override
133 public void completeValidation(ValidationTrace tracer) {
134 super.completeValidation(tracer);
135
136 if (dataObjectClass == null) {
137 String currentValues[] = {};
138 tracer.createError("invalid (null) dataObjectClass", currentValues);
139 }
140
141 if (maintainableClass == null) {
142 String currentValues[] = {};
143 tracer.createError("invalid (null) maintainableClass", currentValues);
144 }
145
146 for (String lockingKey : lockingKeys) {
147 if ( StringUtils.isBlank(lockingKey) ) {
148 String currentValues[] = {"lockingKeys = " + lockingKeys};
149 tracer.createError("invalid (blank) lockingKey", currentValues);
150 } else if (!DataDictionary.isPropertyOf(dataObjectClass, lockingKey)) {
151 String currentValues[] = {"dataObjectClass = " + dataObjectClass, "lockingKey = " + lockingKey};
152 tracer.createError("lockingKey not found in data object class", currentValues);
153 }
154 }
155
156 for (String clearValueOnCopyPropertyName : clearValueOnCopyPropertyNames) {
157 if (StringUtils.isBlank(clearValueOnCopyPropertyName)) {
158 String currentValues[] = {"clearValueOnCopyPropertyNames = " + clearValueOnCopyPropertyNames};
159 tracer.createError("invalid (blank) clearValueOnCopyPropertyNames", currentValues);
160 } else if (!DataDictionary.isPropertyOf(dataObjectClass, clearValueOnCopyPropertyName)) {
161 String currentValues[] = {"dataObjectClass = " + dataObjectClass,
162 "clearValueOnCopyPropertyName = " + clearValueOnCopyPropertyName};
163 tracer.createError("clearValueOnCopyPropertyName not found in data object class", currentValues);
164 }
165 }
166
167 if (documentAuthorizerClass != null
168 && !MaintenanceDocumentAuthorizer.class.isAssignableFrom(documentAuthorizerClass)) {
169 String currentValues[] = {"documentAuthorizerClass = " + documentAuthorizerClass.getName()};
170 tracer.createError("Maintenance Documents must use an implementation of MaintenanceDocumentAuthorizer", currentValues);
171 }
172 }
173
174 @Override
175 protected void validateDefaultExistenceChecks( ValidationTrace tracer ) {
176 for ( ReferenceDefinition refDef : defaultExistenceChecks ) {
177 refDef.completeValidation(dataObjectClass, null, tracer.getCopy());
178 }
179 }
180
181
182 @BeanTagAttribute(name = "lockingKeys", type = BeanTagAttribute.AttributeType.LISTVALUE)
183 public List<String> getLockingKeys() {
184 return lockingKeys;
185 }
186
187
188
189
190
191
192 public void setLockingKeys(List<String> lockingKeys) {
193 this.lockingKeys = lockingKeys;
194 }
195
196
197
198
199 @BeanTagAttribute(name = "preserveLockingKeysOnCopy")
200 public boolean getPreserveLockingKeysOnCopy() {
201 return this.preserveLockingKeysOnCopy;
202 }
203
204
205
206
207 public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) {
208 this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;
209 }
210
211
212
213
214 @BeanTagAttribute(name = "clearValueOnCopyPropertyNames", type = BeanTagAttribute.AttributeType.LISTVALUE)
215 public List<String> getClearValueOnCopyPropertyNames() {
216 return clearValueOnCopyPropertyNames;
217 }
218
219
220
221
222 public void setClearValueOnCopyPropertyNames(List<String> clearValueOnCopyPropertyNames) {
223 this.clearValueOnCopyPropertyNames = clearValueOnCopyPropertyNames;
224 }
225
226
227
228
229 @BeanTagAttribute(name = "allowsRecordDeletion")
230 public boolean getAllowsRecordDeletion() {
231 return this.allowsRecordDeletion;
232 }
233
234
235
236
237 public void setAllowsRecordDeletion(boolean allowsRecordDeletion) {
238 this.allowsRecordDeletion = allowsRecordDeletion;
239 }
240
241 }