1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.service.impl;
17
18 import org.kuali.ole.sys.document.AccountingDocument;
19 import org.kuali.ole.sys.document.FinancialSystemMaintenanceDocument;
20 import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument;
21 import org.kuali.ole.sys.document.LedgerPostingDocument;
22 import org.kuali.ole.sys.document.authorization.AccountingDocumentAuthorizerBase;
23 import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentAuthorizerBase;
24 import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
25 import org.kuali.ole.sys.document.authorization.FinancialSystemTransactionalDocumentAuthorizerBase;
26 import org.kuali.ole.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase;
27 import org.kuali.ole.sys.document.authorization.LedgerPostingDocumentPresentationControllerBase;
28 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
29 import org.kuali.rice.kns.document.authorization.DocumentPresentationController;
30 import org.kuali.rice.krad.datadictionary.DocumentEntry;
31
32 public class DocumentHelperServiceImpl extends org.kuali.rice.kns.service.impl.DocumentHelperServiceImpl {
33
34 @Override
35 public DocumentAuthorizer getDocumentAuthorizer(String documentType) {
36 DocumentEntry documentEntry = getDataDictionaryService().getDataDictionary().getDocumentEntry(documentType);
37 Class documentAuthorizerClass = documentEntry.getDocumentAuthorizerClass();
38 if (documentAuthorizerClass == null) {
39 if (FinancialSystemMaintenanceDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
40 documentAuthorizerClass = FinancialSystemMaintenanceDocumentAuthorizerBase.class;
41 }
42 else if (FinancialSystemTransactionalDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
43 if (AccountingDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
44 documentAuthorizerClass = AccountingDocumentAuthorizerBase.class;
45 }
46 else {
47 documentAuthorizerClass = FinancialSystemTransactionalDocumentAuthorizerBase.class;
48 }
49 }
50 else {
51 return super.getDocumentAuthorizer(documentType);
52 }
53 }
54 try {
55 return (DocumentAuthorizer) documentAuthorizerClass.newInstance();
56 }
57 catch (Exception e) {
58 throw new RuntimeException("Unable to instantiate DocumentAuthorizer class: " + documentAuthorizerClass, e);
59 }
60 }
61
62 @Override
63 public DocumentPresentationController getDocumentPresentationController(String documentType) {
64 org.kuali.rice.krad.datadictionary.DocumentEntry documentEntry = getDataDictionaryService().getDataDictionary().getDocumentEntry(documentType);
65 Class documentPresentationControllerClass = documentEntry.getDocumentPresentationControllerClass();
66 if (documentPresentationControllerClass == null) {
67 if (FinancialSystemMaintenanceDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
68 documentPresentationControllerClass = FinancialSystemMaintenanceDocumentPresentationControllerBase.class;
69 }
70 else if (FinancialSystemTransactionalDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
71 if (LedgerPostingDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) {
72 documentPresentationControllerClass = LedgerPostingDocumentPresentationControllerBase.class;
73 }
74 else {
75 documentPresentationControllerClass = FinancialSystemTransactionalDocumentPresentationControllerBase.class;
76 }
77 }
78 else {
79 return super.getDocumentPresentationController(documentType);
80 }
81 }
82 try {
83 return (DocumentPresentationController) documentPresentationControllerClass.newInstance();
84 }
85 catch (Exception e) {
86 throw new RuntimeException("Unable to instantiate DocumentPresentationController class: " + documentPresentationControllerClass, e);
87 }
88 }
89 }