Class LookupableImpl
- All Implemented Interfaces:
Serializable,Lookupable,ViewHelperService
Lookupable and executes a search using the
LookupService.- Author:
- Kuali Rice Team (rice.collab@kuali.org)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsMaintenanceDeleteAction(Object dataObject) Determines if given data object has associated maintenance document that allows delete maintenance actions.booleanallowsMaintenanceEditAction(Object dataObject) Determines if given data object has associated maintenance document that allows edit maintenance actions.booleanDetermines if given data object has associated maintenance document that allows new or copy maintenance actions.voidbuildMaintenanceActionLink(Link actionLink, Object model, String maintenanceMethodToCall) Invoked to build a maintenance URL for a result row.voidbuildMultiValueSelectField(InputField selectField, Object model) Set the value for the input field control to contain the field conversion values for the line.voidbuildReturnUrlForResult(Link returnLink, Object model) Invoked to build the return URL for a result row.protected Collection<?> executeSearch(Map<String, String> adjustedSearchCriteria, List<String> wildcardAsLiteralSearchCriteria, boolean bounded, Integer searchResultsLimit) Invoked to execute the search with the given criteria and restrictions.protected voidgenerateLookupResultsMessages(Map<String, String> searchCriteria, Collection<?> searchResults, boolean bounded, Integer searchResultsLimit) Generates messages for the user based on the search results.protected Map<String, InputField> getCriteriaFieldsForValidation(LookupView lookupView, LookupForm form) Returns the criteria fields in a map keyed by the field property name.protected StringgetCriteriaLabel(LookupForm form, String componentId) Returns the label of the search criteria field.protected DataObjectAuthorizationServiceClass<?> Returns the class for the data object the lookup is configured with.protected org.kuali.rice.core.api.encryption.EncryptionServiceprotected LookupServiceprotected StringgetMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) Generates a URL to perform a maintenance action on the given result data object.protected StringReturns the maintenance document type associated with the business object class or null if one does not exist.getReturnKeyValues(LookupView lookupView, LookupForm lookupForm, Object dataObject) Returns a map of the configured return keys with their selected values.protected StringgetReturnUrl(LookupView lookupView, LookupForm lookupForm, Object dataObject) Builds the URL for returning the given data object result row.protected PropertiesgetReturnUrlParameters(LookupView lookupView, LookupForm lookupForm, Object dataObject) Builds up aPropertiesobject that will be used to provide the request parameters for the return URL linkprotected ValidCharactersConstraintgetSearchCriteriaConstraint(Map lookupCriteria) Indicator if the search criteria has a valid Characters Constraint.protected Collection<?> getSearchResults(Map<String, String> searchCriteria, List<String> wildcardAsLiteralSearchCriteria, boolean unbounded, Integer searchResultsLimit) Performs a normal search using theLookupService.protected List<?> getSearchResultsForEBO(Map<String, String> searchCriteria, boolean unbounded) Performs a search against anExternalizableBusinessObjectby invoking the module servicegetTranslatedReturnKeyValues(LookupView lookupView, LookupForm lookupForm, Object dataObject) Returns a map of the configured return keys translated to their corresponding field conversion with the associated values.identifyWildcardDisabledFields(LookupForm lookupForm, Map<String, String> searchCriteria) Determines which searchCriteria have been configured with wildcard characters disabled.protected booleanisCriteriaRequired(Map lookupCriteria) Indicator if the search criteria is required.protected booleanisCriteriaSecure(Map lookupCriteria) Indicator if the search criteria is on a secure field.protected booleanisCriteriaWildcardDisabled(Map lookupCriteria) Indicator if wildcards and operators are disabled on this search criteria.protected booleanisResultReturnable(Object dataObject) Determines whether a given data object that's returned as one of the lookup's results is considered returnable, which means that for single-value lookups, a "return value" link may be rendered, and for multiple value lookups, a checkbox is rendered.performClear(LookupForm form, Map<String, String> lookupCriteria) Invoked when the clear action is requested to reset the search fields to their initial default values.Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) Invoked to carry out the lookup search based on the given map of key/value search values.processSearchCriteria(LookupForm lookupForm, Map<String, String> searchCriteria) Filters the search criteria to be used with the lookup.voidsetDataObjectAuthorizationService(DataObjectAuthorizationService dataObjectAuthorizationService) voidsetDataObjectClass(Class<?> dataObjectClass) Sets the class for the data object the lookup will be provided on.voidsetDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) voidsetEncryptionService(org.kuali.rice.core.api.encryption.EncryptionService encryptionService) voidsetLookupService(LookupService lookupService) protected voidsortSearchResults(LookupForm form, List<?> searchResults) Sorts the given list of search results based on the lookup view's configured sort attributes.protected voidvalidateSearchParameterConstraint(LookupForm form, String propertyName, Map<String, Object> lookupCriteriaAttributes, String searchPropertyValue, ValidCharactersConstraint validCharactersConstraint) Validates that the searchPropertyValue is a valid value based on any constraint that may exist for the propertyprotected booleanvalidateSearchParameters(LookupForm form, Map<String, String> searchCriteria) Invoked to perform validation on the search criteria before the search is performed.protected voidvalidateSearchParameterWildcardAndOperators(LookupForm form, String propertyName, Map<String, Object> lookupCriteriaAttributes, String searchPropertyValue) Validates that any wildcards contained within the search value are valid wildcards and allowed for the property type for which the field is searching.Methods inherited from class org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl
addCustomContainerComponents, addLine, applyDefaultValues, applyDefaultValuesForCollectionLine, buildGrowlScript, buildInquiryLink, containsDuplicateLine, extractNewValuesAndAssign, extractSingleValue, filterByReturnedFieldConversions, getConfigurationService, getCurrentPersonContactId, getDataDictionaryService, getDataObjectService, getDefaultValueForField, getExpressionEvaluatorFactory, getLegacyDataAdapter, getViewDictionaryService, isDuplicateLine, linkAddedLine, logAndThrowRuntime, performAddLineValidation, performCustomApplyModel, performCustomFinalize, performCustomInitialization, performCustomViewFinalize, performCustomViewInitialization, performDeleteLineValidation, populateDefaultValueForField, populateViewFromRequestParameters, processAfterAddLine, processAfterDeleteLine, processAfterEditLine, processAfterSaveLine, processAndAddLineObject, processBeforeAddLine, processBeforeEditLine, processBeforeSaveLine, processCollectionAddBlankLine, processCollectionAddLine, processCollectionCloseEditLineDialog, processCollectionDeleteLine, processCollectionEditLine, processCollectionRetrieveEditLineDialog, processCollectionSaveLine, processMultipleValueLookupResults, refreshReference, refreshReferences, retrieveEditModesAndActionFlags, setConfigurationService, setDataDictionaryService, setDataObjectService, setElementContext, setExpressionEvaluatorFactory, setLegacyDataAdapter, setViewContext, setViewDictionaryServiceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kuali.rice.krad.uif.service.ViewHelperService
addCustomContainerComponents, applyDefaultValues, applyDefaultValuesForCollectionLine, buildGrowlScript, buildInquiryLink, getDefaultValueForField, getExpressionEvaluatorFactory, performCustomApplyModel, performCustomFinalize, performCustomInitialization, performCustomViewFinalize, performCustomViewInitialization, populateDefaultValueForField, populateViewFromRequestParameters, processAfterAddLine, processAfterDeleteLine, processAfterEditLine, processAfterSaveLine, processAndAddLineObject, processBeforeAddLine, processBeforeEditLine, processBeforeSaveLine, processCollectionAddBlankLine, processCollectionAddLine, processCollectionCloseEditLineDialog, processCollectionDeleteLine, processCollectionEditLine, processCollectionRetrieveEditLineDialog, processCollectionSaveLine, processMultipleValueLookupResults, refreshReference, refreshReferences, retrieveEditModesAndActionFlags, setElementContext, setViewContext
-
Constructor Details
-
LookupableImpl
public LookupableImpl()
-
-
Method Details
-
performSearch
public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) Invoked to carry out the lookup search based on the given map of key/value search values.- Specified by:
performSearchin interfaceLookupable- Parameters:
form- lookup form instance containing the lookup datasearchCriteria- map of criteria currently setbounded- indicates whether the results should be limited (if necessary) to the max search result limit configured- Returns:
- the list of result objects, possibly bounded with
CollectionIncomplete
-
executeSearch
protected Collection<?> executeSearch(Map<String, String> adjustedSearchCriteria, List<String> wildcardAsLiteralSearchCriteria, boolean bounded, Integer searchResultsLimit) Invoked to execute the search with the given criteria and restrictions.- Parameters:
adjustedSearchCriteria- map of criteria that has been adjusted (encyrption, ebos, etc)wildcardAsLiteralSearchCriteria- map of criteria to treat as literals (wildcards disabled)bounded- indicates whether the search should be boundedsearchResultsLimit- for bounded searches, the result limit- Returns:
- Collectioninvalid input: '<'?> collection of data object instances from the search results
-
processSearchCriteria
protected Map<String,String> processSearchCriteria(LookupForm lookupForm, Map<String, String> searchCriteria) Filters the search criteria to be used with the lookup.Processing entails primarily of the removal of filtered and unused/blank search criteria. Encrypted field values are decrypted, and date range fields are combined into a single criteria entry.
In special cases additional non-valid criteria may be included. E.g. with the KIM User Control as a criteria the principal name may be passed so that it is displayed on the control. The filtering removes these values based on the viewPostMetadata. When calling the search directly (methodToCall=search) the viewPostMetadata is not set before filtering therefore non-valid criteria are not supported in these cases.
- Parameters:
lookupForm- lookup form instance containing the lookup datasearchCriteria- map of criteria to process- Returns:
- map of processed criteria
-
identifyWildcardDisabledFields
protected List<String> identifyWildcardDisabledFields(LookupForm lookupForm, Map<String, String> searchCriteria) Determines which searchCriteria have been configured with wildcard characters disabled.- Parameters:
lookupForm- form used to collect search criteriasearchCriteria- Map of property names and values to use as search parameters- Returns:
- List of property names which have wildcard characters disabled
-
validateSearchParameters
Invoked to perform validation on the search criteria before the search is performed.- Check required criteria have a value
- Check that criteria data type supports wildcards/operators
- Check that wildcards/operators are not used on a secure criteria
- Display info message when wildcards/operators are disabled
- Throw exception when invalid criteria are specified
- Parameters:
form- lookup form instance containing the lookup datasearchCriteria- map of criteria where key is search property name and value is search value (which can include wildcards)- Returns:
- boolean true if validation was successful, false if there were errors and the search should not be performed
-
validateSearchParameterWildcardAndOperators
protected void validateSearchParameterWildcardAndOperators(LookupForm form, String propertyName, Map<String, Object> lookupCriteriaAttributes, String searchPropertyValue) Validates that any wildcards contained within the search value are valid wildcards and allowed for the property type for which the field is searching.- Parameters:
form- lookup form instance containing the lookup datapropertyName- property name of the search criteria field to be validatedsearchPropertyValue- value given for field to search for
-
validateSearchParameterConstraint
protected void validateSearchParameterConstraint(LookupForm form, String propertyName, Map<String, Object> lookupCriteriaAttributes, String searchPropertyValue, ValidCharactersConstraint validCharactersConstraint) Validates that the searchPropertyValue is a valid value based on any constraint that may exist for the property- Parameters:
form- lookup form instance containing the lookup datapropertyName- property name of the search criteria field to be validatedlookupCriteriaAttributes- attributes for the lookup criteriasearchPropertyValue- value given for field to search forvalidCharactersConstraint- constraint on the lookup criteria field
-
getCriteriaLabel
Returns the label of the search criteria field.- Parameters:
form- lookup form instance containing the lookup datacomponentId- component id of the search criteria field- Returns:
- label of the search criteria field
-
isCriteriaWildcardDisabled
Indicator if wildcards and operators are disabled on this search criteria.- Parameters:
lookupCriteria- the viewPostMetadata with the attributes of the search criteria field- Returns:
- true if wildcards and operators are disabled, false otherwise
-
isCriteriaRequired
Indicator if the search criteria is required.- Parameters:
lookupCriteria- the viewPostMetadata with the attributes of the search criteria field- Returns:
- true if the search criteria is required, false otherwise
-
isCriteriaSecure
Indicator if the search criteria is on a secure field.- Parameters:
lookupCriteria- the viewPostMetadata with the attributes of the search criteria field- Returns:
- true if the search criteria is a secure field, false otherwise
-
getSearchCriteriaConstraint
Indicator if the search criteria has a valid Characters Constraint.- Parameters:
lookupCriteria- the viewPostMetadata with the attributes of the search criteria field- Returns:
- the ValidCharactersConstraint if the search criteria has a valid characters constraint
-
generateLookupResultsMessages
protected void generateLookupResultsMessages(Map<String, String> searchCriteria, Collection<?> searchResults, boolean bounded, Integer searchResultsLimit) Generates messages for the user based on the search results.Messages are generated for the number of results, if the results exceed the result limit, and if the search was done using the primary keys for the data object.
- Parameters:
searchCriteria- map of search criteria that was used for the searchsearchResults- list of result data objects from the searchbounded- whether the search was boundedsearchResultsLimit- maximum number of search results to return
-
sortSearchResults
Sorts the given list of search results based on the lookup view's configured sort attributes.First if the posted view exists we grab the sort attributes from it. This will take into account expressions that might have been configured on the sort attributes. If the posted view does not exist (because we did a search from a get request or form session storage is off), we get the sort attributes from the view that we will be rendered (and was initialized before controller call). However, expressions will not be evaluated yet, thus if expressions were configured we don't know the results and can not sort the list
- Parameters:
form- lookup form instance containing view informationsearchResults- list of search results to sort
-
getSearchResults
protected Collection<?> getSearchResults(Map<String, String> searchCriteria, List<String> wildcardAsLiteralSearchCriteria, boolean unbounded, Integer searchResultsLimit) Performs a normal search using theLookupService.- Parameters:
searchCriteria- map of criteria currently setwildcardAsLiteralSearchCriteria- list of property names which have wildcard characters disabledunbounded- indicates whether the complete result should be returned. When set to false the result is limited (if necessary) to the max search result limit configured.searchResultsLimit- result set limit- Returns:
- list of result objects, possibly bounded
-
getSearchResultsForEBO
Performs a search against anExternalizableBusinessObjectby invoking the module service- Parameters:
searchCriteria- map of criteria currently setunbounded- indicates whether the complete result should be returned. When set to false the result is limited (if necessary) to the max search result limit configured.- Returns:
- list of result objects, possibly bounded
-
performClear
Invoked when the clear action is requested to reset the search fields to their initial default values.- Specified by:
performClearin interfaceLookupable- Parameters:
form- lookup form instance containing the lookup datalookupCriteria- map of criteria currently set- Returns:
- map of criteria with field values reset to defaults
-
buildReturnUrlForResult
Invoked to build the return URL for a result row.Based on the line contained in the field context, the URL for returning the role is constructed and set as the href for the link. If a return link cannot be constructed the link should be set to not render
- Specified by:
buildReturnUrlForResultin interfaceLookupable- Parameters:
returnLink- link that will be used to render the return URLmodel- lookup form containing the data
-
isResultReturnable
Determines whether a given data object that's returned as one of the lookup's results is considered returnable, which means that for single-value lookups, a "return value" link may be rendered, and for multiple value lookups, a checkbox is rendered.Note that this can be part of an authorization mechanism, but not the complete authorization mechanism. The component that invoked the lookup/ lookup caller (e.g. document, nesting lookup, etc.) needs to check that the object that was passed to it was returnable as well because there are ways around this method (e.g. crafting a custom return URL).
- Parameters:
dataObject- an object from the search result set- Returns:
- true if the row is returnable and false if it is not
-
getReturnUrl
Builds the URL for returning the given data object result row.Note return URL will only be built if a return location is specified on the lookup form
- Parameters:
lookupView- lookup view instance containing lookup configurationlookupForm- lookup form instance containing the datadataObject- data object instance for the current line and for which the return URL is being built- Returns:
- String return URL or blank if URL cannot be built
-
getReturnUrlParameters
protected Properties getReturnUrlParameters(LookupView lookupView, LookupForm lookupForm, Object dataObject) Builds up aPropertiesobject that will be used to provide the request parameters for the return URL link- Parameters:
lookupView- lookup view instance containing lookup configurationlookupForm- lookup form instance containing the datadataObject- data object instance for the current line and for which the return URL is being built- Returns:
- Properties instance containing request parameters for return URL
-
getTranslatedReturnKeyValues
protected Map<String,String> getTranslatedReturnKeyValues(LookupView lookupView, LookupForm lookupForm, Object dataObject) Returns a map of the configured return keys translated to their corresponding field conversion with the associated values.- Parameters:
lookupView- lookup view instance containing lookup configurationlookupForm- lookup form instance containing the datadataObject- data object instance- Returns:
- Mapinvalid input: '<'String, String> map of translated return key/value pairs
-
getReturnKeyValues
protected Map<String,String> getReturnKeyValues(LookupView lookupView, LookupForm lookupForm, Object dataObject) Returns a map of the configured return keys with their selected values.- Parameters:
lookupView- lookup view instance containing lookup configurationlookupForm- lookup form instance containing the datadataObject- data object instance- Returns:
- Mapinvalid input: '<'String, String> map of return key/value pairs
-
buildMaintenanceActionLink
public void buildMaintenanceActionLink(Link actionLink, Object model, String maintenanceMethodToCall) Invoked to build a maintenance URL for a result row.Based on the line contained in the field context and the given maintenance method that should be called a URL is constructed and set as the action on the action link. If a maintenance link cannot be constructed the action link should be set to not render
- Specified by:
buildMaintenanceActionLinkin interfaceLookupable- Parameters:
actionLink- link that will be used to return the maintenance URLmodel- lookup form containing the datamaintenanceMethodToCall- name of the method that should be invoked in the maintenance controller
-
getMaintenanceActionUrl
protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) Generates a URL to perform a maintenance action on the given result data object.Will build a URL containing keys of the data object to invoke the given maintenance action method within the maintenance controller
- Parameters:
lookupForm- lookup formdataObject- data object instance for the line to build the maintenance action link formethodToCall- method name on the maintenance controller that should be invokedpkNames- list of primary key field names for the data object whose key/value pairs will be added to the maintenance link- Returns:
- String URL link for the maintenance action
-
buildMultiValueSelectField
Set the value for the input field control to contain the field conversion values for the line.Creates and populate the value of the input field control. This value is built according to
LookupForm.getFieldConversions()and allows for client side population of the returned fields without having to do an additional server call.- Specified by:
buildMultiValueSelectFieldin interfaceLookupable- Parameters:
selectField- the InputField used to mark the lookup row as selectedmodel- lookup form containing the model data
-
allowsMaintenanceNewOrCopyAction
public boolean allowsMaintenanceNewOrCopyAction()Determines if given data object has associated maintenance document that allows new or copy maintenance actions.- Specified by:
allowsMaintenanceNewOrCopyActionin interfaceLookupable- Returns:
- boolean true if the maintenance new or copy action is allowed for the data object instance, false otherwise
-
allowsMaintenanceEditAction
Determines if given data object has associated maintenance document that allows edit maintenance actions.- Specified by:
allowsMaintenanceEditActionin interfaceLookupable- Parameters:
dataObject- data object- Returns:
- boolean true if the maintenance edit action is allowed for the data object instance, false otherwise
-
allowsMaintenanceDeleteAction
Determines if given data object has associated maintenance document that allows delete maintenance actions.- Specified by:
allowsMaintenanceDeleteActionin interfaceLookupable- Parameters:
dataObject- data object- Returns:
- boolean true if the maintenance delete action is allowed for the data object instance, false otherwise
-
getMaintenanceDocumentTypeName
Returns the maintenance document type associated with the business object class or null if one does not exist.- Returns:
- String representing the maintenance document type name
-
getCriteriaFieldsForValidation
protected Map<String,InputField> getCriteriaFieldsForValidation(LookupView lookupView, LookupForm form) Returns the criteria fields in a map keyed by the field property name.- Parameters:
lookupView- lookup view instance to pull criteria fields fromform- lookup form instance containing the lookup data- Returns:
- map of criteria fields
-
getDataObjectClass
Returns the class for the data object the lookup is configured with.- Specified by:
getDataObjectClassin interfaceLookupable- Returns:
- Classinvalid input: '<'?> data object class
-
setDataObjectClass
Sets the class for the data object the lookup will be provided on.- Specified by:
setDataObjectClassin interfaceLookupable- Parameters:
dataObjectClass- - data object class for lookup
-
getDataObjectAuthorizationService
-
setDataObjectAuthorizationService
public void setDataObjectAuthorizationService(DataObjectAuthorizationService dataObjectAuthorizationService) -
getDocumentDictionaryService
-
setDocumentDictionaryService
-
getLookupService
-
setLookupService
-
getEncryptionService
protected org.kuali.rice.core.api.encryption.EncryptionService getEncryptionService() -
setEncryptionService
public void setEncryptionService(org.kuali.rice.core.api.encryption.EncryptionService encryptionService)
-