001/* 002 * Copyright 2009 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 */ 016package org.kuali.ole.pdp.businessobject.inquiry; 017 018import java.util.HashMap; 019import java.util.Map; 020import java.util.Properties; 021 022import org.kuali.ole.pdp.PdpPropertyConstants; 023import org.kuali.ole.pdp.businessobject.PaymentDetail; 024import org.kuali.ole.pdp.businessobject.PurchasingPaymentDetail; 025import org.kuali.ole.sys.OLEConstants; 026import org.kuali.ole.sys.context.SpringContext; 027import org.kuali.rice.core.api.config.property.ConfigurationService; 028import org.kuali.rice.kns.lookup.HtmlData; 029import org.kuali.rice.krad.bo.BusinessObject; 030import org.kuali.rice.krad.util.KRADConstants; 031import org.kuali.rice.krad.util.ObjectUtils; 032import org.kuali.rice.krad.util.UrlFactory; 033 034public class PurchasingPaymentDetailInquirable extends PaymentDetailInquirable { 035 036 /** 037 * @see org.kuali.ole.pdp.businessobject.inquiry.PaymentDetailInquirable#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject, java.lang.String, boolean) 038 */ 039 @Override 040 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { 041 PaymentDetail paymentDetail = (PaymentDetail) businessObject; 042 if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_PAYMENT_GROUP.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroupId())) { 043 044 Properties params = new Properties(); 045 params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD); 046 params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName()); 047 params.put(KRADConstants.DOC_FORM_KEY, "88888888"); 048 params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true"); 049 params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do"); 050 params.put(OLEConstants.LOOKUP_READ_ONLY_FIELDS, PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID); 051 params.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, UrlFactory.encode(String.valueOf(paymentDetail.getPaymentGroupId()))); 052 String url = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, params); 053 054 Map<String, String> fieldList = new HashMap<String, String>(); 055 fieldList.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, paymentDetail.getPaymentGroupId().toString()); 056 057 return getHyperLink(PaymentDetail.class, fieldList, url); 058 } 059 060 if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_DISBURSEMENT.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroup().getDisbursementNbr())) { 061 062 Properties params = new Properties(); 063 params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD); 064 params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName()); 065 params.put(KRADConstants.DOC_FORM_KEY, "88888888"); 066 params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true"); 067 params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do"); 068 params.put(OLEConstants.LOOKUP_READ_ONLY_FIELDS, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER); 069 params.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, UrlFactory.encode(String.valueOf(paymentDetail.getPaymentGroup().getDisbursementNbr()))); 070 String url = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, params); 071 072 Map<String, String> fieldList = new HashMap<String, String>(); 073 fieldList.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, paymentDetail.getPaymentGroup().getDisbursementNbr().toString()); 074 075 return getHyperLink(PaymentDetail.class, fieldList, url); 076 } 077 078 return super.getInquiryUrl(businessObject, attributeName, forceInquiry); 079 } 080 081}