org.kuali.rice.kns.lookup
Class DataDictionaryLookupResultsSupportStrategy

java.lang.Object
  extended by org.kuali.rice.kns.lookup.DataDictionaryLookupResultsSupportStrategy
All Implemented Interfaces:
LookupResultsSupportStrategyService

public class DataDictionaryLookupResultsSupportStrategy
extends Object
implements LookupResultsSupportStrategyService

LookupResults support strategy which uses the primary keys and lookupable defined in a business object's data dictionary file to support the multivalue lookup

Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
DataDictionaryLookupResultsSupportStrategy()
           
 
Method Summary
protected  Map<String,String> convertLookupIdToPKFieldMap(String lookupId, Class<? extends BusinessObject> businessObjectClass)
          Converts a lookup id into a PK field map to use to search in a lookupable
protected  String convertPKFieldMapToLookupId(List<String> pkFieldNames, BusinessObject businessObject)
          Converts a Map of PKFields into a String lookup ID
protected  BusinessObjectEntry getBusinessObjectEntry(Class<? extends BusinessObject> boClass)
          Looks up the DataDictionary BusinessObjectEntry for the given class
 DataDictionaryService getDataDictionaryService()
           
protected  Lookupable getLookupableForBusinessObject(Class<? extends BusinessObject> businessObjectClass)
          Retrieves the Lookupable for the given business object class
 String getLookupIdForBusinessObject(BusinessObject businessObject)
          Builds a lookup id for the given business object
protected  List<String> getPrimaryKeyFieldsForBusinessObject(Class<? extends BusinessObject> businessObjectClass)
          Returns the data dictionary defined primary keys for the given BusinessObject
 boolean qualifiesForStrategy(Class<? extends BusinessObject> boClass)
          Determines if both the primary keys and Lookupable are present in the data dictionary definition; if so, the BO qualifies, but if either are missing, it does not
protected  Formatter retrieveBestFormatter(String propertyName, Class<? extends BusinessObject> boClass)
          Like when you're digging through your stuff drawer, you know the one in the kitchen with all the batteries and lint in it, this method goes through the stuff drawer of KNS formatters and attempts to return you a good one
<T extends BusinessObject>
Collection<T>
retrieveSelectedResultBOs(Class<T> boClass, Set<String> lookupIds)
          Uses the Lookupable associated with the given BusinessObject to search for business objects
 void setDataDictionaryService(DataDictionaryService dataDictionaryService)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataDictionaryLookupResultsSupportStrategy

public DataDictionaryLookupResultsSupportStrategy()
Method Detail

getLookupIdForBusinessObject

public String getLookupIdForBusinessObject(BusinessObject businessObject)
Builds a lookup id for the given business object

Specified by:
getLookupIdForBusinessObject in interface LookupResultsSupportStrategyService
Parameters:
businessObject - the lookup to generate an id for
Returns:
the String id
See Also:
LookupResultsSupportStrategyService.getLookupIdForBusinessObject(org.kuali.rice.krad.bo.BusinessObject)

qualifiesForStrategy

public boolean qualifiesForStrategy(Class<? extends BusinessObject> boClass)
Determines if both the primary keys and Lookupable are present in the data dictionary definition; if so, the BO qualifies, but if either are missing, it does not

Specified by:
qualifiesForStrategy in interface LookupResultsSupportStrategyService
Parameters:
boClass - the class to test the determination on
Returns:
true if this strategy supports it, false otherwise
See Also:
LookupResultsSupportStrategyService.qualifiesForStrategy(java.lang.Class)

retrieveSelectedResultBOs

public <T extends BusinessObject> Collection<T> retrieveSelectedResultBOs(Class<T> boClass,
                                                                          Set<String> lookupIds)
                                                               throws Exception
Uses the Lookupable associated with the given BusinessObject to search for business objects

Specified by:
retrieveSelectedResultBOs in interface LookupResultsSupportStrategyService
Parameters:
boClass - the class of the business object to retrieve
Returns:
a Collection of retrieved BusinessObjects
Throws:
Exception - if anything goes wrong...well, just blow up, okay?
See Also:
LookupResultsSupportStrategyService#retrieveSelectedResultBOs(java.lang.String, java.lang.Class, java.lang.String, org.kuali.rice.krad.lookup.LookupResultsService)

getLookupableForBusinessObject

protected Lookupable getLookupableForBusinessObject(Class<? extends BusinessObject> businessObjectClass)
Retrieves the Lookupable for the given business object class

Parameters:
businessObjectClass - the class to find the Lookupable for
Returns:
the Lookupable, or null if nothing could be found

getPrimaryKeyFieldsForBusinessObject

protected List<String> getPrimaryKeyFieldsForBusinessObject(Class<? extends BusinessObject> businessObjectClass)
Returns the data dictionary defined primary keys for the given BusinessObject

Parameters:
businessObjectClass - the business object to get DataDictionary defined primary keys for
Returns:
the List of primary key property names, or null if nothing could be found

convertLookupIdToPKFieldMap

protected Map<String,String> convertLookupIdToPKFieldMap(String lookupId,
                                                         Class<? extends BusinessObject> businessObjectClass)
Converts a lookup id into a PK field map to use to search in a lookupable

Parameters:
lookupId - the id returned by the lookup
businessObjectClass - the class of the business object getting the primary key
Returns:
a Map of field names and values which can be profitably used to search for matching business objects

convertPKFieldMapToLookupId

protected String convertPKFieldMapToLookupId(List<String> pkFieldNames,
                                             BusinessObject businessObject)
Converts a Map of PKFields into a String lookup ID

Parameters:
pkFieldNames - the name of the PK fields, which should be converted to the given lookupId
businessObjectClass - the class of the business object getting the primary key
Returns:
the String lookup id

retrieveBestFormatter

protected Formatter retrieveBestFormatter(String propertyName,
                                          Class<? extends BusinessObject> boClass)
Like when you're digging through your stuff drawer, you know the one in the kitchen with all the batteries and lint in it, this method goes through the stuff drawer of KNS formatters and attempts to return you a good one

Parameters:
propertyName - the name of the property to retrieve
boClass - the class of the BusinessObject the property is on
Returns:
a Formatter, or null if we were unsuccessful in finding

getBusinessObjectEntry

protected BusinessObjectEntry getBusinessObjectEntry(Class<? extends BusinessObject> boClass)
Looks up the DataDictionary BusinessObjectEntry for the given class

Parameters:
boClass - the class of the BusinessObject to find a BusinessObjectEntry for
Returns:
the entry from the data dictionary, or null if nothing was found

getDataDictionaryService

public DataDictionaryService getDataDictionaryService()
Returns:
the dataDictionaryService

setDataDictionaryService

public void setDataDictionaryService(DataDictionaryService dataDictionaryService)
Parameters:
dataDictionaryService - the dataDictionaryService to set


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.