01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.pdp.service.impl;
17:
18: import java.util.Collection;
19: import java.util.HashMap;
20: import java.util.Iterator;
21: import java.util.Map;
22:
23: import org.kuali.core.service.BusinessObjectService;
24: import org.kuali.module.pdp.PdpConstants;
25: import org.kuali.module.pdp.bo.PayeeAchAccount;
26: import org.kuali.module.pdp.service.AchInformation;
27: import org.kuali.module.pdp.service.AchService;
28: import org.springframework.transaction.annotation.Transactional;
29:
30: @Transactional
31: public class AchServiceImpl implements AchService {
32: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
33: .getLogger(AchServiceImpl.class);
34:
35: private BusinessObjectService businessObjectService;
36:
37: /**
38: * @see org.kuali.module.pdp.service.AchService#getAchInformation(java.lang.String, java.lang.String, java.lang.String)
39: */
40: public AchInformation getAchInformation(String idType,
41: String payeeId, String psdTransactionCode) {
42: LOG.debug("getAchInformation() started");
43:
44: Map fields = new HashMap();
45: fields.put("active", Boolean.TRUE);
46: fields.put("payeeIdentifierTypeCode", idType);
47: fields.put("psdTransactionCode", psdTransactionCode);
48: if (PdpConstants.PayeeIdTypeCodes.EMPLOYEE_ID.equals(idType)) {
49: fields.put("personUniversalIdentifier", payeeId);
50: } else if (PdpConstants.PayeeIdTypeCodes.SSN.equals(idType)) {
51: fields.put("payeeSocialSecurityNumber", payeeId);
52: } else if (PdpConstants.PayeeIdTypeCodes.PAYEE_ID
53: .equals(idType)) {
54: fields.put("disbVchrPayeeIdNumber", payeeId);
55: } else if (PdpConstants.PayeeIdTypeCodes.FEIN.equals(idType)) {
56: fields.put("payeeFederalEmployerIdentificationNumber",
57: payeeId);
58: } else if (PdpConstants.PayeeIdTypeCodes.VENDOR_ID
59: .equals(idType)) {
60: String parts[] = payeeId.split("-");
61: if (parts.length == 2) {
62: try {
63: fields.put("vendorHeaderGeneratedIdentifier",
64: new Integer(Integer.parseInt(parts[0])));
65: fields.put("vendorDetailAssignedIdentifier",
66: new Integer(Integer.parseInt(parts[1])));
67: } catch (NumberFormatException e) {
68: e.printStackTrace();
69: }
70: }
71: }
72: Collection rows = businessObjectService.findMatching(
73: PayeeAchAccount.class, fields);
74: if (rows.size() != 1) {
75: LOG.debug("getAchInformation() not found rows = "
76: + rows.size());
77:
78: return null;
79: } else {
80: LOG.debug("getAchInformation() found");
81:
82: Iterator i = rows.iterator();
83: PayeeAchAccount paa = (PayeeAchAccount) i.next();
84: AchInformation ai = new AchInformation();
85: ai.setAchAccountType("22"); // TODO Fix this
86: ai.setAchBankAccountNbr(paa.getBankAccountNumber());
87: ai.setAchBankRoutingNbr(paa.getBankRoutingNumber());
88: ai.setAdviceEmailAddress(paa.getPayeeEmailAddress());
89: ai.setDepartmentCode(paa.getPsdTransactionCode());
90: ai.setIdType(paa.getPayeeIdentifierTypeCode());
91: ai.setPayeeId(payeeId);
92: return ai;
93: }
94: }
95:
96: public void setBusinessObjectService(BusinessObjectService bos) {
97: businessObjectService = bos;
98: }
99: }
|