org.kuali.rice.kns.lookup
Class LookupUtils

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

public class LookupUtils
extends Object

This is a static utility class for Lookup related utilities and helper methods.


Field Summary
private static String BASE_INQUIRY_ACTION_URL
           
private static String BASE_LOOKUP_ACTION_URL
           
private static String BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL
           
private static BusinessObjectDictionaryService businessObjectDictionaryService
           
private static BusinessObjectMetaDataService businessObjectMetaDataService
           
private static DataDictionaryService dataDictionaryService
           
private static DateTimeService dateTimeService
           
private static KualiConfigurationService kualiConfigurationService
           
private static org.apache.log4j.Logger LOG
           
private static PersistenceStructureService persistenceStructureService
           
private static Map<Class,Map<String,Map>> referencesForForeignKey
           
 
Constructor Summary
LookupUtils()
           
 
Method Summary
static void applySearchResultsLimit(Class businessObjectClass, Criteria criteria)
          This method 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 void applySearchResultsLimit(org.apache.ojb.broker.query.Criteria criteria, DatabasePlatform platform)
          Deprecated. use applySearchResultsLimit(Class, Criteria, DatabasePlatform) instead
static String convertReferencesToSelectCollectionToString(Collection<String> referencesToRefresh)
           
static String convertSetOfObjectIdsToString(Set<String> objectIds)
           
static Set<String> convertStringOfObjectIdsToSet(String objectIdsString)
           
static Comparator findBestValueComparatorForColumn(List<ResultRow> resultTable, int column)
          Given a list of results from a lookup, determines the best comparator to use on the String values of each of these columns This method exists because each cell (represented by the Column object) lists the comparator that should be used within it based on the property value class, so we gotta go thru the whole list and determine the best comparator to use
static Map<String,String> forceUppercase(Class boClass, Map<String,String> fieldValues)
          This method 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 boClass, String fieldName, String fieldValue)
          This method 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 Map<String,String> generateCompositeSelectedObjectIds(Set<String> previouslySelectedObjectIds, Set<String> displayedObjectIds, Set<String> selectedObjectIds)
          Given 3 sets of object IDs: the set of selected object IDs before rendering the current page, the set of object IDs rendered on the page, and the set of object IDs selected on the page, computes the total set of selected object IDs.
private static String generateFieldConversions(BusinessObject businessObject, String collectionName, BusinessObjectRelationship relationship, String propertyPrefix, List displayedFieldNames, String nestedObjectPrefix)
           
private static String generateLookupParameters(BusinessObject businessObject, String collectionName, BusinessObjectRelationship relationship, String propertyPrefix, List displayedFieldNames, String nestedObjectPrefix)
           
static Timestamp getActiveDateTimestampForCriteria(Map searchValues)
          Determines what Timestamp should be used for active queries on effective dated records.
static Integer getApplicationMaximumSearchResulsPerPageForMultipleValueLookups()
          This method the maximum rows per page in a multiple value lookup
private static Integer getApplicationSearchResultsLimit()
           
static String getBaseInquiryUrl()
           
static String getBaseLookupUrl(boolean isMultipleValue)
           
private static Integer getBusinessObjectSearchResultsLimit(Class businessObjectClass)
          This method parses and returns the lookup result set limit for the passed in BO (if one exists)
static BusinessObject getNestedBusinessObject(BusinessObject bo, String attributeName)
          This method walks through the nested attribute and finds the last business object in the chain and returns it (excluding the last parameter which is the actual attribute)
static Class getNestedReferenceClass(BusinessObject businessObject, String attributeName)
           
static Map getPrimitiveReference(BusinessObject businessObject, String attributeName)
           
static Integer getSearchResultsLimit(Class businessObjectClass)
          This method parses and returns the lookup result set limit, checking first for the limit for the BO being looked up, and then the global application limit if there isn't a limit specific to this BO.
static void removeHiddenCriteriaFields(Class businessObjectClass, Map fieldValues)
          Removes fields identified in the data dictionary as hidden from the lookup field values.
 void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService)
           
 void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService)
          Sets the businessObjectMetaDataService attribute value.
 void setDataDictionaryService(DataDictionaryService ddService)
           
 void setDateTimeService(DateTimeService dateTimeService)
           
static Field setFieldDirectInquiry(BusinessObject businessObject, String attributeName, Field field)
           
private static void setFieldDirectInquiry(Field field)
          Sets whether a field should have direct inquiries enabled.
static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index, String attributeName, Field field, List displayedFieldNames)
          Sets a fields quickfinder class and field conversions for an attribute.
static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index, String attributeName, Field field, List displayedFieldNames, boolean noLookupField)
           
static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index, String attributeName, Field field, List displayedFieldNames, SelectiveReferenceRefresher srr)
          Sets a fields quickfinder class and field conversions for an attribute.
static Field setFieldQuickfinder(BusinessObject businessObject, String attributeName, Field field, List displayedFieldNames)
           
static Field setFieldQuickfinder(BusinessObject businessObject, String attributeName, Field field, List displayedFieldNames, SelectiveReferenceRefresher srr)
           
 void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService)
           
 void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
           
static String transformLookupUrlToMultiple(String lookupUrl)
           
static Map translateFieldConversions(String fieldConversionsString)
          This translates a , delimited list of pairs separated by a : into a Map of target --> lookup field conversions.
static List<String> translateReadOnlyFieldsToList(String readOnlyFieldsString)
          This makes a , delimited String list of fields separated by a , into a List of target --> lookup readOnlyFieldsList.
private static String translateToDisplayedField(Class businessObjectClass, String fieldName, List displayedFieldNames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

dataDictionaryService

private static DataDictionaryService dataDictionaryService

persistenceStructureService

private static PersistenceStructureService persistenceStructureService

businessObjectDictionaryService

private static BusinessObjectDictionaryService businessObjectDictionaryService

businessObjectMetaDataService

private static BusinessObjectMetaDataService businessObjectMetaDataService

kualiConfigurationService

private static KualiConfigurationService kualiConfigurationService

dateTimeService

private static DateTimeService dateTimeService

BASE_LOOKUP_ACTION_URL

private static String BASE_LOOKUP_ACTION_URL

BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL

private static String BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL

BASE_INQUIRY_ACTION_URL

private static String BASE_INQUIRY_ACTION_URL

referencesForForeignKey

private static Map<Class,Map<String,Map>> referencesForForeignKey
Constructor Detail

LookupUtils

public LookupUtils()
Method Detail

setBusinessObjectDictionaryService

public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService)

setDataDictionaryService

public void setDataDictionaryService(DataDictionaryService ddService)

setPersistenceStructureService

public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)

setKualiConfigurationService

public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService)

setDateTimeService

public void setDateTimeService(DateTimeService dateTimeService)

setBusinessObjectMetaDataService

public void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService)
Sets the businessObjectMetaDataService attribute value.

Parameters:
businessObjectMetaDataService - The businessObjectMetaDataService to set.

forceUppercase

public static String forceUppercase(Class boClass,
                                    String fieldName,
                                    String fieldValue)
This method 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:
boClass - Parent BO 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 boClass,
                                                Map<String,String> fieldValues)
This method 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:
boClass - Parent BO 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).

applySearchResultsLimit

public static void applySearchResultsLimit(org.apache.ojb.broker.query.Criteria criteria,
                                           DatabasePlatform platform)
Deprecated. use applySearchResultsLimit(Class, Criteria, DatabasePlatform) instead


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)
This method 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

getSearchResultsLimit

public static Integer getSearchResultsLimit(Class businessObjectClass)
This method parses and returns the lookup result set limit, checking first for the limit for the BO being looked up, and then the global application limit if there isn't a limit specific to this BO.

Parameters:
businessObjectClass - BO class to search on / get limit for. If the passed in type is not of type BusinessObject, then the application-wide default limit is used.
Returns:
result set limit (or null if there isn't one)

getApplicationSearchResultsLimit

private static Integer getApplicationSearchResultsLimit()

getBusinessObjectSearchResultsLimit

private static Integer getBusinessObjectSearchResultsLimit(Class businessObjectClass)
This method parses and returns the lookup result set limit for the passed in BO (if one exists)

Parameters:
businessObjectClass -
Returns:
result set limit for this BO (or null if the BO doesn't have a limit)

getApplicationMaximumSearchResulsPerPageForMultipleValueLookups

public static Integer getApplicationMaximumSearchResulsPerPageForMultipleValueLookups()
This method the maximum rows per page in a multiple value lookup

Returns:
See Also:
org.kuali.KNSConstants.SystemGroupParameterNames#MULTIPLE_VALUE_LOOKUP_RESULTS_PER_PAGE

translateReadOnlyFieldsToList

public static List<String> translateReadOnlyFieldsToList(String readOnlyFieldsString)
This makes a , delimited String list of fields separated by a , into a List of target --> lookup readOnlyFieldsList.

Parameters:
readOnlyFields -
Returns:
the List representation of the readOnlyFields String provided.

translateFieldConversions

public static Map translateFieldConversions(String fieldConversionsString)
This translates a , delimited list of pairs separated by a : into a Map of target --> lookup field conversions.

Parameters:
conversionFields -
Returns:
the Map representation of the fieldConversions String provided.

setFieldQuickfinder

public static Field setFieldQuickfinder(BusinessObject businessObject,
                                        String attributeName,
                                        Field field,
                                        List displayedFieldNames)

setFieldQuickfinder

public static Field setFieldQuickfinder(BusinessObject businessObject,
                                        String attributeName,
                                        Field field,
                                        List displayedFieldNames,
                                        SelectiveReferenceRefresher srr)

setFieldQuickfinder

public static Field setFieldQuickfinder(BusinessObject businessObject,
                                        String collectionName,
                                        boolean addLine,
                                        int index,
                                        String attributeName,
                                        Field field,
                                        List displayedFieldNames,
                                        SelectiveReferenceRefresher srr)
Sets a fields quickfinder class and field conversions for an attribute.


setFieldQuickfinder

public static Field setFieldQuickfinder(BusinessObject businessObject,
                                        String collectionName,
                                        boolean addLine,
                                        int index,
                                        String attributeName,
                                        Field field,
                                        List displayedFieldNames)
Sets a fields quickfinder class and field conversions for an attribute.


setFieldQuickfinder

public static Field setFieldQuickfinder(BusinessObject businessObject,
                                        String collectionName,
                                        boolean addLine,
                                        int index,
                                        String attributeName,
                                        Field field,
                                        List displayedFieldNames,
                                        boolean noLookupField)

getBaseLookupUrl

public static String getBaseLookupUrl(boolean isMultipleValue)

getBaseInquiryUrl

public static String getBaseInquiryUrl()

transformLookupUrlToMultiple

public static String transformLookupUrlToMultiple(String lookupUrl)

setFieldDirectInquiry

private static void setFieldDirectInquiry(Field field)
Sets whether a field should have direct inquiries enabled. The direct inquiry is the functionality on a page such that if the primary key for a quickfinder is filled in and the direct inquiry button is pressed, then a new window will popup showing an inquiry page without going through the lookup first. For this method to work properly, it must be called after setFieldQuickfinder //TODO: chb: that should not be the case -- the relationship object the two rely upon should be established outside of the lookup/quickfinder code

Parameters:
field -

setFieldDirectInquiry

public static Field setFieldDirectInquiry(BusinessObject businessObject,
                                          String attributeName,
                                          Field field)
Parameters:
field -
Returns:
the altered Field object

getPrimitiveReference

public static Map getPrimitiveReference(BusinessObject businessObject,
                                        String attributeName)

getNestedBusinessObject

public static BusinessObject getNestedBusinessObject(BusinessObject bo,
                                                     String attributeName)
This method walks through the nested attribute and finds the last business object in the chain and returns it (excluding the last parameter which is the actual attribute)

Parameters:
attributeName -
Returns:

getNestedReferenceClass

public static Class getNestedReferenceClass(BusinessObject businessObject,
                                            String attributeName)

generateFieldConversions

private static String generateFieldConversions(BusinessObject businessObject,
                                               String collectionName,
                                               BusinessObjectRelationship relationship,
                                               String propertyPrefix,
                                               List displayedFieldNames,
                                               String nestedObjectPrefix)

generateLookupParameters

private static String generateLookupParameters(BusinessObject businessObject,
                                               String collectionName,
                                               BusinessObjectRelationship relationship,
                                               String propertyPrefix,
                                               List displayedFieldNames,
                                               String nestedObjectPrefix)

translateToDisplayedField

private static String translateToDisplayedField(Class businessObjectClass,
                                                String fieldName,
                                                List displayedFieldNames)

convertReferencesToSelectCollectionToString

public static String convertReferencesToSelectCollectionToString(Collection<String> referencesToRefresh)

convertSetOfObjectIdsToString

public static String convertSetOfObjectIdsToString(Set<String> objectIds)

convertStringOfObjectIdsToSet

public static Set<String> convertStringOfObjectIdsToSet(String objectIdsString)

findBestValueComparatorForColumn

public static Comparator findBestValueComparatorForColumn(List<ResultRow> resultTable,
                                                          int column)
Given a list of results from a lookup, determines the best comparator to use on the String values of each of these columns This method exists because each cell (represented by the Column object) lists the comparator that should be used within it based on the property value class, so we gotta go thru the whole list and determine the best comparator to use

Parameters:
resultsTable -
column -
Returns:

generateCompositeSelectedObjectIds

public static Map<String,String> generateCompositeSelectedObjectIds(Set<String> previouslySelectedObjectIds,
                                                                    Set<String> displayedObjectIds,
                                                                    Set<String> selectedObjectIds)
Given 3 sets of object IDs: the set of selected object IDs before rendering the current page, the set of object IDs rendered on the page, and the set of object IDs selected on the page, computes the total set of selected object IDs. Instead of storing it in a set, returns it in a map with the selected object ID as both the key and value

Parameters:
previouslySelectedObjectIds -
displayedObjectIds -
selectedObjectIds -
Returns:

removeHiddenCriteriaFields

public static void removeHiddenCriteriaFields(Class businessObjectClass,
                                              Map fieldValues)
Removes fields identified in the data dictionary as hidden from the lookup field values. (This will remove Universal User ID and Person name from search requests when a user ID is entered.)

Parameters:
fieldValues -

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


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