1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kns.datadictionary; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.LinkedHashMap; |
21 | |
import java.util.List; |
22 | |
import java.util.Map; |
23 | |
|
24 | |
import org.apache.commons.lang.StringUtils; |
25 | |
import org.kuali.rice.kew.docsearch.DocumentSearchGenerator; |
26 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
27 | |
import org.kuali.rice.kns.datadictionary.exception.ClassValidationException; |
28 | |
import org.kuali.rice.kns.datadictionary.exception.DuplicateEntryException; |
29 | |
import org.kuali.rice.kns.document.Document; |
30 | |
import org.kuali.rice.kns.document.authorization.DocumentAuthorizer; |
31 | |
import org.kuali.rice.kns.document.authorization.DocumentPresentationController; |
32 | |
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder; |
33 | |
import org.kuali.rice.kns.rule.BusinessRule; |
34 | |
import org.kuali.rice.kns.rule.PromptBeforeValidation; |
35 | |
import org.kuali.rice.kns.web.derviedvaluesetter.DerivedValuesSetter; |
36 | |
import org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | 0 | abstract public class DocumentEntry extends DataDictionaryEntryBase { |
47 | |
|
48 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentEntry.class); |
49 | |
|
50 | |
protected Class<? extends Document> documentClass; |
51 | |
protected Class<? extends Document> baseDocumentClass; |
52 | |
protected Class<? extends BusinessRule> businessRulesClass; |
53 | |
protected Class<? extends PromptBeforeValidation> promptBeforeValidationClass; |
54 | |
protected Class<? extends DerivedValuesSetter> derivedValuesSetterClass; |
55 | |
protected String documentTypeName; |
56 | |
|
57 | 0 | protected boolean allowsNoteAttachments = true; |
58 | 0 | protected boolean allowsNoteFYI = false; |
59 | |
protected Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass; |
60 | 0 | protected boolean displayTopicFieldInNotes = false; |
61 | 0 | protected boolean usePessimisticLocking = false; |
62 | 0 | protected boolean useWorkflowPessimisticLocking = false; |
63 | 0 | protected boolean encryptDocumentDataInPersistentSessionStorage = false; |
64 | |
|
65 | 0 | protected List<String> webScriptFiles = new ArrayList<String>( 3 ); |
66 | |
|
67 | |
protected Class<? extends DocumentAuthorizer> documentAuthorizerClass; |
68 | 0 | protected List<HeaderNavigation> headerNavigationList = new ArrayList<HeaderNavigation>(); |
69 | |
|
70 | 0 | protected boolean allowsCopy = false; |
71 | |
protected WorkflowProperties workflowProperties; |
72 | |
protected WorkflowAttributes workflowAttributes; |
73 | |
|
74 | 0 | protected List<ReferenceDefinition> defaultExistenceChecks = new ArrayList<ReferenceDefinition>(); |
75 | 0 | protected Map<String,ReferenceDefinition> defaultExistenceCheckMap = new LinkedHashMap<String, ReferenceDefinition>(); |
76 | |
|
77 | 0 | protected boolean sessionDocument = false; |
78 | |
protected Class<? extends DocumentPresentationController> documentPresentationControllerClass; |
79 | |
protected Class<? extends DocumentSearchGenerator> documentSearchGeneratorClass; |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
public String getJstlKey() { |
85 | 0 | return documentTypeName; |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public void setDocumentClass(Class<? extends Document> documentClass) { |
93 | 0 | if (documentClass == null) { |
94 | 0 | throw new IllegalArgumentException("invalid (null) documentClass"); |
95 | |
} |
96 | |
|
97 | 0 | this.documentClass = documentClass; |
98 | 0 | } |
99 | |
|
100 | |
public Class<? extends Document> getDocumentClass() { |
101 | 0 | return documentClass; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public void setBaseDocumentClass(Class<? extends Document> baseDocumentClass) { |
110 | 0 | this.baseDocumentClass = baseDocumentClass; |
111 | 0 | } |
112 | |
|
113 | |
public Class<? extends Document> getBaseDocumentClass() { |
114 | 0 | return baseDocumentClass; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public void setBusinessRulesClass(Class<? extends BusinessRule> businessRulesClass) { |
122 | 0 | this.businessRulesClass = businessRulesClass; |
123 | 0 | } |
124 | |
|
125 | |
public Class<? extends BusinessRule> getBusinessRulesClass() { |
126 | 0 | return businessRulesClass; |
127 | |
} |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public void setDocumentAuthorizerClass(Class<? extends DocumentAuthorizer> documentAuthorizerClass) { |
135 | 0 | this.documentAuthorizerClass = documentAuthorizerClass; |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public Class<? extends DocumentAuthorizer> getDocumentAuthorizerClass() { |
146 | 0 | return documentAuthorizerClass; |
147 | |
} |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass() { |
153 | 0 | return promptBeforeValidationClass; |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public void setPromptBeforeValidationClass(Class<? extends PromptBeforeValidation> preRulesCheckClass) { |
163 | 0 | this.promptBeforeValidationClass = preRulesCheckClass; |
164 | 0 | } |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
public void setDocumentTypeName(String documentTypeName) { |
172 | 0 | if (StringUtils.isBlank(documentTypeName)) { |
173 | 0 | throw new IllegalArgumentException("invalid (blank) documentTypeName"); |
174 | |
} |
175 | 0 | this.documentTypeName = documentTypeName; |
176 | 0 | } |
177 | |
|
178 | |
public String getDocumentTypeName() { |
179 | 0 | return this.documentTypeName; |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
public void completeValidation() { |
188 | 0 | super.completeValidation(); |
189 | |
|
190 | 0 | if (baseDocumentClass != null && !baseDocumentClass.isAssignableFrom(documentClass)) { |
191 | 0 | throw new ClassValidationException("The baseDocumentClass " + baseDocumentClass.getName() + |
192 | |
" is not a superclass of the documentClass " + documentClass.getName()); |
193 | |
} |
194 | |
|
195 | 0 | if (workflowProperties != null && workflowAttributes != null) { |
196 | 0 | throw new DataDictionaryException(documentTypeName + ": workflowProperties and workflowAttributes cannot both be defined for a document"); |
197 | |
} |
198 | 0 | } |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public String getFullClassName() { |
204 | 0 | if ( getBaseDocumentClass() != null) { |
205 | 0 | return getBaseDocumentClass().getName(); |
206 | |
} |
207 | 0 | if ( getDocumentClass() != null ) { |
208 | 0 | return getDocumentClass().getName(); |
209 | |
} |
210 | 0 | return ""; |
211 | |
} |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public Class getEntryClass() { |
217 | 0 | return getDocumentClass(); |
218 | |
} |
219 | |
|
220 | |
public String toString() { |
221 | 0 | return "DocumentEntry for documentType " + documentTypeName; |
222 | |
} |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
public boolean getDisplayTopicFieldInNotes() { |
230 | 0 | return displayTopicFieldInNotes; |
231 | |
} |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
public void setDisplayTopicFieldInNotes(boolean displayTopicFieldInNotes) { |
238 | 0 | this.displayTopicFieldInNotes = displayTopicFieldInNotes; |
239 | 0 | } |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
public boolean getUsePessimisticLocking() { |
247 | 0 | return this.usePessimisticLocking; |
248 | |
} |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
public void setUsePessimisticLocking(boolean usePessimisticLocking) { |
254 | 0 | if ( LOG.isDebugEnabled() ) { |
255 | 0 | LOG.debug("calling setUsePessimisticLocking '" + usePessimisticLocking + "'"); |
256 | |
} |
257 | |
|
258 | 0 | this.usePessimisticLocking = usePessimisticLocking; |
259 | 0 | } |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
public boolean getUseWorkflowPessimisticLocking() { |
267 | 0 | return this.useWorkflowPessimisticLocking; |
268 | |
} |
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
public void setUseWorkflowPessimisticLocking(boolean useWorkflowPessimisticLocking) { |
274 | 0 | if ( LOG.isDebugEnabled() ) { |
275 | 0 | LOG.debug("calling setuseWorkflowPessimisticLocking '" + useWorkflowPessimisticLocking + "'"); |
276 | |
} |
277 | |
|
278 | 0 | this.useWorkflowPessimisticLocking = useWorkflowPessimisticLocking; |
279 | 0 | } |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
public void setAttachmentTypesValuesFinderClass(Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass) { |
287 | 0 | if (attachmentTypesValuesFinderClass == null) { |
288 | 0 | throw new IllegalArgumentException("invalid (null) attachmentTypesValuesFinderClass"); |
289 | |
} |
290 | |
|
291 | 0 | this.attachmentTypesValuesFinderClass = attachmentTypesValuesFinderClass; |
292 | 0 | } |
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
public Class<? extends KeyValuesFinder> getAttachmentTypesValuesFinderClass() { |
298 | 0 | return attachmentTypesValuesFinderClass; |
299 | |
} |
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
public void setAllowsCopy(boolean allowsCopy) { |
307 | 0 | this.allowsCopy = allowsCopy; |
308 | 0 | } |
309 | |
|
310 | |
public boolean getAllowsCopy() { |
311 | 0 | return allowsCopy; |
312 | |
} |
313 | |
|
314 | |
public List<HeaderNavigation> getHeaderNavigationList() { |
315 | 0 | return headerNavigationList; |
316 | |
} |
317 | |
|
318 | |
public List<String> getWebScriptFiles() { |
319 | 0 | return webScriptFiles; |
320 | |
} |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
public void setWebScriptFiles(List<String> webScriptFiles) { |
328 | 0 | this.webScriptFiles = webScriptFiles; |
329 | 0 | } |
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
public boolean getAllowsNoteAttachments() { |
335 | 0 | return this.allowsNoteAttachments; |
336 | |
} |
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
public void setAllowsNoteAttachments(boolean allowsNoteAttachments) { |
344 | 0 | this.allowsNoteAttachments = allowsNoteAttachments; |
345 | 0 | } |
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
public boolean getAllowsNoteFYI() { |
351 | 0 | return allowsNoteFYI; |
352 | |
} |
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
public void setAllowsNoteFYI(boolean allowsNoteFYI) { |
358 | 0 | this.allowsNoteFYI = allowsNoteFYI; |
359 | 0 | } |
360 | |
|
361 | |
public WorkflowProperties getWorkflowProperties() { |
362 | 0 | return this.workflowProperties; |
363 | |
} |
364 | |
|
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
public void setWorkflowProperties(WorkflowProperties workflowProperties) { |
371 | 0 | this.workflowProperties = workflowProperties; |
372 | 0 | } |
373 | |
|
374 | |
public WorkflowAttributes getWorkflowAttributes() { |
375 | 0 | return this.workflowAttributes; |
376 | |
} |
377 | |
|
378 | |
public void setWorkflowAttributes(WorkflowAttributes workflowAttributes) { |
379 | 0 | this.workflowAttributes = workflowAttributes; |
380 | 0 | } |
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
public void setHeaderNavigationList(List<HeaderNavigation> headerNavigationList) { |
387 | 0 | this.headerNavigationList = headerNavigationList; |
388 | 0 | } |
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
public List<ReferenceDefinition> getDefaultExistenceChecks() { |
397 | 0 | return defaultExistenceChecks; |
398 | |
} |
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
public void setDefaultExistenceChecks(List<ReferenceDefinition> defaultExistenceChecks) { |
410 | 0 | this.defaultExistenceChecks = defaultExistenceChecks; |
411 | 0 | } |
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
public List<String> getDefaultExistenceCheckFieldNames() { |
419 | 0 | List<String> fieldNames = new ArrayList<String>(); |
420 | 0 | fieldNames.addAll(this.defaultExistenceCheckMap.keySet()); |
421 | |
|
422 | 0 | return fieldNames; |
423 | |
} |
424 | |
|
425 | |
|
426 | |
|
427 | |
public boolean isSessionDocument() { |
428 | 0 | return this.sessionDocument; |
429 | |
} |
430 | |
|
431 | |
public void setSessionDocument(boolean sessionDocument) { |
432 | 0 | this.sessionDocument = sessionDocument; |
433 | 0 | } |
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
public Class<? extends DocumentPresentationController> getDocumentPresentationControllerClass() { |
443 | 0 | return this.documentPresentationControllerClass; |
444 | |
} |
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
public void setDocumentPresentationControllerClass( |
450 | |
Class<? extends DocumentPresentationController> documentPresentationControllerClass) { |
451 | 0 | this.documentPresentationControllerClass = documentPresentationControllerClass; |
452 | 0 | } |
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
public Class<? extends DerivedValuesSetter> getDerivedValuesSetterClass() { |
458 | 0 | return this.derivedValuesSetterClass; |
459 | |
} |
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
public void setDerivedValuesSetterClass( |
465 | |
Class<? extends DerivedValuesSetter> derivedValuesSetter) { |
466 | 0 | this.derivedValuesSetterClass = derivedValuesSetter; |
467 | 0 | } |
468 | |
|
469 | |
public boolean isEncryptDocumentDataInPersistentSessionStorage() { |
470 | 0 | return this.encryptDocumentDataInPersistentSessionStorage; |
471 | |
} |
472 | |
|
473 | |
public void setEncryptDocumentDataInPersistentSessionStorage( |
474 | |
boolean encryptDocumentDataInPersistentSessionStorage) { |
475 | 0 | this.encryptDocumentDataInPersistentSessionStorage = encryptDocumentDataInPersistentSessionStorage; |
476 | 0 | } |
477 | |
|
478 | |
public Class<? extends DocumentSearchGenerator> getDocumentSearchGeneratorClass() { |
479 | 0 | return this.documentSearchGeneratorClass; |
480 | |
} |
481 | |
|
482 | |
public void setDocumentSearchGeneratorClass( |
483 | |
Class<? extends DocumentSearchGenerator> documentSearchGeneratorClass) { |
484 | 0 | this.documentSearchGeneratorClass = documentSearchGeneratorClass; |
485 | 0 | } |
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
@Override |
493 | |
public void afterPropertiesSet() throws Exception { |
494 | 0 | super.afterPropertiesSet(); |
495 | 0 | if ( defaultExistenceChecks != null) { |
496 | 0 | defaultExistenceCheckMap.clear(); |
497 | 0 | for ( ReferenceDefinition reference : defaultExistenceChecks ) { |
498 | 0 | if (reference == null) { |
499 | 0 | throw new IllegalArgumentException("invalid (null) defaultExistenceCheck"); |
500 | |
} |
501 | |
|
502 | 0 | String keyName = reference.isCollectionReference()? (reference.getCollection()+"."+reference.getAttributeName()):reference.getAttributeName(); |
503 | 0 | if (defaultExistenceCheckMap.containsKey(keyName)) { |
504 | 0 | throw new DuplicateEntryException("duplicate defaultExistenceCheck entry for attribute '" + keyName + "'"); |
505 | |
} |
506 | 0 | reference.setBusinessObjectClass(getEntryClass()); |
507 | 0 | defaultExistenceCheckMap.put(keyName, reference); |
508 | 0 | } |
509 | |
} |
510 | 0 | } |
511 | |
} |