1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.datadictionary.exporter; |
17 | |
|
18 | |
import org.kuali.rice.kew.dto.DocumentTypeDTO; |
19 | |
import org.kuali.rice.kew.exception.WorkflowException; |
20 | |
import org.kuali.rice.kns.datadictionary.DocumentEntry; |
21 | |
import org.kuali.rice.kns.service.DocumentHelperService; |
22 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public abstract class DocumentEntryMapper { |
30 | |
|
31 | |
protected DocumentTypeDTO getDocumentType(String documentTypeName) { |
32 | |
try { |
33 | 0 | return KNSServiceLocatorWeb.getWorkflowInfoService().getDocType(documentTypeName); |
34 | 0 | } catch (WorkflowException e) { |
35 | 0 | throw new RuntimeException("Caught Exception trying to get the Workflow Document Type", e); |
36 | |
} |
37 | |
} |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@SuppressWarnings("unchecked") |
44 | |
protected ExportMap mapEntry(DocumentEntry entry) { |
45 | 0 | if (entry == null) { |
46 | 0 | throw new IllegalArgumentException("invalid (null) entry"); |
47 | |
} |
48 | |
|
49 | |
|
50 | 0 | ExportMap entryMap = new ExportMap(entry.getJstlKey()); |
51 | |
|
52 | 0 | Class businessRulesClass = entry.getBusinessRulesClass(); |
53 | 0 | if (businessRulesClass != null) { |
54 | 0 | entryMap.set("businessRulesClass", businessRulesClass.getName()); |
55 | |
} |
56 | |
|
57 | 0 | entryMap.set("documentTypeName", entry.getDocumentTypeName()); |
58 | |
|
59 | 0 | DocumentTypeDTO docType = getDocumentType(entry.getDocumentTypeName()); |
60 | 0 | entryMap.set("label", docType.getDocTypeLabel()); |
61 | |
|
62 | 0 | if (docType.getDocTypeDescription() != null) { |
63 | 0 | entryMap.set("description", docType.getDocTypeDescription()); |
64 | |
} |
65 | |
|
66 | 0 | DocumentHelperService documentHelperService = KNSServiceLocatorWeb.getDocumentHelperService(); |
67 | 0 | entryMap.set("documentAuthorizerClass", documentHelperService.getDocumentAuthorizer(entry.getDocumentTypeName()).getClass().getName()); |
68 | 0 | entryMap.set("documentPresentationControllerClass", documentHelperService.getDocumentPresentationController(entry.getDocumentTypeName()).getClass().getName()); |
69 | |
|
70 | 0 | entryMap.set("allowsNoteAttachments", Boolean.toString(entry.getAllowsNoteAttachments())); |
71 | |
|
72 | 0 | entryMap.set("allowsNoteFYI", Boolean.toString(entry.getAllowsNoteFYI())); |
73 | |
|
74 | 0 | if (entry.getAttachmentTypesValuesFinderClass() != null) { |
75 | 0 | entryMap.set("attachmentTypesValuesFinderClass", entry.getAttachmentTypesValuesFinderClass().getName()); |
76 | |
} |
77 | |
|
78 | 0 | entryMap.set("displayTopicFieldInNotes", Boolean.toString(entry.getDisplayTopicFieldInNotes())); |
79 | |
|
80 | 0 | entryMap.set("usePessimisticLocking", Boolean.toString(entry.getUsePessimisticLocking())); |
81 | 0 | entryMap.set("useWorkflowPessimisticLocking", Boolean.toString(entry.getUseWorkflowPessimisticLocking())); |
82 | 0 | entryMap.set("sessionDocument", Boolean.toString(entry.isSessionDocument())); |
83 | |
|
84 | 0 | entryMap.set(new AttributesMapBuilder().buildAttributesMap(entry)); |
85 | 0 | entryMap.set(new CollectionsMapBuilder().buildCollectionsMap(entry)); |
86 | |
|
87 | 0 | return entryMap; |
88 | |
} |
89 | |
|
90 | |
} |