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