}
request.setAttribute("scope", scope);
request.setAttribute("scopes", scopes);
// Perform the search
DiscoverResult qResults = null;
try
{
qResults = SearchUtils.getSearchService().search(context, scope,
queryArgs);
List<Community> resultsListComm = new ArrayList<Community>();
List<Collection> resultsListColl = new ArrayList<Collection>();
List<Item> resultsListItem = new ArrayList<Item>();
for (DSpaceObject dso : qResults.getDspaceObjects())
{
if (dso instanceof Item)
{
resultsListItem.add((Item) dso);
}
else if (dso instanceof Collection)
{
resultsListColl.add((Collection) dso);
}
else if (dso instanceof Community)
{
resultsListComm.add((Community) dso);
}
}
// Make objects from the handles - make arrays, fill them out
resultsCommunities = new Community[resultsListComm.size()];
resultsCollections = new Collection[resultsListColl.size()];
resultsItems = new Item[resultsListItem.size()];
resultsCommunities = resultsListComm.toArray(resultsCommunities);
resultsCollections = resultsListColl.toArray(resultsCollections);
resultsItems = resultsListItem.toArray(resultsItems);
// Log
log.info(LogManager.getHeader(context, "search", "scope=" + scope
+ ",query=\"" + query + "\",results=("
+ resultsCommunities.length + ","
+ resultsCollections.length + "," + resultsItems.length
+ ")"));
// Pass in some page qualities
// total number of pages
long pageTotal = 1 + ((qResults.getTotalSearchResults() - 1) / qResults
.getMaxResults());
// current page being displayed
long pageCurrent = 1 + (qResults.getStart() / qResults
.getMaxResults());
// pageLast = min(pageCurrent+3,pageTotal)
long pageLast = ((pageCurrent + 3) > pageTotal) ? pageTotal
: (pageCurrent + 3);
// pageFirst = max(1,pageCurrent-3)
long pageFirst = ((pageCurrent - 3) > 1) ? (pageCurrent - 3) : 1;
// Pass the results to the display JSP
request.setAttribute("items", resultsItems);
request.setAttribute("communities", resultsCommunities);
request.setAttribute("collections", resultsCollections);
request.setAttribute("pagetotal", new Long(pageTotal));
request.setAttribute("pagecurrent", new Long(pageCurrent));
request.setAttribute("pagelast", new Long(pageLast));
request.setAttribute("pagefirst", new Long(pageFirst));
request.setAttribute("spellcheck", qResults.getSpellCheckQuery());
request.setAttribute("queryresults", qResults);
try
{