001 /** 002 * Copyright 2005-2012 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 */ 016 package org.kuali.rice.krad.service.impl; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.rice.krad.bo.DocumentHeader; 020 import org.kuali.rice.krad.dao.DocumentHeaderDao; 021 import org.kuali.rice.krad.service.DocumentHeaderService; 022 import org.kuali.rice.krad.service.KRADServiceLocator; 023 import org.springframework.transaction.annotation.Transactional; 024 025 /** 026 * This is an implementation of {@link DocumentHeaderService} that facilitates 027 * document header management and customization 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 * 031 */ 032 @Transactional 033 public class DocumentHeaderServiceImpl implements DocumentHeaderService { 034 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentHeaderServiceImpl.class); 035 private DocumentHeaderDao documentHeaderDao; 036 037 /** 038 * @see org.kuali.rice.krad.service.DocumentHeaderService#getDocumentHeaderBaseClass() 039 */ 040 public Class<? extends DocumentHeader> getDocumentHeaderBaseClass() { 041 Class documentHeaderClass = documentHeaderDao.getDocumentHeaderBaseClass(); 042 if ( (documentHeaderClass == null) || (!DocumentHeader.class.isAssignableFrom(documentHeaderClass)) ) { 043 throw new RuntimeException("invalid document header base class '" + documentHeaderClass + "' returned by dao '" + documentHeaderDao.getClass().getName() + "'"); 044 } 045 return documentHeaderClass; 046 } 047 048 /** 049 * @see org.kuali.rice.krad.service.DocumentHeaderService#getDocumentHeaderById(java.lang.String) 050 */ 051 public DocumentHeader getDocumentHeaderById(String documentHeaderId) { 052 if (StringUtils.isBlank(documentHeaderId)) { 053 throw new IllegalArgumentException("document header id given is blank"); 054 } 055 return documentHeaderDao.getByDocumentHeaderId(documentHeaderId); 056 } 057 058 /** 059 * @see org.kuali.rice.krad.service.DocumentHeaderService#saveDocumentHeader(org.kuali.rice.krad.bo.DocumentHeader) 060 */ 061 public void saveDocumentHeader(DocumentHeader documentHeader) { 062 KRADServiceLocator.getBusinessObjectService().save(documentHeader); 063 } 064 065 /** 066 * @see org.kuali.rice.krad.service.DocumentHeaderService#deleteDocumentHeader(org.kuali.rice.krad.bo.DocumentHeader) 067 */ 068 public void deleteDocumentHeader(DocumentHeader documentHeader) { 069 KRADServiceLocator.getBusinessObjectService().delete(documentHeader); 070 } 071 072 /** 073 * dao injected by spring 074 * 075 * @param documentHeaderDao 076 */ 077 public void setDocumentHeaderDao(DocumentHeaderDao documentHeaderDao) { 078 this.documentHeaderDao = documentHeaderDao; 079 } 080 081 }