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