mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9153 Correct the component name, and improve the fetching of the most recent post reply
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29794 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -62,7 +62,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class DiscussionServiceImpl implements DiscussionService
|
||||
{
|
||||
public static final String DISCUSSION_COMPONENT = "discussion";
|
||||
public static final String DISCUSSION_COMPONENT = "discussions";
|
||||
|
||||
protected static final String CANNED_QUERY_GET_CHILDREN = "discussionGetChildrenCannedQueryFactory";
|
||||
|
||||
@@ -510,32 +510,20 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
{
|
||||
// Do a listing at the Node level, ordered by created date
|
||||
// to get the most recent nodes
|
||||
NodeBackedEntity node = null;
|
||||
int skip = 0;
|
||||
int pageSize = 10000;
|
||||
while(node == null)
|
||||
{
|
||||
PagingRequest paging = new PagingRequest(skip, pageSize);
|
||||
paging.setRequestTotalCountMax(skip+pageSize+10);
|
||||
CannedQueryResults<NodeBackedEntity> results =
|
||||
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, paging);
|
||||
PagingRequest paging = new PagingRequest(0, 1);
|
||||
CannedQueryResults<NodeBackedEntity> results =
|
||||
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, false, paging);
|
||||
|
||||
// Move to the next page if we're not at the end
|
||||
if(results.hasMoreItems())
|
||||
{
|
||||
skip += pageSize;
|
||||
continue;
|
||||
}
|
||||
// Bail if the topic lacks posts
|
||||
if(results.getPage().size() == 0)
|
||||
{
|
||||
// No posts in the topic
|
||||
return null;
|
||||
}
|
||||
// Grab the last node
|
||||
node = results.getPage().get(results.getPage().size()-1);
|
||||
// Bail if the topic lacks posts
|
||||
if(results.getPage().size() == 0)
|
||||
{
|
||||
// No posts in the topic
|
||||
return null;
|
||||
}
|
||||
|
||||
// Grab the newest node
|
||||
NodeBackedEntity node = results.getPage().get(0);
|
||||
|
||||
// Wrap and return
|
||||
return buildPost(node.getNodeRef(), topic, node.getName(), null);
|
||||
}
|
||||
@@ -558,9 +546,9 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
@Override
|
||||
public PagingResults<TopicInfo> listTopics(NodeRef nodeRef,
|
||||
PagingRequest paging) {
|
||||
// Do the listing
|
||||
// Do the listing, oldest first
|
||||
CannedQueryResults<NodeBackedEntity> nodes =
|
||||
listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, paging);
|
||||
listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, true, paging);
|
||||
|
||||
// Wrap and return
|
||||
return wrap(nodes, nodeRef);
|
||||
@@ -569,9 +557,9 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPosts(TopicInfo topic, PagingRequest paging)
|
||||
{
|
||||
// Do the listing
|
||||
// Do the listing, oldest first
|
||||
CannedQueryResults<NodeBackedEntity> nodes =
|
||||
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, paging);
|
||||
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, true, paging);
|
||||
|
||||
// Wrap and return
|
||||
return wrap(nodes, topic);
|
||||
@@ -611,13 +599,21 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
* type, optionally filtered by creator
|
||||
*/
|
||||
private CannedQueryResults<NodeBackedEntity> listEntries(NodeRef parent,
|
||||
QName nodeType, String creatorUsername, PagingRequest paging)
|
||||
QName nodeType, String creatorUsername, boolean oldestFirst, PagingRequest paging)
|
||||
{
|
||||
// Grab the factory
|
||||
GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
|
||||
|
||||
// Do the sorting, newest first by created date
|
||||
CannedQuerySortDetails sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails();
|
||||
// Do the sorting, newest first or last by created date (as requested)
|
||||
CannedQuerySortDetails sorting = null;
|
||||
if(oldestFirst)
|
||||
{
|
||||
sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails();
|
||||
}
|
||||
else
|
||||
{
|
||||
sorting = getChildrenCannedQueryFactory.createDateDescendingCQSortDetails();
|
||||
}
|
||||
|
||||
// Run the canned query
|
||||
GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
|
||||
|
Reference in New Issue
Block a user