001/* 002 * Copyright 2005 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.coa.service.impl; 017 018import java.util.HashMap; 019import java.util.Map; 020 021import org.kuali.ole.coa.businessobject.SubAccount; 022import org.kuali.ole.coa.service.SubAccountService; 023import org.kuali.ole.sys.OLEPropertyConstants; 024import org.kuali.ole.sys.service.NonTransactional; 025import org.kuali.rice.krad.service.BusinessObjectService; 026import org.springframework.cache.annotation.Cacheable; 027 028/** 029 * This class is the service implementation for the SubAccount structure. This is the default implementation that gets delivered 030 * with Kuali. 031 */ 032 033@NonTransactional 034public class SubAccountServiceImpl implements SubAccountService { 035 036 protected BusinessObjectService businessObjectService; 037 /** 038 * @see org.kuali.ole.coa.service.SubAccountService#getByPrimaryId(java.lang.String, java.lang.String, java.lang.String) 039 */ 040 @Override 041 public SubAccount getByPrimaryId(String chartOfAccountsCode, String accountNumber, String subAccountNumber) { 042 Map<String, Object> keys = new HashMap<String, Object>(3); 043 keys.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); 044 keys.put(OLEPropertyConstants.ACCOUNT_NUMBER, accountNumber); 045 keys.put(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, subAccountNumber); 046 return businessObjectService.findByPrimaryKey(SubAccount.class, keys); 047 } 048 049 /** 050 * Method is used by KualiAccountAttribute to enable caching of accounts for routing. 051 * 052 * @see org.kuali.ole.coa.service.impl.SubAccountServiceImpl#getByPrimaryId(String, String, String) 053 */ 054 @Override 055 @Cacheable(value=SubAccount.CACHE_NAME, key="#p0+'-'+#p1+'-'+#p2") 056 public SubAccount getByPrimaryIdWithCaching(String chartOfAccountsCode, String accountNumber, String subAccountNumber) { 057 return getByPrimaryId(chartOfAccountsCode, accountNumber, subAccountNumber); 058 } 059 060 public void setBusinessObjectService(BusinessObjectService businessObjectService) { 061 this.businessObjectService = businessObjectService; 062 } 063 064}