View Javadoc
1   /*
2    * Copyright 2005 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.coa.service.impl;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.kuali.ole.coa.businessobject.SubAccount;
22  import org.kuali.ole.coa.service.SubAccountService;
23  import org.kuali.ole.sys.OLEPropertyConstants;
24  import org.kuali.ole.sys.service.NonTransactional;
25  import org.kuali.rice.krad.service.BusinessObjectService;
26  import org.springframework.cache.annotation.Cacheable;
27  
28  /**
29   * This class is the service implementation for the SubAccount structure. This is the default implementation that gets delivered
30   * with Kuali.
31   */
32  
33  @NonTransactional
34  public class SubAccountServiceImpl implements SubAccountService {
35  
36      protected BusinessObjectService businessObjectService;
37      /**
38       * @see org.kuali.ole.coa.service.SubAccountService#getByPrimaryId(java.lang.String, java.lang.String, java.lang.String)
39       */
40      @Override
41      public SubAccount getByPrimaryId(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
42          Map<String, Object> keys = new HashMap<String, Object>(3);
43          keys.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode);
44          keys.put(OLEPropertyConstants.ACCOUNT_NUMBER, accountNumber);
45          keys.put(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, subAccountNumber);
46          return businessObjectService.findByPrimaryKey(SubAccount.class, keys);
47      }
48  
49      /**
50       * Method is used by KualiAccountAttribute to enable caching of accounts for routing.
51       * 
52       * @see org.kuali.ole.coa.service.impl.SubAccountServiceImpl#getByPrimaryId(String, String, String)
53       */
54      @Override
55      @Cacheable(value=SubAccount.CACHE_NAME, key="#p0+'-'+#p1+'-'+#p2")
56      public SubAccount getByPrimaryIdWithCaching(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
57          return getByPrimaryId(chartOfAccountsCode, accountNumber, subAccountNumber);
58      }
59  
60      public void setBusinessObjectService(BusinessObjectService businessObjectService) {
61          this.businessObjectService = businessObjectService;
62      }
63  
64  }