View Javadoc
1   /*
2    * Copyright 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.pdp.businessobject.inquiry;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  import java.util.Properties;
21  
22  import org.kuali.ole.pdp.PdpPropertyConstants;
23  import org.kuali.ole.pdp.businessobject.PayeeACHAccount;
24  import org.kuali.ole.pdp.businessobject.PayeeType;
25  import org.kuali.ole.sys.OLEConstants;
26  import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl;
27  import org.kuali.rice.core.api.util.type.KualiInteger;
28  import org.kuali.rice.kns.lookup.HtmlData;
29  import org.kuali.rice.krad.bo.BusinessObject;
30  import org.kuali.rice.krad.util.KRADConstants;
31  import org.kuali.rice.krad.util.ObjectUtils;
32  import org.kuali.rice.krad.util.UrlFactory;
33  
34  /**
35   * Customer inquiry for "Payee ACH Account Lookup" results.
36   */
37  public class PayeeAchAccountInquirable extends KfsInquirableImpl {
38  
39      /**
40       * @see org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject,
41       *      java.lang.String, boolean)
42       */
43      @Override
44      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
45          
46          HtmlData htmlData = null;
47          
48          //
49          // Creates a customized inquiry link for the 'payeeName' attribute.
50          //
51          if (PdpPropertyConstants.PAYEE_NAME.equals(attributeName)) {
52              Properties parameters = new Properties();
53  
54              parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD);
55              parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PayeeACHAccount.class.getName());
56  
57              KualiInteger generatedIdentifier = (KualiInteger) ObjectUtils.getPropertyValue(businessObject, PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER);
58              parameters.put(PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER, generatedIdentifier.toString());
59  
60              Map<String, String> fieldList = new HashMap<String, String>();
61              fieldList.put(PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER, generatedIdentifier.toString());
62              
63              htmlData = getHyperLink(PayeeACHAccount.class, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters));
64          }
65          
66          //
67          // Creates a customized inquiry link for the 'payeeIdentifierTypeCode' attribute.
68          //
69          else if (PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE.equals(attributeName)) {
70              Properties parameters = new Properties();
71  
72              parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD);
73              parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PayeeType.class.getName());
74  
75              String payeeIdentifierCode = (String) ObjectUtils.getPropertyValue(businessObject, PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE);
76              parameters.put(PdpPropertyConstants.PAYEE_CODE, payeeIdentifierCode);
77  
78              Map<String, String> fieldList = new HashMap<String, String>();
79              fieldList.put(PdpPropertyConstants.PAYEE_CODE, payeeIdentifierCode);
80              
81              htmlData = getHyperLink(PayeeType.class, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters));
82          }
83          
84          //
85          // Default.
86          //
87          else {
88              htmlData = super.getInquiryUrl(businessObject, attributeName, forceInquiry);            
89          }
90          
91          return htmlData;
92      }
93  
94  }