View Javadoc
1   /*
2    * Copyright 2009 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.PaymentDetail;
24  import org.kuali.ole.pdp.businessobject.PurchasingPaymentDetail;
25  import org.kuali.ole.sys.OLEConstants;
26  import org.kuali.ole.sys.context.SpringContext;
27  import org.kuali.rice.core.api.config.property.ConfigurationService;
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  public class PurchasingPaymentDetailInquirable extends PaymentDetailInquirable {
35  
36      /**
37       * @see org.kuali.ole.pdp.businessobject.inquiry.PaymentDetailInquirable#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject, java.lang.String, boolean)
38       */
39      @Override
40      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
41          PaymentDetail paymentDetail = (PaymentDetail) businessObject;
42          if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_PAYMENT_GROUP.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroupId())) {
43  
44              Properties params = new Properties();
45              params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD);
46              params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName());
47              params.put(KRADConstants.DOC_FORM_KEY, "88888888");
48              params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true");
49              params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do");
50              params.put(OLEConstants.LOOKUP_READ_ONLY_FIELDS, PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID);
51              params.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, UrlFactory.encode(String.valueOf(paymentDetail.getPaymentGroupId())));
52              String url = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, params);
53  
54              Map<String, String> fieldList = new HashMap<String, String>();
55              fieldList.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, paymentDetail.getPaymentGroupId().toString());
56  
57              return getHyperLink(PaymentDetail.class, fieldList, url);
58          }
59  
60          if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_DISBURSEMENT.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroup().getDisbursementNbr())) {
61  
62              Properties params = new Properties();
63              params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD);
64              params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName());
65              params.put(KRADConstants.DOC_FORM_KEY, "88888888");
66              params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true");
67              params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do");
68              params.put(OLEConstants.LOOKUP_READ_ONLY_FIELDS, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER);
69              params.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, UrlFactory.encode(String.valueOf(paymentDetail.getPaymentGroup().getDisbursementNbr())));
70              String url = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, params);
71  
72              Map<String, String> fieldList = new HashMap<String, String>();
73              fieldList.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, paymentDetail.getPaymentGroup().getDisbursementNbr().toString());
74  
75              return getHyperLink(PaymentDetail.class, fieldList, url);
76          }
77  
78          return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
79      }
80  
81  }