1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.service.impl; |
17 | |
|
18 | |
import java.util.Collection; |
19 | |
|
20 | |
import org.kuali.rice.kew.dto.DocumentTypeDTO; |
21 | |
import org.kuali.rice.kew.exception.WorkflowException; |
22 | |
import org.kuali.rice.kns.datadictionary.DataDictionary; |
23 | |
import org.kuali.rice.kns.datadictionary.TransactionalDocumentEntry; |
24 | |
import org.kuali.rice.kns.document.TransactionalDocument; |
25 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
26 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
27 | |
import org.kuali.rice.kns.service.TransactionalDocumentDictionaryService; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class TransactionalDocumentDictionaryServiceImpl implements TransactionalDocumentDictionaryService { |
34 | |
private DataDictionaryService dataDictionaryService; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public Boolean getAllowsCopy(TransactionalDocument document) { |
40 | 0 | Boolean allowsCopy = null; |
41 | |
|
42 | 0 | TransactionalDocumentEntry entry = getTransactionalDocumentEntry(document); |
43 | 0 | if (entry != null) { |
44 | 0 | allowsCopy = Boolean.valueOf(entry.getAllowsCopy()); |
45 | |
} |
46 | |
|
47 | 0 | return allowsCopy; |
48 | |
} |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public Class getDocumentClassByName(String documentTypeName) { |
54 | 0 | Class documentClass = null; |
55 | |
|
56 | 0 | TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(documentTypeName); |
57 | 0 | if (entry != null) { |
58 | 0 | documentClass = entry.getDocumentClass(); |
59 | |
} |
60 | |
|
61 | 0 | return documentClass; |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public String getDescription(String transactionalDocumentTypeName) { |
68 | 0 | String description = null; |
69 | |
|
70 | 0 | DocumentTypeDTO docType = getDocumentType(transactionalDocumentTypeName); |
71 | 0 | if (docType != null) { |
72 | 0 | description = docType.getDocTypeDescription(); |
73 | |
} |
74 | |
|
75 | 0 | return description; |
76 | |
} |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public String getLabel(String transactionalDocumentTypeName) { |
82 | 0 | String label = null; |
83 | |
|
84 | 0 | DocumentTypeDTO docType = getDocumentType(transactionalDocumentTypeName); |
85 | 0 | if (docType != null) { |
86 | 0 | label = docType.getDocTypeLabel(); |
87 | |
} |
88 | |
|
89 | 0 | return label; |
90 | |
} |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public Class getBusinessRulesClass(TransactionalDocument document) { |
96 | 0 | Class businessRulesClass = null; |
97 | |
|
98 | |
|
99 | 0 | String docTypeName = document.getDocumentHeader().getWorkflowDocument().getDocumentType(); |
100 | 0 | TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName); |
101 | 0 | if (entry != null) { |
102 | 0 | businessRulesClass = entry.getBusinessRulesClass(); |
103 | |
} |
104 | |
|
105 | 0 | return businessRulesClass; |
106 | |
} |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { |
114 | 0 | this.dataDictionaryService = dataDictionaryService; |
115 | 0 | } |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public DataDictionary getDataDictionary() { |
123 | 0 | return this.dataDictionaryService.getDataDictionary(); |
124 | |
} |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
protected DocumentTypeDTO getDocumentType(String documentTypeName) { |
133 | |
try { |
134 | 0 | return KNSServiceLocator.getWorkflowInfoService().getDocType(documentTypeName); |
135 | 0 | } catch (WorkflowException e) { |
136 | 0 | throw new RuntimeException("Caught exception attempting to get document type for doc type name '" + documentTypeName + "'", e); |
137 | |
} |
138 | |
} |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
private TransactionalDocumentEntry getTransactionalDocumentEntry(TransactionalDocument document) { |
147 | 0 | if (document == null) { |
148 | 0 | throw new IllegalArgumentException("invalid (null) document"); |
149 | |
} |
150 | |
|
151 | 0 | TransactionalDocumentEntry entry = (TransactionalDocumentEntry)getDataDictionary().getDocumentEntry(document.getClass().getName()); |
152 | |
|
153 | 0 | return entry; |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
private TransactionalDocumentEntry getTransactionalDocumentEntryBydocumentTypeName(String documentTypeName) { |
163 | 0 | if (documentTypeName == null) { |
164 | 0 | throw new IllegalArgumentException("invalid (null) document type name"); |
165 | |
} |
166 | |
|
167 | 0 | TransactionalDocumentEntry entry = (TransactionalDocumentEntry) getDataDictionary().getDocumentEntry(documentTypeName); |
168 | |
|
169 | 0 | return entry; |
170 | |
} |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
public Collection getDefaultExistenceChecks(String docTypeName) { |
178 | 0 | Collection defaultExistenceChecks = null; |
179 | |
|
180 | 0 | TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName); |
181 | 0 | if (entry != null) { |
182 | 0 | defaultExistenceChecks = entry.getDefaultExistenceChecks(); |
183 | |
} |
184 | |
|
185 | 0 | return defaultExistenceChecks; |
186 | |
} |
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
public Collection getDefaultExistenceChecks(TransactionalDocument document) { |
194 | 0 | return getDefaultExistenceChecks(getTransactionalDocumentEntry(document).getDocumentTypeName()); |
195 | |
} |
196 | |
} |