001 /* 002 * Copyright 2011 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.kfs.gl.service.impl; 017 018 import java.util.Iterator; 019 import java.util.Map; 020 021 import org.kuali.kfs.gl.businessobject.Encumbrance; 022 import org.kuali.kfs.gl.dataaccess.EncumbranceDao; 023 import org.kuali.kfs.gl.service.EncumbranceService; 024 import org.springframework.transaction.annotation.Transactional; 025 026 /** 027 * The base implementation of EncumbranaceService 028 */ 029 @Transactional 030 public class EncumbranceServiceImpl implements EncumbranceService { 031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EncumbranceServiceImpl.class); 032 033 private EncumbranceDao encumbranceDao; 034 035 /** 036 * Saves an encumbrance 037 * 038 * @param enc an encumbrance to save 039 * @see org.kuali.kfs.gl.service.EncumbranceService#save(org.kuali.kfs.gl.businessobject.Encumbrance) 040 */ 041 public void save(Encumbrance enc) { 042 LOG.debug("save() started"); 043 044 encumbranceDao.save(enc); 045 } 046 047 /** 048 * Removes all encumbrances from the database having a certain chart and fiscal year 049 * @param chartOfAccountsCode the chart of encumbrances to purge 050 * @param year the year of encumbrances to purge 051 * @see org.kuali.kfs.gl.service.EncumbranceService#purgeYearByChart(java.lang.String, int) 052 */ 053 public void purgeYearByChart(String chartOfAccountsCode, int year) { 054 LOG.debug("purgeYearByChart() started"); 055 056 encumbranceDao.purgeYearByChart(chartOfAccountsCode, year); 057 } 058 059 /** 060 * Returns an iterator with all encumbrances from the database. 061 * @return an Iterator of all encumbrances 062 * @see org.kuali.kfs.gl.service.EncumbranceService#getAllEncumbrances() 063 */ 064 public Iterator getAllEncumbrances() { 065 return encumbranceDao.getAllEncumbrances(); 066 } 067 068 /** 069 * Field accessor for EncumbranceDao 070 * 071 * @param ed 072 */ 073 public void setEncumbranceDao(EncumbranceDao ed) { 074 encumbranceDao = ed; 075 } 076 077 /** 078 * group all encumbrances with/without the given document type code by fiscal year, chart, account, sub-account, object code, 079 * sub object code, and balance type code, and summarize the encumbrance amount and the encumbrance close amount. 080 * 081 * @param documentTypeCode the given document type code 082 * @param included indicate if all encumbrances with the given document type are included in the results or not 083 * @see org.kuali.kfs.gl.service.EncumbranceService#getSummarizedEncumbrances(java.lang.String, boolean) 084 */ 085 public Iterator getSummarizedEncumbrances(String documentTypeCode, boolean included) { 086 return encumbranceDao.getSummarizedEncumbrances(documentTypeCode, included); 087 } 088 089 /** 090 * Given the fieldValues, forms a query and finds the open encumbrances that match it 091 * @param fieldValues the values to form an encumbrance query out of 092 * @return an Iterator full of qualifying encumbrances 093 * @see org.kuali.kfs.gl.service.EncumbranceService#findOpenEncumbrance(java.util.Map) 094 */ 095 public Iterator findOpenEncumbrance(Map fieldValues) { 096 return encumbranceDao.findOpenEncumbrance(fieldValues); 097 } 098 099 /** 100 * Returns the count of all open encumbrances in the database, matching the given field values 101 * @param fieldValues the field values to build an encumbrance query out of 102 * @return the number of qualifying open encumbrances 103 * @see org.kuali.kfs.gl.service.EncumbranceService#getOpenEncumbranceCount(java.util.Map) 104 */ 105 public Integer getOpenEncumbranceRecordCount(Map fieldValues) { 106 return encumbranceDao.getOpenEncumbranceRecordCount(fieldValues); 107 } 108 }