mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.1.N (5.1.3) to 5.2.N (5.2.1)
134007 cpopa: Merged 5.0.N (5.0.5) to 5.1.N (5.1.3) 134006 cpopa: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.5) 134005 cpopa: MNT-17011 : Site Blog Post's tag filter always limits to 10 results and offers no paging to go through all results if larger than 10 - ensure the tag filter returns correct information so as to allow the user to page though all the results git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134008 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.blog;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -82,6 +84,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
public class BlogServiceImpl implements BlogService
|
||||
{
|
||||
public static final String BLOG_COMPONENT = "blog";
|
||||
private static final int MIN_NUMBER_OF_PAGES_FOR_THE_USER_TO_LOOP_THROUGH = 10;
|
||||
|
||||
/**
|
||||
* The logger
|
||||
@@ -537,23 +540,23 @@ public class BlogServiceImpl implements BlogService
|
||||
{
|
||||
luceneQuery.append(createDateRangeQuery(dateRange.getFromDate(), dateRange.getToDate(), dateRange.getDateProperty()));
|
||||
}
|
||||
|
||||
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(blogContainerNode.getStoreRef());
|
||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp.setQuery(luceneQuery.toString());
|
||||
sp.addSort(ContentModel.PROP_PUBLISHED.toString(), false);
|
||||
|
||||
sp.setMaxItems(pagingReq.getMaxItems());
|
||||
|
||||
sp.setMaxItems(pagingReq.getMaxItems() * MIN_NUMBER_OF_PAGES_FOR_THE_USER_TO_LOOP_THROUGH);
|
||||
sp.setSkipCount(pagingReq.getSkipCount());
|
||||
|
||||
ResultSet luceneResults = null;
|
||||
PagingResults<BlogPostInfo> results = null;
|
||||
try
|
||||
{
|
||||
luceneResults = searchService.query(sp);
|
||||
final ResultSet finalLuceneResults = luceneResults;
|
||||
final List<NodeRef> nodeRefs = finalLuceneResults.getNodeRefs();
|
||||
|
||||
final List<NodeRef> nodeRefs = finalLuceneResults.getNodeRefs().subList(0, min(pagingReq.getMaxItems(), finalLuceneResults.length()));
|
||||
|
||||
results = new PagingResults<BlogPostInfo>()
|
||||
{
|
||||
@@ -578,16 +581,18 @@ public class BlogServiceImpl implements BlogService
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
int itemsRemainingAfterThisPage = finalLuceneResults.length();
|
||||
final int totalItemsInUnpagedResultSet = pagingReq.getSkipCount() + itemsRemainingAfterThisPage;
|
||||
return new Pair<Integer, Integer>(totalItemsInUnpagedResultSet, totalItemsInUnpagedResultSet);
|
||||
{
|
||||
long totalResultCount = finalLuceneResults.getNumberFound();
|
||||
/*if (finalLuceneResults.hasMore()){
|
||||
totalResultCount++;
|
||||
}*/
|
||||
return new Pair<Integer, Integer>((int)totalResultCount, (int)totalResultCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return finalLuceneResults.hasMore();
|
||||
return finalLuceneResults.length() > pagingReq.getMaxItems();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user