View Javadoc
1   /*
2    * Copyright 2007-2008 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.module.purap.document.service.impl;
17  
18  import org.apache.log4j.Logger;
19  import org.kuali.ole.module.purap.businessobject.ReceivingAddress;
20  import org.kuali.ole.module.purap.document.dataaccess.ReceivingAddressDao;
21  import org.kuali.ole.module.purap.document.service.ReceivingAddressService;
22  import org.springframework.transaction.annotation.Transactional;
23  
24  import java.util.Collection;
25  import java.util.Iterator;
26  
27  @Transactional
28  public class ReceivingAddressServiceImpl implements ReceivingAddressService {
29      private static Logger LOG = Logger.getLogger(ReceivingAddressServiceImpl.class);
30  
31      private ReceivingAddressDao dao;
32  
33      public void setReceivingAddressDao(ReceivingAddressDao dao) {
34          this.dao = dao;
35      }
36  
37      /**
38       * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findActiveByChartOrg(java.lang.String, java.lang.String)
39       */
40      public Collection<ReceivingAddress> findActiveByChartOrg(String chartCode, String orgCode) {
41          LOG.debug("Entering findActiveByChartOrg(String,String)");
42          LOG.debug("Leaving findActiveByChartOrg(String,String)");
43          return dao.findActiveByChartOrg(chartCode, orgCode);
44      }
45  
46      /**
47       * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findDefaultByChartOrg(java.lang.String, java.lang.String)
48       */
49      public Collection<ReceivingAddress> findDefaultByChartOrg(String chartCode, String orgCode) {
50          LOG.debug("Entering findDefaultByChartOrg(String,String)");
51          LOG.debug("Leaving findDefaultByChartOrg(String,String)");
52          return dao.findDefaultByChartOrg(chartCode, orgCode);
53      }
54  
55      /**
56       * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#findUniqueDefaultByChartOrg(java.lang.String, java.lang.String)
57       */
58      public ReceivingAddress findUniqueDefaultByChartOrg(String chartCode, String orgCode) {
59          LOG.debug("Entering findUniqueDefaultByChartOrg(String,String)");
60          Collection<ReceivingAddress> addresses = findDefaultByChartOrg(chartCode, orgCode);
61          if (addresses != null) {
62              Iterator iter = addresses.iterator();
63              if (iter.hasNext()) {
64                  LOG.debug("Leaving findUniqueDefaultByChartOrg(String,String)");
65                  return (ReceivingAddress) iter.next();
66              }
67          }
68          LOG.debug("Leaving findUniqueDefaultByChartOrg(String,String)");
69          return null;
70          //TODO what if more than one is found? throw an exception
71      }
72  
73      /**
74       * @see org.kuali.ole.module.purap.document.service.ReceivingAddressService#countActiveByChartOrg(java.lang.String, java.lang.String)
75       */
76      public int countActiveByChartOrg(String chartCode, String orgCode) {
77          LOG.debug("Entering countActiveByChartOrg(String,String)");
78          LOG.debug("Leaving countActiveByChartOrg(String,String)");
79          return dao.countActiveByChartOrg(chartCode, orgCode);
80      }
81  
82  }