001/* 002 * Copyright 2008 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.sys.OLEConstants; 025import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl; 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 PaymentDetailInquirable extends KfsInquirableImpl { 035 036 /** 037 * @see org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject, 038 * java.lang.String, boolean) 039 */ 040 @Override 041 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { 042 PaymentDetail paymentDetail = (PaymentDetail) businessObject; 043 if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_PAYMENT_GROUP.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroupId())) { 044 045 Properties params = new Properties(); 046 params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD); 047 params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PaymentDetail.class.getName()); 048 params.put(KRADConstants.DOC_FORM_KEY, "88888888"); 049 params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true"); 050 params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do"); 051 params.put(OLEConstants.LOOKUP_READ_ONLY_FIELDS, PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID); 052 params.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, UrlFactory.encode(String.valueOf(paymentDetail.getPaymentGroupId()))); 053 String url = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, params); 054 055 Map<String, String> fieldList = new HashMap<String, String>(); 056 fieldList.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, paymentDetail.getPaymentGroupId().toString()); 057 058 return getHyperLink(PaymentDetail.class, fieldList, url); 059 } 060 061 if (PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_NUMBER_OF_PAYMENTS_IN_DISBURSEMENT.equals(attributeName) && ObjectUtils.isNotNull(paymentDetail.getPaymentGroup().getDisbursementNbr())) { 062 063 Properties params = new Properties(); 064 params.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD); 065 params.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PaymentDetail.class.getName()); 066 params.put(KRADConstants.DOC_FORM_KEY, "88888888"); 067 params.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true"); 068 params.put(OLEConstants.BACK_LOCATION, SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY) + "/" + OLEConstants.MAPPING_PORTAL + ".do"); 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}