001/* 002 * Copyright 2007-2008 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.module.purap.document.service.impl; 017 018import org.apache.log4j.Logger; 019import org.kuali.ole.module.purap.businessobject.ReceivingAddress; 020import org.kuali.ole.module.purap.document.dataaccess.ReceivingAddressDao; 021import org.kuali.ole.module.purap.document.service.ReceivingAddressService; 022import org.springframework.transaction.annotation.Transactional; 023 024import java.util.Collection; 025import java.util.Iterator; 026 027@Transactional 028public class ReceivingAddressServiceImpl implements ReceivingAddressService { 029 private static Logger LOG = Logger.getLogger(ReceivingAddressServiceImpl.class); 030 031 private ReceivingAddressDao dao; 032 033 public void setReceivingAddressDao(ReceivingAddressDao dao) { 034 this.dao = dao; 035 } 036 037 /** 038 * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findActiveByChartOrg(java.lang.String, java.lang.String) 039 */ 040 public Collection<ReceivingAddress> findActiveByChartOrg(String chartCode, String orgCode) { 041 LOG.debug("Entering findActiveByChartOrg(String,String)"); 042 LOG.debug("Leaving findActiveByChartOrg(String,String)"); 043 return dao.findActiveByChartOrg(chartCode, orgCode); 044 } 045 046 /** 047 * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findDefaultByChartOrg(java.lang.String, java.lang.String) 048 */ 049 public Collection<ReceivingAddress> findDefaultByChartOrg(String chartCode, String orgCode) { 050 LOG.debug("Entering findDefaultByChartOrg(String,String)"); 051 LOG.debug("Leaving findDefaultByChartOrg(String,String)"); 052 return dao.findDefaultByChartOrg(chartCode, orgCode); 053 } 054 055 /** 056 * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findUniqueDefaultByChartOrg(java.lang.String, java.lang.String) 057 */ 058 public ReceivingAddress findUniqueDefaultByChartOrg(String chartCode, String orgCode) { 059 LOG.debug("Entering findUniqueDefaultByChartOrg(String,String)"); 060 Collection<ReceivingAddress> addresses = findDefaultByChartOrg(chartCode, orgCode); 061 if (addresses != null) { 062 Iterator iter = addresses.iterator(); 063 if (iter.hasNext()) { 064 LOG.debug("Leaving findUniqueDefaultByChartOrg(String,String)"); 065 return (ReceivingAddress) iter.next(); 066 } 067 } 068 LOG.debug("Leaving findUniqueDefaultByChartOrg(String,String)"); 069 return null; 070 //TODO what if more than one is found? throw an exception 071 } 072 073 /** 074 * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#countActiveByChartOrg(java.lang.String, java.lang.String) 075 */ 076 public int countActiveByChartOrg(String chartCode, String orgCode) { 077 LOG.debug("Entering countActiveByChartOrg(String,String)"); 078 LOG.debug("Leaving countActiveByChartOrg(String,String)"); 079 return dao.countActiveByChartOrg(chartCode, orgCode); 080 } 081 082}