View Javadoc
1   /*
2    * Copyright 2010 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.coa.businessobject.inquiry;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  import java.util.Properties;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.ole.coa.businessobject.IndirectCostRecoveryRate;
24  import org.kuali.ole.sys.OLEConstants;
25  import org.kuali.ole.sys.OLEPropertyConstants;
26  import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.ole.sys.service.UniversityDateService;
29  import org.kuali.rice.kns.lookup.HtmlData;
30  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
31  import org.kuali.rice.krad.bo.BusinessObject;
32  import org.kuali.rice.krad.util.KRADConstants;
33  import org.kuali.rice.krad.util.ObjectUtils;
34  import org.kuali.rice.krad.util.UrlFactory;
35  
36  /**
37   * Inquirable class for {@link Account}
38   */
39  public class AccountInquirable extends KfsInquirableImpl {
40  
41      /**
42       * @see org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject,
43       *      java.lang.String, boolean)
44       */
45      @Override
46      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
47          if (OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER.equals(attributeName)) {
48              String baseUrl = KRADConstants.INQUIRY_ACTION;
49  
50              Properties parameters = new Properties();
51              parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD);
52              parameters.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, IndirectCostRecoveryRate.class.getName());
53              parameters.put(OLEConstants.DOC_FORM_KEY, "88888888");
54  
55              Map<String, String> inquiryFields = new HashMap<String, String>();
56              String icrIdentifier = (String) ObjectUtils.getPropertyValue(businessObject, attributeName);
57              if (StringUtils.isBlank(icrIdentifier)) {
58                  return new AnchorHtmlData();
59              }
60              inquiryFields.put(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrIdentifier);
61              parameters.put(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrIdentifier);
62  
63              Integer fiscalYear = SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
64              parameters.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear.toString());
65  
66              return getHyperLink(IndirectCostRecoveryRate.class, inquiryFields, UrlFactory.parameterizeUrl(baseUrl, parameters));
67          }
68  
69          return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
70      }
71  
72  }