001/*
002 * Copyright 2005-2006 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.SubObjectCode;
022import org.kuali.ole.coa.service.SubObjectCodeService;
023import org.kuali.ole.sys.OLEPropertyConstants;
024import org.kuali.ole.sys.context.SpringContext;
025import org.kuali.ole.sys.service.NonTransactional;
026import org.kuali.ole.sys.service.UniversityDateService;
027import org.kuali.rice.krad.service.BusinessObjectService;
028
029/**
030 * This class is the service implementation for the SubObjectCode structure. This is the default implementation that gets delivered
031 * with Kuali.
032 */
033
034@NonTransactional
035public class SubObjectCodeServiceImpl implements SubObjectCodeService {
036    private UniversityDateService universityDateService;
037
038    /**
039     * @see org.kuali.ole.coa.service.SubObjectCodeService#getByPrimaryId(java.lang.Integer, java.lang.String,
040     *      java.lang.String, java.lang.String, java.lang.String)
041     */
042    public SubObjectCode getByPrimaryId(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String financialObjectCode, String financialSubObjectCode) {
043        
044        Map<String, Object> keys = new HashMap<String, Object>();
045        keys.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, universityFiscalYear);
046        keys.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode);
047        keys.put(OLEPropertyConstants.ACCOUNT_NUMBER, accountNumber);
048        keys.put(OLEPropertyConstants.FINANCIAL_OBJECT_CODE, financialObjectCode);
049        keys.put(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, financialSubObjectCode);
050        return (SubObjectCode)SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(SubObjectCode.class, keys);
051    }
052
053    /**
054     * @see org.kuali.ole.coa.service.SubObjectCodeService#getByPrimaryIdForCurrentYear(java.lang.String, java.lang.String,
055     *      java.lang.String, java.lang.String)
056     */
057    public SubObjectCode getByPrimaryIdForCurrentYear(String chartOfAccountsCode, String accountNumber, String financialObjectCode, String financialSubObjectCode) {
058        return this.getByPrimaryId(universityDateService.getCurrentFiscalYear(), chartOfAccountsCode, accountNumber, financialObjectCode, financialSubObjectCode);
059    }
060
061    /**
062     * 
063     * This method injects UniversityDateService
064     * @param universityDateService
065     */
066    public void setUniversityDateService(UniversityDateService universityDateService) {
067        this.universityDateService = universityDateService;
068    }
069}