org.kuali.rice.krad.lookup
Class LookupUtils

java.lang.Object
  extended by org.kuali.rice.krad.lookup.LookupUtils

public class LookupUtils
extends Object

Provides static utility methods for use within the lookup framework

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

Constructor Summary
LookupUtils()
           
 
Method Summary
static void applySearchResultsLimit(Class businessObjectClass, Criteria criteria)
          Applies the search results limit to the search criteria for this BO (JPA)
static void applySearchResultsLimit(Class businessObjectClass, org.apache.ojb.broker.query.Criteria criteria, DatabasePlatform platform)
          This method applies the search results limit to the search criteria for this BO
static Map<String,String> forceUppercase(Class<?> dataObjectClass, Map<String,String> fieldValues)
          Uses the DataDictionary to determine whether to force uppercase the values, and if it should, then it does the uppercase, and returns the upper-cased Map of fieldname/fieldValue pairs.
static String forceUppercase(Class<?> dataObjectClass, String fieldName, String fieldValue)
          Uses the DataDictionary to determine whether to force uppercase the value, and if it should, then it does the uppercase, and returns the upper-cased value.
static Timestamp getActiveDateTimestampForCriteria(Map searchValues)
          Determines what Timestamp should be used for active queries on effective dated records.
static Integer getApplicationSearchResultsLimit()
          Retrieves the default application search limit configured through a system parameter
static Class<? extends ExternalizableBusinessObject> getExternalizableBusinessObjectClass(Class<?> boClass, String propertyName)
          Given an property on the main BO class, return the defined type of the ExternalizableBusinessObject.
static Map<String,String> getExternalizableBusinessObjectFieldValues(String eboPropertyName, Map<String,String> fieldValues)
          Return the EBO fieldValue entries explicitly for the given eboPropertyName.
static List<String> getExternalizableBusinessObjectProperties(Class<?> boClass, Map<String,String> fieldValues)
          Get the complete list of all properties referenced in the fieldValues that are ExternalizableBusinessObjects.
static Integer getSearchResultsLimit(Class dataObjectClass)
          Parses and returns the lookup result set limit, checking first for the limit for the class being looked up, and then the global application limit if there isn't a limit specific to this data object class
static boolean hasExternalBusinessObjectProperty(Class<?> boClass, Map<String,String> fieldValues)
          Checks whether any of the fieldValues being passed refer to a property within an ExternalizableBusinessObject.
static boolean isExternalBusinessObjectProperty(Object sampleBo, String propertyName)
          Check whether the given property represents a property within an EBO starting with the sampleBo object given.
static Map<String,String> preprocessDateFields(Map<String,String> searchCriteria)
          Changes from/to dates into the range operators the lookupable dao expects ("..",">" etc) this method modifies the passed in map and returns a list containing only the modified fields
static Map<String,String> removeExternalizableBusinessObjectFieldValues(Class<?> boClass, Map<String,String> fieldValues)
          Returns a map stripped of any properties which refer to ExternalizableBusinessObjects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookupUtils

public LookupUtils()
Method Detail

forceUppercase

public static String forceUppercase(Class<?> dataObjectClass,
                                    String fieldName,
                                    String fieldValue)
Uses the DataDictionary to determine whether to force uppercase the value, and if it should, then it does the uppercase, and returns the upper-cased value.

Parameters:
dataObjectClass - Parent DO class that the fieldName is a member of.
fieldName - Name of the field to be forced to uppercase.
fieldValue - Value of the field that may be uppercased.
Returns:
The correctly uppercased fieldValue if it should be uppercased, otherwise fieldValue is returned unchanged.

forceUppercase

public static Map<String,String> forceUppercase(Class<?> dataObjectClass,
                                                Map<String,String> fieldValues)
Uses the DataDictionary to determine whether to force uppercase the values, and if it should, then it does the uppercase, and returns the upper-cased Map of fieldname/fieldValue pairs.

Parameters:
dataObjectClass - Parent DO class that the fieldName is a member of.
fieldValues - A Map where the key is the fieldName and the value is the fieldValue.
Returns:
The same Map is returned, with the appropriate values uppercased (if any).

getSearchResultsLimit

public static Integer getSearchResultsLimit(Class dataObjectClass)
Parses and returns the lookup result set limit, checking first for the limit for the class being looked up, and then the global application limit if there isn't a limit specific to this data object class

Parameters:
dataObjectClass - - class to get limit for

getApplicationSearchResultsLimit

public static Integer getApplicationSearchResultsLimit()
Retrieves the default application search limit configured through a system parameter


applySearchResultsLimit

public static void applySearchResultsLimit(Class businessObjectClass,
                                           org.apache.ojb.broker.query.Criteria criteria,
                                           DatabasePlatform platform)
This method applies the search results limit to the search criteria for this BO

Parameters:
businessObjectClass - BO class to search on / get limit for
criteria - search criteria
platform - database platform

applySearchResultsLimit

public static void applySearchResultsLimit(Class businessObjectClass,
                                           Criteria criteria)
Applies the search results limit to the search criteria for this BO (JPA)

Parameters:
businessObjectClass - BO class to search on / get limit for
criteria - search criteria

getActiveDateTimestampForCriteria

public static Timestamp getActiveDateTimestampForCriteria(Map searchValues)
Determines what Timestamp should be used for active queries on effective dated records. Determination made as follows:

Parameters:
searchValues - - Map containing search key/value pairs
Returns:
Timestamp to be used for active criteria

preprocessDateFields

public static Map<String,String> preprocessDateFields(Map<String,String> searchCriteria)
Changes from/to dates into the range operators the lookupable dao expects ("..",">" etc) this method modifies the passed in map and returns a list containing only the modified fields

Parameters:
searchCriteria - - map of criteria currently set for which the date criteria will be adjusted

hasExternalBusinessObjectProperty

public static boolean hasExternalBusinessObjectProperty(Class<?> boClass,
                                                        Map<String,String> fieldValues)
                                                 throws IllegalAccessException,
                                                        InstantiationException
Checks whether any of the fieldValues being passed refer to a property within an ExternalizableBusinessObject.

Throws:
IllegalAccessException
InstantiationException

isExternalBusinessObjectProperty

public static boolean isExternalBusinessObjectProperty(Object sampleBo,
                                                       String propertyName)
Check whether the given property represents a property within an EBO starting with the sampleBo object given. This is used to determine if a criteria needs to be applied to the EBO first, before sending to the normal lookup DAO.


removeExternalizableBusinessObjectFieldValues

public static Map<String,String> removeExternalizableBusinessObjectFieldValues(Class<?> boClass,
                                                                               Map<String,String> fieldValues)
                                                                        throws IllegalAccessException,
                                                                               InstantiationException
Returns a map stripped of any properties which refer to ExternalizableBusinessObjects. These values may not be passed into the lookup service, since the objects they refer to are not in the local database.

Throws:
IllegalAccessException
InstantiationException

getExternalizableBusinessObjectFieldValues

public static Map<String,String> getExternalizableBusinessObjectFieldValues(String eboPropertyName,
                                                                            Map<String,String> fieldValues)
Return the EBO fieldValue entries explicitly for the given eboPropertyName. (I.e., any properties with the given property name as a prefix.


getExternalizableBusinessObjectProperties

public static List<String> getExternalizableBusinessObjectProperties(Class<?> boClass,
                                                                     Map<String,String> fieldValues)
                                                              throws IllegalAccessException,
                                                                     InstantiationException
Get the complete list of all properties referenced in the fieldValues that are ExternalizableBusinessObjects. This is a list of the EBO object references themselves, not of the properties within them.

Throws:
IllegalAccessException
InstantiationException

getExternalizableBusinessObjectClass

public static Class<? extends ExternalizableBusinessObject> getExternalizableBusinessObjectClass(Class<?> boClass,
                                                                                                 String propertyName)
                                                                                          throws IllegalAccessException,
                                                                                                 InstantiationException
Given an property on the main BO class, return the defined type of the ExternalizableBusinessObject. This will be used by other code to determine the correct module service to call for the lookup.

Parameters:
boClass -
propertyName -
Returns:
Throws:
IllegalAccessException
InstantiationException


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