1 /* 2 * Copyright 2006 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.gl.service.impl; 17 18 import java.util.Iterator; 19 import java.util.Map; 20 21 import org.kuali.ole.gl.businessobject.Encumbrance; 22 import org.kuali.ole.gl.dataaccess.EncumbranceDao; 23 import org.kuali.ole.gl.service.EncumbranceService; 24 import org.kuali.ole.sys.context.SpringContext; 25 import org.kuali.rice.krad.service.BusinessObjectService; 26 import org.springframework.transaction.annotation.Transactional; 27 28 /** 29 * The base implementation of EncumbranaceService 30 */ 31 @Transactional 32 public class EncumbranceServiceImpl implements EncumbranceService { 33 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EncumbranceServiceImpl.class); 34 35 private EncumbranceDao encumbranceDao; 36 37 /** 38 * Saves an encumbrance 39 * 40 * @param enc an encumbrance to save 41 * @see org.kuali.ole.gl.service.EncumbranceService#save(org.kuali.ole.gl.businessobject.Encumbrance) 42 */ 43 public void save(Encumbrance enc) { 44 LOG.debug("save() started"); 45 SpringContext.getBean(BusinessObjectService.class).save(enc); 46 } 47 48 /** 49 * Removes all encumbrances from the database having a certain chart and fiscal year 50 * @param chartOfAccountsCode the chart of encumbrances to purge 51 * @param year the year of encumbrances to purge 52 * @see org.kuali.ole.gl.service.EncumbranceService#purgeYearByChart(java.lang.String, int) 53 */ 54 public void purgeYearByChart(String chartOfAccountsCode, int year) { 55 LOG.debug("purgeYearByChart() started"); 56 57 encumbranceDao.purgeYearByChart(chartOfAccountsCode, year); 58 } 59 60 /** 61 * Returns an iterator with all encumbrances from the database. 62 * @return an Iterator of all encumbrances 63 * @see org.kuali.ole.gl.service.EncumbranceService#getAllEncumbrances() 64 */ 65 public Iterator getAllEncumbrances() { 66 return encumbranceDao.getAllEncumbrances(); 67 } 68 69 /** 70 * Field accessor for EncumbranceDao 71 * 72 * @param ed 73 */ 74 public void setEncumbranceDao(EncumbranceDao ed) { 75 encumbranceDao = ed; 76 } 77 78 /** 79 * group all encumbrances with/without the given document type code by fiscal year, chart, account, sub-account, object code, 80 * sub object code, and balance type code, and summarize the encumbrance amount and the encumbrance close amount. 81 * 82 * @param documentTypeCode the given document type code 83 * @param included indicate if all encumbrances with the given document type are included in the results or not 84 * @see org.kuali.ole.gl.service.EncumbranceService#getSummarizedEncumbrances(java.lang.String, boolean) 85 */ 86 public Iterator getSummarizedEncumbrances(String documentTypeCode, boolean included) { 87 return encumbranceDao.getSummarizedEncumbrances(documentTypeCode, included); 88 } 89 90 /** 91 * Given the fieldValues, forms a query and finds the open encumbrances that match it 92 * @param fieldValues the values to form an encumbrance query out of 93 * @param includeZeroEncumbrances 94 * @return an Iterator full of qualifying encumbrances 95 * @see org.kuali.ole.gl.service.EncumbranceService#findOpenEncumbrance(java.util.Map) 96 */ 97 public Iterator findOpenEncumbrance(Map fieldValues, boolean includeZeroEncumbrances) { 98 return encumbranceDao.findOpenEncumbrance(fieldValues, includeZeroEncumbrances); 99 } 100 101 /** 102 * Returns the count of all open encumbrances in the database, matching the given field values 103 * @param fieldValues the field values to build an encumbrance query out of 104 * @param includeZeroEncumbrances 105 * @return the number of qualifying open encumbrances 106 * @see org.kuali.ole.gl.service.EncumbranceService#getOpenEncumbranceCount(java.util.Map) 107 */ 108 public Integer getOpenEncumbranceRecordCount(Map fieldValues, boolean includeZeroEncumbrances) { 109 return encumbranceDao.getOpenEncumbranceRecordCount(fieldValues, includeZeroEncumbrances); 110 } 111 }