001/* 002 * Copyright 2010 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.coa.businessobject.inquiry; 017 018import java.util.HashMap; 019import java.util.Map; 020import java.util.Properties; 021 022import org.apache.commons.lang.StringUtils; 023import org.kuali.ole.coa.businessobject.IndirectCostRecoveryRate; 024import org.kuali.ole.sys.OLEConstants; 025import org.kuali.ole.sys.OLEPropertyConstants; 026import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl; 027import org.kuali.ole.sys.context.SpringContext; 028import org.kuali.ole.sys.service.UniversityDateService; 029import org.kuali.rice.kns.lookup.HtmlData; 030import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; 031import org.kuali.rice.krad.bo.BusinessObject; 032import org.kuali.rice.krad.util.KRADConstants; 033import org.kuali.rice.krad.util.ObjectUtils; 034import org.kuali.rice.krad.util.UrlFactory; 035 036/** 037 * Inquirable class for {@link Account} 038 */ 039public class AccountInquirable extends KfsInquirableImpl { 040 041 /** 042 * @see org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject, 043 * java.lang.String, boolean) 044 */ 045 @Override 046 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { 047 if (OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER.equals(attributeName)) { 048 String baseUrl = KRADConstants.INQUIRY_ACTION; 049 050 Properties parameters = new Properties(); 051 parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD); 052 parameters.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, IndirectCostRecoveryRate.class.getName()); 053 parameters.put(OLEConstants.DOC_FORM_KEY, "88888888"); 054 055 Map<String, String> inquiryFields = new HashMap<String, String>(); 056 String icrIdentifier = (String) ObjectUtils.getPropertyValue(businessObject, attributeName); 057 if (StringUtils.isBlank(icrIdentifier)) { 058 return new AnchorHtmlData(); 059 } 060 inquiryFields.put(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrIdentifier); 061 parameters.put(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrIdentifier); 062 063 Integer fiscalYear = SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear(); 064 parameters.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear.toString()); 065 066 return getHyperLink(IndirectCostRecoveryRate.class, inquiryFields, UrlFactory.parameterizeUrl(baseUrl, parameters)); 067 } 068 069 return super.getInquiryUrl(businessObject, attributeName, forceInquiry); 070 } 071 072}