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.pdp.service.impl;
017
018 import java.util.Collection;
019 import java.util.HashMap;
020 import java.util.Map;
021
022 import org.kuali.kfs.pdp.PdpConstants;
023 import org.kuali.kfs.pdp.PdpPropertyConstants;
024 import org.kuali.kfs.pdp.businessobject.PayeeACHAccount;
025 import org.kuali.kfs.pdp.service.AchService;
026 import org.kuali.kfs.sys.KFSPropertyConstants;
027 import org.kuali.rice.kns.service.BusinessObjectService;
028
029 /**
030 * @see org.kuali.kfs.pdp.service.AchService
031 */
032 public class AchServiceImpl implements AchService {
033 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AchServiceImpl.class);
034
035 private BusinessObjectService businessObjectService;
036
037 /**
038 * @see org.kuali.kfs.pdp.service.AchService#getAchInformation(java.lang.String, java.lang.String, java.lang.String)
039 */
040 public PayeeACHAccount getAchInformation(String idType, String payeeId, String achTransactionType) {
041 LOG.debug("getAchInformation() started");
042
043 Map<String, Object> fields = new HashMap<String, Object>();
044
045 fields.put(KFSPropertyConstants.ACTIVE, Boolean.TRUE);
046 fields.put(PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, idType);
047 fields.put(PdpPropertyConstants.ACH_TRANSACTION_TYPE, achTransactionType);
048 fields.put(PdpPropertyConstants.PAYEE_ID_NUMBER, payeeId);
049
050 Collection<PayeeACHAccount> rows = businessObjectService.findMatching(PayeeACHAccount.class, fields);
051 if (rows.size() != 1) {
052 LOG.debug("getAchInformation() not found rows = " + rows.size());
053
054 return null;
055 }
056 else {
057 LOG.debug("getAchInformation() found");
058
059 return rows.iterator().next();
060 }
061 }
062
063 /**
064 * Sets the businessObjectService attribute value.
065 *
066 * @param businessObjectService The businessObjectService to set.
067 */
068 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
069 this.businessObjectService = businessObjectService;
070 }
071
072 }