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.businessobject.inquiry;
017
018 import java.util.HashMap;
019 import java.util.Map;
020 import java.util.Properties;
021
022 import org.kuali.kfs.pdp.PdpPropertyConstants;
023 import org.kuali.kfs.pdp.businessobject.PayeeACHAccount;
024 import org.kuali.kfs.pdp.businessobject.PayeeType;
025 import org.kuali.kfs.sys.KFSConstants;
026 import org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl;
027 import org.kuali.rice.kns.bo.BusinessObject;
028 import org.kuali.rice.kns.lookup.HtmlData;
029 import org.kuali.rice.kns.util.KNSConstants;
030 import org.kuali.rice.kns.util.KualiInteger;
031 import org.kuali.rice.kns.util.ObjectUtils;
032 import org.kuali.rice.kns.util.UrlFactory;
033
034 /**
035 * Customer inquiry for "Payee ACH Account Lookup" results.
036 */
037 public class PayeeAchAccountInquirable extends KfsInquirableImpl {
038
039 /**
040 * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject,
041 * java.lang.String, boolean)
042 */
043 @Override
044 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
045
046 HtmlData htmlData = null;
047
048 //
049 // Creates a customized inquiry link for the 'payeeName' attribute.
050 //
051 if (PdpPropertyConstants.PAYEE_NAME.equals(attributeName)) {
052 Properties parameters = new Properties();
053
054 parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.START_METHOD);
055 parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PayeeACHAccount.class.getName());
056
057 KualiInteger generatedIdentifier = (KualiInteger) ObjectUtils.getPropertyValue(businessObject, PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER);
058 parameters.put(PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER, generatedIdentifier.toString());
059
060 Map<String, String> fieldList = new HashMap<String, String>();
061 fieldList.put(PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER, generatedIdentifier.toString());
062
063 htmlData = getHyperLink(PayeeACHAccount.class, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters));
064 }
065
066 //
067 // Creates a customized inquiry link for the 'payeeIdentifierTypeCode' attribute.
068 //
069 else if (PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE.equals(attributeName)) {
070 Properties parameters = new Properties();
071
072 parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.START_METHOD);
073 parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PayeeType.class.getName());
074
075 String payeeIdentifierCode = (String) ObjectUtils.getPropertyValue(businessObject, PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE);
076 parameters.put(PdpPropertyConstants.PAYEE_CODE, payeeIdentifierCode);
077
078 Map<String, String> fieldList = new HashMap<String, String>();
079 fieldList.put(PdpPropertyConstants.PAYEE_CODE, payeeIdentifierCode);
080
081 htmlData = getHyperLink(PayeeType.class, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters));
082 }
083
084 //
085 // Default.
086 //
087 else {
088 htmlData = super.getInquiryUrl(businessObject, attributeName, forceInquiry);
089 }
090
091 return htmlData;
092 }
093
094 }