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