001/* 002 * Copyright 2008-2009 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.sys.service.impl; 017 018import org.kuali.ole.sys.document.AccountingDocument; 019import org.kuali.ole.sys.document.FinancialSystemMaintenanceDocument; 020import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument; 021import org.kuali.ole.sys.document.LedgerPostingDocument; 022import org.kuali.ole.sys.document.authorization.AccountingDocumentAuthorizerBase; 023import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentAuthorizerBase; 024import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase; 025import org.kuali.ole.sys.document.authorization.FinancialSystemTransactionalDocumentAuthorizerBase; 026import org.kuali.ole.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase; 027import org.kuali.ole.sys.document.authorization.LedgerPostingDocumentPresentationControllerBase; 028import org.kuali.rice.kns.document.authorization.DocumentAuthorizer; 029import org.kuali.rice.kns.document.authorization.DocumentPresentationController; 030import org.kuali.rice.krad.datadictionary.DocumentEntry; 031 032public class DocumentHelperServiceImpl extends org.kuali.rice.kns.service.impl.DocumentHelperServiceImpl { 033 034 @Override 035 public DocumentAuthorizer getDocumentAuthorizer(String documentType) { 036 DocumentEntry documentEntry = getDataDictionaryService().getDataDictionary().getDocumentEntry(documentType); 037 Class documentAuthorizerClass = documentEntry.getDocumentAuthorizerClass(); 038 if (documentAuthorizerClass == null) { 039 if (FinancialSystemMaintenanceDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 040 documentAuthorizerClass = FinancialSystemMaintenanceDocumentAuthorizerBase.class; 041 } 042 else if (FinancialSystemTransactionalDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 043 if (AccountingDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 044 documentAuthorizerClass = AccountingDocumentAuthorizerBase.class; 045 } 046 else { 047 documentAuthorizerClass = FinancialSystemTransactionalDocumentAuthorizerBase.class; 048 } 049 } 050 else { 051 return super.getDocumentAuthorizer(documentType); 052 } 053 } 054 try { 055 return (DocumentAuthorizer) documentAuthorizerClass.newInstance(); 056 } 057 catch (Exception e) { 058 throw new RuntimeException("Unable to instantiate DocumentAuthorizer class: " + documentAuthorizerClass, e); 059 } 060 } 061 062 @Override 063 public DocumentPresentationController getDocumentPresentationController(String documentType) { 064 org.kuali.rice.krad.datadictionary.DocumentEntry documentEntry = getDataDictionaryService().getDataDictionary().getDocumentEntry(documentType); 065 Class documentPresentationControllerClass = documentEntry.getDocumentPresentationControllerClass(); 066 if (documentPresentationControllerClass == null) { 067 if (FinancialSystemMaintenanceDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 068 documentPresentationControllerClass = FinancialSystemMaintenanceDocumentPresentationControllerBase.class; 069 } 070 else if (FinancialSystemTransactionalDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 071 if (LedgerPostingDocument.class.isAssignableFrom(documentEntry.getDocumentClass())) { 072 documentPresentationControllerClass = LedgerPostingDocumentPresentationControllerBase.class; 073 } 074 else { 075 documentPresentationControllerClass = FinancialSystemTransactionalDocumentPresentationControllerBase.class; 076 } 077 } 078 else { 079 return super.getDocumentPresentationController(documentType); 080 } 081 } 082 try { 083 return (DocumentPresentationController) documentPresentationControllerClass.newInstance(); 084 } 085 catch (Exception e) { 086 throw new RuntimeException("Unable to instantiate DocumentPresentationController class: " + documentPresentationControllerClass, e); 087 } 088 } 089}