use of org.kuali.kfs.kns.lookup.LookupableHelperService in project cu-kfs by CU-CommunityApps.
the class DataObjectRestServiceController method getSearchResults.
protected List<? extends BusinessObject> getSearchResults(HttpServletRequest request, FinancialSystemBusinessObjectEntry boe) {
Map<String, String> fieldValues = new HashMap<String, String>();
for (Object o : request.getParameterMap().keySet()) {
String[] value = (String[]) request.getParameterMap().get(o);
fieldValues.put(o.toString(), value[0]);
}
LookupableHelperService lookupableHelperService = getLookupableHelperService(boe.getLookupDefinition().getLookupableID());
lookupableHelperService.setBusinessObjectClass(boe.getBusinessObjectClass());
String limitByParameter = fieldValues.remove(LIMIT_BY_PARAMETER);
String maxObjectsToReturn = fieldValues.remove(MAX_OBJECTS_TO_RETURN);
List<? extends BusinessObject> searchResults;
if (StringUtils.isEmpty(limitByParameter) || limitByParameter.equalsIgnoreCase("Y")) {
searchResults = lookupableHelperService.getSearchResults(fieldValues);
} else {
try {
searchResults = lookupableHelperService.getSearchResultsUnbounded(fieldValues);
} catch (UnsupportedOperationException e) {
LOG.warn("lookupableHelperService.getSearchResultsUnbounded failed. Retrying the lookup using the default search.", e);
searchResults = lookupableHelperService.getSearchResults(fieldValues);
}
}
if (StringUtils.isNotEmpty(maxObjectsToReturn)) {
int searchLimit = Integer.parseInt(maxObjectsToReturn);
if (searchLimit > 0) {
return searchResults.subList(0, Math.min(searchResults.size(), searchLimit));
}
}
return searchResults;
}
Aggregations