1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary;
17
18 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
19 import org.kuali.rice.kns.document.authorization.DocumentPresentationController;
20 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentAuthorizerBase;
21 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase;
22 import org.kuali.rice.kns.rule.PromptBeforeValidation;
23 import org.kuali.rice.kns.web.derivedvaluesetter.DerivedValuesSetter;
24 import org.kuali.rice.krad.bo.BusinessObject;
25 import org.kuali.rice.krad.datadictionary.DataDictionaryException;
26 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException;
27 import org.kuali.rice.krad.document.Document;
28 import org.kuali.rice.kns.document.MaintenanceDocumentBase;
29 import org.kuali.rice.kns.maintenance.Maintainable;
30 import org.kuali.rice.kns.rules.MaintenanceDocumentRule;
31 import org.kuali.rice.krad.rules.MaintenanceDocumentRuleBase;
32
33 import java.util.ArrayList;
34 import java.util.LinkedHashMap;
35 import java.util.List;
36 import java.util.Map;
37
38
39
40
41 @Deprecated
42 public class MaintenanceDocumentEntry extends org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry implements KNSDocumentEntry {
43 protected List<MaintainableSectionDefinition> maintainableSections = new ArrayList<MaintainableSectionDefinition>();
44 protected List<String> lockingKeys = new ArrayList<String>();
45
46 protected Map<String, MaintainableSectionDefinition> maintainableSectionMap =
47 new LinkedHashMap<String, MaintainableSectionDefinition>();
48
49 protected boolean allowsNewOrCopy = true;
50 protected String additionalSectionsFile;
51
52
53 protected boolean preserveLockingKeysOnCopy = false;
54
55
56 protected boolean allowsRecordDeletion = false;
57
58 protected boolean translateCodes = false;
59
60 protected Class<? extends PromptBeforeValidation> promptBeforeValidationClass;
61 protected Class<? extends DerivedValuesSetter> derivedValuesSetterClass;
62 protected List<String> webScriptFiles = new ArrayList<String>(3);
63 protected List<HeaderNavigation> headerNavigationList = new ArrayList<HeaderNavigation>();
64
65 protected boolean sessionDocument = false;
66
67 public MaintenanceDocumentEntry() {
68 super();
69
70 documentAuthorizerClass = MaintenanceDocumentAuthorizerBase.class;
71 documentPresentationControllerClass = MaintenanceDocumentPresentationControllerBase.class;
72 }
73
74
75
76
77 public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass() {
78 return promptBeforeValidationClass;
79 }
80
81
82
83
84
85
86
87
88
89 public void setPromptBeforeValidationClass(Class<? extends PromptBeforeValidation> preRulesCheckClass) {
90 this.promptBeforeValidationClass = preRulesCheckClass;
91 }
92
93 @Override
94 public Class<? extends Document> getStandardDocumentBaseClass() {
95 return MaintenanceDocumentBase.class;
96 }
97
98
99
100
101
102 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
103 if (businessObjectClass == null) {
104 throw new IllegalArgumentException("invalid (null) dataObjectClass");
105 }
106
107 setDataObjectClass(businessObjectClass);
108 }
109
110 public Class<? extends BusinessObject> getBusinessObjectClass() {
111 return (Class<? extends BusinessObject>) getDataObjectClass();
112 }
113
114
115
116
117 @SuppressWarnings("unchecked")
118 @Override
119 public Class getEntryClass() {
120 return getDataObjectClass();
121 }
122
123 public Class<? extends Maintainable> getMaintainableClass() {
124 return (Class<? extends Maintainable>) super.getMaintainableClass();
125 }
126
127
128
129
130 public List<MaintainableSectionDefinition> getMaintainableSections() {
131 return maintainableSections;
132 }
133
134
135
136
137
138 public List<String> getLockingKeyFieldNames() {
139 return lockingKeys;
140 }
141
142
143
144
145
146
147 public boolean getAllowsNewOrCopy() {
148 return allowsNewOrCopy;
149 }
150
151
152
153
154
155
156 public void setAllowsNewOrCopy(boolean allowsNewOrCopy) {
157 this.allowsNewOrCopy = allowsNewOrCopy;
158 }
159
160
161
162
163
164
165 public void completeValidation() {
166 if ( !MaintenanceDocumentRule.class.isAssignableFrom( getBusinessRulesClass() ) ) {
167 throw new DataDictionaryException( "ERROR: Business rules class for KNS Maintenance document entry " +
168 getBusinessRulesClass().getName() + " does not implement the expected " +
169 MaintenanceDocumentRule.class.getName() + " interface.");
170 }
171 super.completeValidation();
172
173 for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
174 maintainableSectionDefinition.completeValidation(getDataObjectClass(), null);
175 }
176 }
177
178
179
180
181 public String toString() {
182 return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName();
183 }
184
185 @Deprecated
186 public String getAdditionalSectionsFile() {
187 return additionalSectionsFile;
188 }
189
190
191
192
193
194
195
196 @Deprecated
197 public void setAdditionalSectionsFile(String additionalSectionsFile) {
198 this.additionalSectionsFile = additionalSectionsFile;
199 }
200
201 public List<String> getLockingKeys() {
202 return lockingKeys;
203 }
204
205
206
207
208
209
210 public void setLockingKeys(List<String> lockingKeys) {
211 for (String lockingKey : lockingKeys) {
212 if (lockingKey == null) {
213 throw new IllegalArgumentException("invalid (null) lockingKey");
214 }
215 }
216 this.lockingKeys = lockingKeys;
217 }
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 @Deprecated
233 public void setMaintainableSections(List<MaintainableSectionDefinition> maintainableSections) {
234 maintainableSectionMap.clear();
235 for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
236 if (maintainableSectionDefinition == null) {
237 throw new IllegalArgumentException("invalid (null) maintainableSectionDefinition");
238 }
239
240 String sectionTitle = maintainableSectionDefinition.getTitle();
241 if (maintainableSectionMap.containsKey(sectionTitle)) {
242 throw new DuplicateEntryException(
243 "section '" + sectionTitle + "' already defined for maintenanceDocument '" +
244 getDocumentTypeName() + "'");
245 }
246
247 maintainableSectionMap.put(sectionTitle, maintainableSectionDefinition);
248 }
249 this.maintainableSections = maintainableSections;
250 }
251
252
253
254
255 public boolean getPreserveLockingKeysOnCopy() {
256 return this.preserveLockingKeysOnCopy;
257 }
258
259
260
261
262 public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) {
263 this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;
264 }
265
266
267
268
269 public boolean getAllowsRecordDeletion() {
270 return this.allowsRecordDeletion;
271 }
272
273
274
275
276 public void setAllowsRecordDeletion(boolean allowsRecordDeletion) {
277 this.allowsRecordDeletion = allowsRecordDeletion;
278 }
279
280 @Deprecated
281 public boolean isTranslateCodes() {
282 return this.translateCodes;
283 }
284
285 @Deprecated
286 public void setTranslateCodes(boolean translateCodes) {
287 this.translateCodes = translateCodes;
288 }
289
290
291
292
293
294
295
296
297
298 @Override
299 public Class<? extends DocumentAuthorizer> getDocumentAuthorizerClass() {
300 return (Class<? extends DocumentAuthorizer>) super.getDocumentAuthorizerClass();
301 }
302
303
304
305
306
307
308
309
310
311
312 @Override
313 public Class<? extends DocumentPresentationController> getDocumentPresentationControllerClass() {
314 return (Class<? extends DocumentPresentationController>) super.getDocumentPresentationControllerClass();
315 }
316
317 public List<HeaderNavigation> getHeaderNavigationList() {
318 return headerNavigationList;
319 }
320
321 public List<String> getWebScriptFiles() {
322 return webScriptFiles;
323 }
324
325
326
327
328
329
330 public void setWebScriptFiles(List<String> webScriptFiles) {
331 this.webScriptFiles = webScriptFiles;
332 }
333
334
335
336
337
338 public void setHeaderNavigationList(List<HeaderNavigation> headerNavigationList) {
339 this.headerNavigationList = headerNavigationList;
340 }
341
342 public boolean isSessionDocument() {
343 return this.sessionDocument;
344 }
345
346 public void setSessionDocument(boolean sessionDocument) {
347 this.sessionDocument = sessionDocument;
348 }
349
350
351
352
353 public Class<? extends DerivedValuesSetter> getDerivedValuesSetterClass() {
354 return this.derivedValuesSetterClass;
355 }
356
357
358
359
360 public void setDerivedValuesSetterClass(Class<? extends DerivedValuesSetter> derivedValuesSetter) {
361 this.derivedValuesSetterClass = derivedValuesSetter;
362 }
363
364 public void afterPropertiesSet() throws Exception {
365 if ( getBusinessRulesClass() == null || getBusinessRulesClass().equals(MaintenanceDocumentRuleBase.class) ) {
366 setBusinessRulesClass(org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase.class);
367 }
368 super.afterPropertiesSet();
369 }
370 }