View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.sys.businessobject.inquiry;
17  
18  
19  
20  import org.apache.commons.beanutils.PropertyUtils;
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
24  import org.kuali.rice.kns.lookup.HtmlData;
25  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
26  import org.kuali.rice.krad.bo.BusinessObject;
27  import org.kuali.rice.krad.util.ObjectUtils;
28  
29  /**
30   * Base OLE Inquirable Implementation
31   */
32  public class KfsInquirableImpl extends KualiInquirableImpl {
33      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KfsInquirableImpl.class);
34      /**
35       * Helper method to build an inquiry url for a result field. Special implementation to not build an inquiry link if the value is
36       * all dashes.
37       *
38       * @param bo the business object instance to build the urls for
39       * @param propertyName the property which links to an inquirable
40       * @return String url to inquiry
41       */
42      @Override
43      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
44          try {
45          if (PropertyUtils.isReadable(businessObject, attributeName)) {
46              Object objFieldValue = ObjectUtils.getPropertyValue(businessObject, attributeName);
47              String fieldValue = objFieldValue == null ? OLEConstants.EMPTY_STRING : objFieldValue.toString();
48  
49              if (StringUtils.containsOnly(fieldValue, OLEConstants.DASH)) {
50                  return new AnchorHtmlData();
51              }
52          }
53  
54          return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
55          } catch ( Exception ex ) {
56              LOG.error( "Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName );
57              LOG.debug( "Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName, ex );
58              return new AnchorHtmlData();
59          }
60      }
61  
62  }