public List<User> load(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
List<User> users = null;
Sort sort;
// sort
if (sortField != null) {
if (sortOrder.equals(SortOrder.DESCENDING)) {
sort = SortFactoryUtil.getSort(User.class, sortField, "desc");
}
else {
sort = SortFactoryUtil.getSort(User.class, sortField, "asc");
}
}
else {
sort = SortFactoryUtil.getSort(User.class, DEFAULT_SORT_CRITERIA, "asc");
}
try {
LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
int liferayOneRelativeFinishRow = first + pageSize + 1;
boolean andSearch = true;
int status = WorkflowConstants.STATUS_ANY;
String firstName = trimExpresssion((String) filters.get("firstName"));
String middleName = trimExpresssion((String) filters.get("middleName"));
String lastName = trimExpresssion((String) filters.get("lastName"));
String screenName = trimExpresssion((String) filters.get("screenName"));
String emailAddress = trimExpresssion((String) filters.get("emailAddress"));
// For the sake of speed, search for users in the index rather than
// querying the database directly.
Hits hits = UserLocalServiceUtil.search(companyId, firstName, middleName, lastName, screenName,
emailAddress, status, params, andSearch, first, liferayOneRelativeFinishRow, sort);
List<Document> documentHits = hits.toList();
logger.debug(
("filters firstName=[{0}] middleName=[{1}] lastName=[{2}] screenName=[{3}] emailAddress=[{4}] active=[{5}] andSearch=[{6}] startRow=[{7}] liferayOneRelativeFinishRow=[{8}] sortColumn=[{9}] reverseOrder=[{10}] hitCount=[{11}]"),
firstName, middleName, lastName, screenName, emailAddress, status, andSearch, first,
liferayOneRelativeFinishRow, sortField, sort.isReverse(), documentHits.size());
// Convert the results from the search index into a list of user
// objects.
users = new ArrayList<User>(documentHits.size());