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.sys.KFSConstants;
025 import org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl;
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 PaymentDetailInquirable extends KfsInquirableImpl {
035
036 /**
037 * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.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(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
047 params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PaymentDetail.class.getName());
048 params.put(KNSConstants.DOC_FORM_KEY, "88888888");
049 params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
050 params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
051 params.put(KFSConstants.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(KNSConstants.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(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
065 params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PaymentDetail.class.getName());
066 params.put(KNSConstants.DOC_FORM_KEY, "88888888");
067 params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
068 params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
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 }