View Javadoc
1   /*
2    * Copyright 2007 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.pdp.service.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.kuali.ole.pdp.PdpPropertyConstants;
25  import org.kuali.ole.pdp.businessobject.PayeeACHAccount;
26  import org.kuali.ole.pdp.service.AchService;
27  import org.kuali.ole.sys.OLEPropertyConstants;
28  import org.kuali.rice.krad.service.BusinessObjectService;
29  
30  /**
31   * @see org.kuali.ole.pdp.service.AchService
32   */
33  public class AchServiceImpl implements AchService {
34      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AchServiceImpl.class);
35  
36      private BusinessObjectService businessObjectService;
37  
38      /**
39       * @see org.kuali.ole.pdp.service.AchService#getAchInformation(java.lang.String, java.lang.String, java.lang.String)
40       */
41      public PayeeACHAccount getAchInformation(String idType, String payeeId, String achTransactionType) {
42          LOG.debug("getAchInformation() started");
43  
44          Map<String, Object> fields = new HashMap<String, Object>();
45  
46          fields.put(OLEPropertyConstants.ACTIVE, Boolean.TRUE);
47          fields.put(PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, idType);
48          fields.put(PdpPropertyConstants.ACH_TRANSACTION_TYPE, achTransactionType);
49          fields.put(PdpPropertyConstants.PAYEE_ID_NUMBER, payeeId);
50  
51          Collection<PayeeACHAccount> rows = businessObjectService.findMatching(PayeeACHAccount.class, fields);
52          if (rows.size() != 1) {
53              if (LOG.isDebugEnabled()) {
54                  LOG.debug("getAchInformation() not found rows = " + rows.size());
55              }
56  
57              return null;
58          }
59          else {
60              LOG.debug("getAchInformation() found");
61  
62              return rows.iterator().next();
63          }
64      }
65  
66      /**
67       * @see org.kuali.ole.pdp.service.AchService#getActiveAchAccounts()
68       */
69      public List<PayeeACHAccount> getActiveAchAccounts() {
70          LOG.debug("getActivePayeeAchAccounts() started");
71  
72          Map<String, Object> fields = new HashMap<String, Object>();
73          fields.put(OLEPropertyConstants.ACTIVE, Boolean.TRUE);
74          Collection<PayeeACHAccount> accounts = businessObjectService.findMatchingOrderBy(PayeeACHAccount.class, fields, PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, true);
75          
76          return new ArrayList<PayeeACHAccount>(accounts);
77      }
78      
79      /**
80       * Sets the businessObjectService attribute value.
81       * 
82       * @param businessObjectService The businessObjectService to set.
83       */
84      public void setBusinessObjectService(BusinessObjectService businessObjectService) {
85          this.businessObjectService = businessObjectService;
86      }
87  
88  }