001/* 002 * Copyright 2007 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 */ 016package org.kuali.ole.sys.businessobject.inquiry; 017 018 019 020import org.apache.commons.beanutils.PropertyUtils; 021import org.apache.commons.lang.StringUtils; 022import org.kuali.ole.sys.OLEConstants; 023import org.kuali.rice.kns.inquiry.KualiInquirableImpl; 024import org.kuali.rice.kns.lookup.HtmlData; 025import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; 026import org.kuali.rice.krad.bo.BusinessObject; 027import org.kuali.rice.krad.util.ObjectUtils; 028 029/** 030 * Base OLE Inquirable Implementation 031 */ 032public class KfsInquirableImpl extends KualiInquirableImpl { 033 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KfsInquirableImpl.class); 034 /** 035 * Helper method to build an inquiry url for a result field. Special implementation to not build an inquiry link if the value is 036 * all dashes. 037 * 038 * @param bo the business object instance to build the urls for 039 * @param propertyName the property which links to an inquirable 040 * @return String url to inquiry 041 */ 042 @Override 043 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { 044 try { 045 if (PropertyUtils.isReadable(businessObject, attributeName)) { 046 Object objFieldValue = ObjectUtils.getPropertyValue(businessObject, attributeName); 047 String fieldValue = objFieldValue == null ? OLEConstants.EMPTY_STRING : objFieldValue.toString(); 048 049 if (StringUtils.containsOnly(fieldValue, OLEConstants.DASH)) { 050 return new AnchorHtmlData(); 051 } 052 } 053 054 return super.getInquiryUrl(businessObject, attributeName, forceInquiry); 055 } catch ( Exception ex ) { 056 LOG.error( "Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName ); 057 LOG.debug( "Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName, ex ); 058 return new AnchorHtmlData(); 059 } 060 } 061 062}