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.PaymentDetail;
024    import org.kuali.kfs.pdp.businessobject.PurchasingPaymentDetail;
025    import org.kuali.kfs.sys.KFSConstants;
026    import org.kuali.kfs.sys.context.SpringContext;
027    import org.kuali.rice.kns.bo.BusinessObject;
028    import org.kuali.rice.kns.lookup.HtmlData;
029    import org.kuali.rice.kns.service.KualiConfigurationService;
030    import org.kuali.rice.kns.util.KNSConstants;
031    import org.kuali.rice.kns.util.ObjectUtils;
032    import org.kuali.rice.kns.util.UrlFactory;
033    
034    public class PurchasingPaymentDetailInquirable extends PaymentDetailInquirable {
035    
036        /**
037         * @see org.kuali.kfs.pdp.businessobject.inquiry.PaymentDetailInquirable#getInquiryUrl(org.kuali.rice.kns.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(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
046                params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName());
047                params.put(KNSConstants.DOC_FORM_KEY, "88888888");
048                params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
049                params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
050                params.put(KFSConstants.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(KNSConstants.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(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
064                params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName());
065                params.put(KNSConstants.DOC_FORM_KEY, "88888888");
066                params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
067                params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
068                params.put(KFSConstants.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(KNSConstants.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    }