Coverage Report - org.kuali.rice.kns.inquiry.KualiInquirableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiInquirableImpl
0%
0/207
0%
0/116
3.129
 
 1  
 /*
 2  
  * Copyright 2005-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.rice.kns.inquiry;
 17  
 
 18  
 import java.security.GeneralSecurityException;
 19  
 import java.util.ArrayList;
 20  
 import java.util.Collection;
 21  
 import java.util.Collections;
 22  
 import java.util.HashMap;
 23  
 import java.util.Iterator;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 import java.util.Properties;
 27  
 
 28  
 import org.apache.commons.collections.BidiMap;
 29  
 import org.apache.commons.collections.bidimap.DualHashBidiMap;
 30  
 import org.apache.commons.lang.StringUtils;
 31  
 import org.kuali.rice.core.service.EncryptionService;
 32  
 import org.kuali.rice.kns.bo.BusinessObject;
 33  
 import org.kuali.rice.kns.bo.BusinessObjectRelationship;
 34  
 import org.kuali.rice.kns.bo.DocumentHeader;
 35  
 import org.kuali.rice.kns.bo.ExternalizableBusinessObject;
 36  
 import org.kuali.rice.kns.datadictionary.AttributeSecurity;
 37  
 import org.kuali.rice.kns.datadictionary.InquirySectionDefinition;
 38  
 import org.kuali.rice.kns.lookup.CollectionIncomplete;
 39  
 import org.kuali.rice.kns.lookup.HtmlData;
 40  
 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
 41  
 import org.kuali.rice.kns.lookup.LookupUtils;
 42  
 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
 43  
 import org.kuali.rice.kns.service.BusinessObjectMetaDataService;
 44  
 import org.kuali.rice.kns.service.BusinessObjectService;
 45  
 import org.kuali.rice.kns.service.DataDictionaryService;
 46  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 47  
 import org.kuali.rice.kns.service.KualiConfigurationService;
 48  
 import org.kuali.rice.kns.service.LookupService;
 49  
 import org.kuali.rice.kns.service.ModuleService;
 50  
 import org.kuali.rice.kns.service.PersistenceStructureService;
 51  
 import org.kuali.rice.kns.util.ExternalizableBusinessObjectUtils;
 52  
 import org.kuali.rice.kns.util.GlobalVariables;
 53  
 import org.kuali.rice.kns.util.InactiveRecordsHidingUtils;
 54  
 import org.kuali.rice.kns.util.KNSConstants;
 55  
 import org.kuali.rice.kns.util.ObjectUtils;
 56  
 import org.kuali.rice.kns.util.UrlFactory;
 57  
 import org.kuali.rice.kns.web.format.Formatter;
 58  
 import org.kuali.rice.kns.web.ui.Section;
 59  
 import org.kuali.rice.kns.web.ui.SectionBridge;
 60  
 
 61  
 /**
 62  
  * Kuali inquirable implementation. Implements methods necessary to retrieve the business object and render the ui.
 63  
  *
 64  
  * NOTE: this class is not thread safe.  When using this class or any subclasses in Spring, make sure that this is not a singleton service, or
 65  
  * serious errors may occur.
 66  
  */
 67  
 public class KualiInquirableImpl implements Inquirable {
 68  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiInquirableImpl.class);
 69  
 
 70  
     protected LookupService lookupService;
 71  
     protected BusinessObjectDictionaryService businessObjectDictionaryService;
 72  
     protected BusinessObjectMetaDataService businessObjectMetaDataService;
 73  
     protected PersistenceStructureService persistenceStructureService;
 74  
     protected DataDictionaryService dataDictionaryService;
 75  
     protected EncryptionService encryptionService;
 76  
     protected KualiConfigurationService kualiConfigurationService;
 77  
     protected static BusinessObjectService businessObjectService;
 78  
 
 79  
     protected Class businessObjectClass;
 80  
 
 81  
     protected Map<String, Boolean> inactiveRecordDisplay;
 82  
 
 83  
     /**
 84  
      * A list that can be used to define classes that are superclasses or superinterfaces of kuali objects where those
 85  
      * objects' inquiry URLs need to use the name of the superclass or superinterface as the business object class attribute
 86  
      * (see {@link RiceConstants#BUSINESS_OBJECT_CLASS_ATTRIBUTE)
 87  
      */
 88  0
     public static List<Class> SUPER_CLASS_TRANSLATOR_LIST = new ArrayList<Class>();
 89  
     public static final String INQUIRY_TITLE_PREFIX = "title.inquiry.url.value.prependtext";
 90  
 
 91  
     /**
 92  
      * Default constructor, initializes services from spring
 93  
      */
 94  0
     public KualiInquirableImpl() {
 95  0
         inactiveRecordDisplay = new HashMap<String, Boolean>();
 96  0
     }
 97  
 
 98  
     /**
 99  
      * Return a business object by searching with map, the map keys should be a property name of the business object, with the map
 100  
      * value as the value to search for.
 101  
      */
 102  
     public BusinessObject getBusinessObject(Map fieldValues) {
 103  0
         if (getBusinessObjectClass() == null) {
 104  0
             LOG.error("Business object class not set in inquirable.");
 105  0
             throw new RuntimeException("Business object class not set in inquirable.");
 106  
         }
 107  
 
 108  0
         CollectionIncomplete searchResults = null;
 109  0
                 ModuleService moduleService =
 110  
                         KNSServiceLocator.getKualiModuleService().getResponsibleModuleService(getBusinessObjectClass());
 111  0
                 if (moduleService != null && moduleService.isExternalizable(getBusinessObjectClass())) {
 112  0
                         BusinessObject bo = moduleService.getExternalizableBusinessObject(getBusinessObjectClass(), fieldValues);
 113  0
                         if(bo!=null) {
 114  0
                                 ArrayList list = new ArrayList( 1 );
 115  0
                                 list.add( bo );
 116  0
                                 searchResults = new CollectionIncomplete(list, 1L);
 117  
                         }
 118  0
                 } else {
 119  
                         // CHECK THIS: If this is to get a single BO, why using the lookup service?
 120  0
                         searchResults = (CollectionIncomplete) getLookupService().findCollectionBySearch(getBusinessObjectClass(), fieldValues);
 121  
                 }
 122  0
         BusinessObject foundObject = null;
 123  0
         if (searchResults != null && searchResults.size() > 0) {
 124  0
             foundObject = (BusinessObject) searchResults.get(0);
 125  
         }
 126  0
         return foundObject;
 127  
     }
 128  
 
 129  
 
 130  
     /**
 131  
      * Objects extending KualiInquirableBase must specify the Section objects used to display the inquiry result.
 132  
      */
 133  
     public List<Section> getSections(BusinessObject bo) {
 134  
 
 135  0
         List<Section> sections = new ArrayList<Section>();
 136  0
         if (getBusinessObjectClass() == null) {
 137  0
             LOG.error("Business object class not set in inquirable.");
 138  0
             throw new RuntimeException("Business object class not set in inquirable.");
 139  
         }
 140  
 
 141  0
         InquiryRestrictions inquiryRestrictions = KNSServiceLocator.getBusinessObjectAuthorizationService().getInquiryRestrictions(bo, GlobalVariables.getUserSession().getPerson());
 142  
 
 143  0
         Collection<InquirySectionDefinition> inquirySections = getBusinessObjectDictionaryService().getInquirySections(getBusinessObjectClass());
 144  0
         for (Iterator<InquirySectionDefinition> iter = inquirySections.iterator(); iter.hasNext();) {
 145  0
             InquirySectionDefinition inquirySection = iter.next();
 146  0
             if (!inquiryRestrictions.isHiddenSectionId(inquirySection.getId())) {
 147  0
                     Section section = SectionBridge.toSection(this, inquirySection, bo, inquiryRestrictions);
 148  0
                     sections.add(section);
 149  
             }
 150  0
         }
 151  
 
 152  0
         return sections;
 153  
     }
 154  
 
 155  
     /**
 156  
      * Helper method to build an inquiry url for a result field.
 157  
      *
 158  
      * @param bo the business object instance to build the urls for
 159  
      * @param propertyName the property which links to an inquirable
 160  
      * @return String url to inquiry
 161  
      */
 162  
     public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
 163  0
         Properties parameters = new Properties();
 164  0
         AnchorHtmlData hRef = new AnchorHtmlData(KNSConstants.EMPTY_STRING, KNSConstants.EMPTY_STRING);
 165  0
         parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, "start");
 166  
 
 167  0
         Class inquiryBusinessObjectClass = null;
 168  0
         String attributeRefName = "";
 169  0
         boolean isPkReference = false;
 170  
 
 171  0
         boolean doesNestedReferenceHaveOwnPrimitiveReference = false;
 172  0
         BusinessObject nestedBusinessObject = null;
 173  
 
 174  0
         if (attributeName.equals(getBusinessObjectDictionaryService().getTitleAttribute(businessObject.getClass()))) {
 175  0
             inquiryBusinessObjectClass = businessObject.getClass();
 176  0
             isPkReference = true;
 177  
         }
 178  
         else {
 179  0
             if (ObjectUtils.isNestedAttribute(attributeName)) {
 180  
                 // if we have a reference object, we should determine if we should either provide an inquiry link to
 181  
                 // the reference object itself, or some other nested primitive.
 182  
 
 183  
                 // for example, if the attribute is "referenceObject.someAttribute", and there is no primitive reference for
 184  
                 // "someAttribute", then an inquiry link is provided to the "referenceObject".  If it does have a primitive reference, then
 185  
                 // the inquiry link is directed towards it instead
 186  0
                 String nestedReferenceName = ObjectUtils.getNestedAttributePrefix(attributeName);
 187  0
                 Object nestedReferenceObject = ObjectUtils.getNestedValue(businessObject, nestedReferenceName);
 188  
 
 189  0
                 if (ObjectUtils.isNotNull(nestedReferenceObject) && nestedReferenceObject instanceof BusinessObject) {
 190  0
                     nestedBusinessObject = (BusinessObject) nestedReferenceObject;
 191  0
                     String nestedAttributePrimitive = ObjectUtils.getNestedAttributePrimitive(attributeName);
 192  
 
 193  0
                     if (nestedAttributePrimitive.equals(getBusinessObjectDictionaryService().getTitleAttribute(nestedBusinessObject.getClass()))) {
 194  
                             // we are going to inquiry the record that contains the attribute we're rendering an inquiry URL for
 195  0
                             inquiryBusinessObjectClass = nestedBusinessObject.getClass();
 196  
                         // I know it's already set to false, just to show how this variable is set
 197  0
                         doesNestedReferenceHaveOwnPrimitiveReference = false;
 198  
                     }
 199  
                     else {
 200  0
                             Map primitiveReference = LookupUtils.getPrimitiveReference(nestedBusinessObject, nestedAttributePrimitive);
 201  0
                             if (primitiveReference != null && !primitiveReference.isEmpty()) {
 202  0
                                 attributeRefName = (String) primitiveReference.keySet().iterator().next();
 203  0
                                 inquiryBusinessObjectClass = (Class) primitiveReference.get(attributeRefName);
 204  0
                                 doesNestedReferenceHaveOwnPrimitiveReference = true;
 205  
                             }
 206  
                             else {
 207  
                                     // we are going to inquiry the record that contains the attribute we're rendering an inquiry URL for
 208  0
                                         inquiryBusinessObjectClass = nestedBusinessObject.getClass();
 209  
                                 // I know it's already set to false, just to show how this variable is set
 210  0
                                 doesNestedReferenceHaveOwnPrimitiveReference = false;
 211  
                             }
 212  
                     }
 213  
                 }
 214  0
             }
 215  
             else {
 216  0
                 Map primitiveReference = LookupUtils.getPrimitiveReference(businessObject, attributeName);
 217  0
                 if (primitiveReference != null && !primitiveReference.isEmpty()) {
 218  0
                     attributeRefName = (String) primitiveReference.keySet().iterator().next();
 219  0
                     inquiryBusinessObjectClass = (Class) primitiveReference.get(attributeRefName);
 220  
                 }
 221  
             }
 222  
         }
 223  
 
 224  0
         if (inquiryBusinessObjectClass != null && DocumentHeader.class.isAssignableFrom(inquiryBusinessObjectClass)) {
 225  0
             String documentNumber = (String) ObjectUtils.getPropertyValue(businessObject, attributeName);
 226  0
             if (!StringUtils.isBlank(documentNumber)) {
 227  
                 // if NullPointerException on the following line, maybe the Spring bean wasn't injected w/ KualiConfigurationException, or if
 228  
                 // instances of a sub-class of this class are not Spring created, then override getKualiConfigurationService() in the subclass
 229  
                 // to return the configuration service from a Spring service locator (or set it).
 230  0
                 hRef.setHref(getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) + KNSConstants.DOCHANDLER_DO_URL + documentNumber + KNSConstants.DOCHANDLER_URL_CHUNK);
 231  
             }
 232  0
             return hRef;
 233  
         }
 234  
 
 235  0
         if (inquiryBusinessObjectClass == null || getBusinessObjectDictionaryService().isInquirable(inquiryBusinessObjectClass) == null || !getBusinessObjectDictionaryService().isInquirable(inquiryBusinessObjectClass).booleanValue()) {
 236  0
             return hRef;
 237  
         }
 238  
 
 239  0
         synchronized (SUPER_CLASS_TRANSLATOR_LIST) {
 240  0
             for (Class clazz : SUPER_CLASS_TRANSLATOR_LIST) {
 241  0
                 if (clazz.isAssignableFrom(inquiryBusinessObjectClass)) {
 242  0
                     inquiryBusinessObjectClass = clazz;
 243  0
                     break;
 244  
                 }
 245  
             }
 246  0
         }
 247  
 
 248  0
         if (!inquiryBusinessObjectClass.isInterface() && ExternalizableBusinessObject.class.isAssignableFrom(inquiryBusinessObjectClass)) {
 249  0
                 inquiryBusinessObjectClass = ExternalizableBusinessObjectUtils.determineExternalizableBusinessObjectSubInterface(inquiryBusinessObjectClass);
 250  
         }
 251  
 
 252  0
         parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, inquiryBusinessObjectClass.getName());
 253  
 
 254  
 
 255  
         // listPrimaryKeyFieldNames returns an unmodifiable list.  So a copy is necessary.
 256  0
         List<String> keys = new ArrayList<String>(getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(inquiryBusinessObjectClass));
 257  
 
 258  0
         if (keys == null) {
 259  0
                 keys = Collections.emptyList();
 260  
         }
 261  
 
 262  0
         BusinessObjectRelationship businessObjectRelationship = null;
 263  
 
 264  0
         if(attributeRefName != null && !"".equals(attributeRefName)){
 265  0
                 businessObjectRelationship =
 266  
                             getBusinessObjectMetaDataService().getBusinessObjectRelationship(
 267  
                                             businessObject, attributeRefName);
 268  
 
 269  0
                     if (businessObjectRelationship != null && businessObjectRelationship.getParentToChildReferences() != null) {
 270  0
                             for (String targetNamePrimaryKey : businessObjectRelationship.getParentToChildReferences().values()) {
 271  0
                                     keys.add(targetNamePrimaryKey);
 272  
                             }
 273  
                     }
 274  
         }
 275  
         // build key value url parameters used to retrieve the business object
 276  0
         String keyName = null;
 277  0
         String keyConversion = null;
 278  0
         Map<String, String> fieldList = new HashMap<String,String>();
 279  0
         for (Iterator iter = keys.iterator(); iter.hasNext();) {
 280  0
             keyName = (String) iter.next();
 281  0
             keyConversion = keyName;
 282  0
             if (ObjectUtils.isNestedAttribute(attributeName)) {
 283  0
                 if (doesNestedReferenceHaveOwnPrimitiveReference) {
 284  0
                     String nestedAttributePrefix = ObjectUtils.getNestedAttributePrefix(attributeName);
 285  
                     //String foreignKeyFieldName = getBusinessObjectMetaDataService().getForeignKeyFieldName(
 286  
                     //        inquiryBusinessObjectClass.getClass(), attributeRefName, keyName);
 287  
 
 288  0
                     String foreignKeyFieldName = getBusinessObjectMetaDataService().getForeignKeyFieldName(
 289  
                                                                                     nestedBusinessObject.getClass(), attributeRefName, keyName);
 290  0
                     keyConversion = nestedAttributePrefix + "." + foreignKeyFieldName;
 291  0
                 }
 292  
                 else {
 293  0
                     keyConversion = ObjectUtils.getNestedAttributePrefix(attributeName) + "." + keyName;
 294  
                 }
 295  
             }
 296  
             else {
 297  0
                 if (isPkReference) {
 298  0
                     keyConversion = keyName;
 299  
                 }
 300  0
                 else if (businessObjectRelationship != null) {
 301  
                         //Using BusinessObjectMetaDataService instead of PersistenceStructureService
 302  
                         //since otherwise, relationship information from datadictionary is not used at all
 303  
                         //Also, BOMDS.getBusinessObjectRelationship uses PersistenceStructureService,
 304  
                         //so both datadictionary and the persistance layer get covered
 305  
                         /*
 306  
                         BusinessObjectRelationship businessObjectRelationship =
 307  
                                 getBusinessObjectMetaDataService().getBusinessObjectRelationship(
 308  
                                                 businessObject, attributeRefName);
 309  
                                                 */
 310  0
                         BidiMap bidiMap = new DualHashBidiMap(businessObjectRelationship.getParentToChildReferences());
 311  0
                         keyConversion = (String)bidiMap.getKey(keyName);
 312  
                     //keyConversion = getPersistenceStructureService().getForeignKeyFieldName(businessObject.getClass(), attributeRefName, keyName);
 313  
                 }
 314  
             }
 315  0
             Object keyValue = null;
 316  0
             if (keyConversion != null) {
 317  0
                 keyValue = ObjectUtils.getPropertyValue(businessObject, keyConversion);
 318  
             }
 319  
 
 320  0
             if (keyValue == null) {
 321  0
                 keyValue = "";
 322  0
             } else if (keyValue instanceof java.sql.Date) { //format the date for passing in url
 323  0
                 if (Formatter.findFormatter(keyValue.getClass()) != null) {
 324  0
                     Formatter formatter = Formatter.getFormatter(keyValue.getClass());
 325  0
                     keyValue = (String) formatter.format(keyValue);
 326  0
                 }
 327  
             } else {
 328  0
                 keyValue = keyValue.toString();
 329  
             }
 330  
 
 331  
             // Encrypt value if it is a field that has restriction that prevents a value from being shown to user,
 332  
             // because we don't want the browser history to store the restricted attribute's value in the URL
 333  0
             AttributeSecurity attributeSecurity = KNSServiceLocator.getDataDictionaryService().getAttributeSecurity(businessObject.getClass().getName(), keyName);
 334  0
             if(attributeSecurity != null && attributeSecurity.hasRestrictionThatRemovesValueFromUI()){
 335  
                     try {
 336  0
                     keyValue = getEncryptionService().encrypt(keyValue);
 337  
                 }
 338  0
                 catch (GeneralSecurityException e) {
 339  0
                     LOG.error("Exception while trying to encrypted value for inquiry framework.", e);
 340  0
                     throw new RuntimeException(e);
 341  0
                 }
 342  
             }
 343  
 
 344  0
             parameters.put(keyName, keyValue);
 345  0
             fieldList.put(keyName, keyValue.toString());
 346  0
         }
 347  
 
 348  0
         return getHyperLink(inquiryBusinessObjectClass, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters));
 349  
     }
 350  
 
 351  
     protected AnchorHtmlData getHyperLink(Class inquiryClass, Map<String,String> fieldList, String inquiryUrl){
 352  0
             AnchorHtmlData a = new AnchorHtmlData(inquiryUrl, KNSConstants.EMPTY_STRING);
 353  0
             a.setTitle(HtmlData.getTitleText(this.createTitleText(inquiryClass), inquiryClass, fieldList));
 354  0
             return a;
 355  
     }
 356  
     
 357  
     /**
 358  
      * creates the title text for a given BO
 359  
      * 
 360  
      * @param boClass the BO class
 361  
      * @return the title text
 362  
      */
 363  
     protected String createTitleText(Class<? extends BusinessObject> boClass) {
 364  0
             String titleText = "";
 365  
             
 366  0
             final String titlePrefixProp = getKualiConfigurationService().getPropertyString(
 367  
                 INQUIRY_TITLE_PREFIX);
 368  0
             if (StringUtils.isNotBlank(titlePrefixProp)) {
 369  0
                     titleText += titlePrefixProp + " ";
 370  
             }
 371  
             
 372  0
             final String objectLabel = getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(boClass.getName()).getObjectLabel();
 373  0
             if (StringUtils.isNotBlank(objectLabel)) {
 374  0
                     titleText += objectLabel + " ";
 375  
             }
 376  
             
 377  0
             return titleText;
 378  
     }
 379  
 
 380  
     public void addAdditionalSections(List columns, BusinessObject bo) {
 381  0
     }
 382  
 
 383  
     /**
 384  
      * @see org.kuali.rice.kns.inquiry.Inquirable#getHtmlMenuBar()
 385  
      */
 386  
     public String getHtmlMenuBar() {
 387  
         // TODO: replace with inquiry menu bar
 388  0
         return getBusinessObjectDictionaryService().getLookupMenuBar(getBusinessObjectClass());
 389  
     }
 390  
 
 391  
     /**
 392  
      * @see org.kuali.rice.kns.inquiry.Inquirable#getTitle()
 393  
      */
 394  
     public String getTitle() {
 395  0
         return getBusinessObjectDictionaryService().getInquiryTitle(getBusinessObjectClass());
 396  
     }
 397  
 
 398  
     /**
 399  
      * @return Returns the businessObjectClass.
 400  
      */
 401  
     public Class getBusinessObjectClass() {
 402  0
         return businessObjectClass;
 403  
     }
 404  
 
 405  
     /**
 406  
      * @param businessObjectClass The businessObjectClass to set.
 407  
      */
 408  
     public void setBusinessObjectClass(Class businessObjectClass) {
 409  0
         this.businessObjectClass = businessObjectClass;
 410  0
     }
 411  
 
 412  
     /**
 413  
      * @see org.kuali.rice.kns.inquiry.Inquirable#getInactiveRecordDisplay()
 414  
      */
 415  
     public Map<String, Boolean> getInactiveRecordDisplay() {
 416  0
         return inactiveRecordDisplay;
 417  
 }
 418  
     /**
 419  
      * @see org.kuali.rice.kns.inquiry.Inquirable#getShowInactiveRecords(java.lang.String)
 420  
      */
 421  
     public boolean getShowInactiveRecords(String collectionName) {
 422  0
         return InactiveRecordsHidingUtils.getShowInactiveRecords(inactiveRecordDisplay, collectionName);
 423  
     }
 424  
 
 425  
     /**
 426  
      * @see org.kuali.rice.kns.inquiry.Inquirable#setShowInactiveRecords(java.lang.String, boolean)
 427  
      */
 428  
     public void setShowInactiveRecords(String collectionName, boolean showInactive) {
 429  0
         InactiveRecordsHidingUtils.setShowInactiveRecords(inactiveRecordDisplay, collectionName, showInactive);
 430  0
     }
 431  
 
 432  
     public LookupService getLookupService() {
 433  0
         if ( lookupService == null ) {
 434  0
             lookupService = KNSServiceLocator.getLookupService();
 435  
         }
 436  0
         return lookupService;
 437  
     }
 438  
 
 439  
     public void setLookupService(LookupService lookupService) {
 440  0
         this.lookupService = lookupService;
 441  0
     }
 442  
 
 443  
     public BusinessObjectDictionaryService getBusinessObjectDictionaryService() {
 444  0
         if ( businessObjectDictionaryService == null ) {
 445  0
             businessObjectDictionaryService = KNSServiceLocator.getBusinessObjectDictionaryService();
 446  
         }
 447  0
         return businessObjectDictionaryService;
 448  
     }
 449  
 
 450  
     public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService) {
 451  0
         this.businessObjectDictionaryService = businessObjectDictionaryService;
 452  0
     }
 453  
 
 454  
     public PersistenceStructureService getPersistenceStructureService() {
 455  0
         if ( persistenceStructureService == null ) {
 456  0
             persistenceStructureService = KNSServiceLocator.getPersistenceStructureService();
 457  
         }
 458  0
         return this.persistenceStructureService;
 459  
     }
 460  
 
 461  
     public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) {
 462  0
         this.persistenceStructureService = persistenceStructureService;
 463  0
     }
 464  
 
 465  
     public DataDictionaryService getDataDictionaryService() {
 466  0
         if ( dataDictionaryService == null ) {
 467  0
             dataDictionaryService = KNSServiceLocator.getDataDictionaryService();
 468  
         }
 469  0
         return this.dataDictionaryService;
 470  
     }
 471  
 
 472  
     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
 473  0
         this.dataDictionaryService = dataDictionaryService;
 474  0
     }
 475  
 
 476  
     public EncryptionService getEncryptionService() {
 477  0
         if ( encryptionService == null ) {
 478  0
             encryptionService = KNSServiceLocator.getEncryptionService();
 479  
         }
 480  0
         return this.encryptionService;
 481  
     }
 482  
 
 483  
     public void setEncryptionService(EncryptionService encryptionService) {
 484  0
         this.encryptionService = encryptionService;
 485  0
     }
 486  
 
 487  
     /**
 488  
      * Retrieves the {@link KualiConfigurationService}.  In the event that instances of this class are not created as Spring beans,
 489  
      * override this method to return an instance from the service locator.
 490  
      *
 491  
      * @return
 492  
      */
 493  
     protected KualiConfigurationService getKualiConfigurationService() {
 494  0
                 if (kualiConfigurationService == null) {
 495  0
                         kualiConfigurationService = KNSServiceLocator.getKualiConfigurationService();
 496  
                 }
 497  0
         return this.kualiConfigurationService;
 498  
     }
 499  
 
 500  
     public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
 501  0
         this.kualiConfigurationService = kualiConfigurationService;
 502  0
     }
 503  
 
 504  
         public BusinessObjectMetaDataService getBusinessObjectMetaDataService() {
 505  0
                 if (businessObjectMetaDataService == null) {
 506  0
                         businessObjectMetaDataService = KNSServiceLocator.getBusinessObjectMetaDataService();
 507  
                 }
 508  0
                 return this.businessObjectMetaDataService;
 509  
         }
 510  
 
 511  
         public void setBusinessObjectMetaDataService(
 512  
                         BusinessObjectMetaDataService businessObjectMetaDataService) {
 513  0
                 this.businessObjectMetaDataService = businessObjectMetaDataService;
 514  0
         }
 515  
 
 516  
         public BusinessObjectService getBusinessObjectService() {
 517  0
                 if (businessObjectService == null ) {
 518  0
                         businessObjectService = KNSServiceLocator.getBusinessObjectService();
 519  
                 }
 520  0
                 return businessObjectService;
 521  
         }
 522  
 
 523  
     protected AnchorHtmlData getInquiryUrlForPrimaryKeys(
 524  
                     Class clazz, Object businessObject, List<String> primaryKeys, String displayText){
 525  0
             if(businessObject==null)
 526  0
                     return new AnchorHtmlData(KNSConstants.EMPTY_STRING, KNSConstants.EMPTY_STRING);
 527  
 
 528  0
         Properties parameters = new Properties();
 529  0
         parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.START_METHOD);
 530  0
         parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, clazz.getName());
 531  
 
 532  
         String titleAttributeValue;
 533  0
         Map<String, String> fieldList = new HashMap<String, String>();
 534  0
         for(String primaryKey: primaryKeys){
 535  0
                 titleAttributeValue = (String)ObjectUtils.getPropertyValue(businessObject, primaryKey);
 536  0
             parameters.put(primaryKey, titleAttributeValue);
 537  0
             fieldList.put(primaryKey, titleAttributeValue);
 538  
         }
 539  0
         if(StringUtils.isEmpty(displayText))
 540  0
                 return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters));
 541  
         else
 542  0
                 return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters), displayText);
 543  
     }
 544  
 
 545  
 
 546  
     protected AnchorHtmlData getHyperLink(Class inquiryClass, Map<String,String> fieldList, String inquiryUrl, String displayText){
 547  0
             AnchorHtmlData a = new AnchorHtmlData(inquiryUrl, KNSConstants.EMPTY_STRING, displayText);
 548  0
             a.setTitle(AnchorHtmlData.getTitleText(
 549  
                 getKualiConfigurationService().getPropertyString(
 550  
                         INQUIRY_TITLE_PREFIX) + " " +
 551  
                         getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(inquiryClass.getName()).getObjectLabel()+
 552  
                         " ", inquiryClass, fieldList));
 553  0
             return a;
 554  
     }
 555  
 
 556  
 
 557  
 }