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 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";
|
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
|
// Do a listing at the Node level, ordered by created date
|
||||||
// to get the most recent nodes
|
// to get the most recent nodes
|
||||||
NodeBackedEntity node = null;
|
PagingRequest paging = new PagingRequest(0, 1);
|
||||||
int skip = 0;
|
CannedQueryResults<NodeBackedEntity> results =
|
||||||
int pageSize = 10000;
|
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, false, paging);
|
||||||
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);
|
|
||||||
|
|
||||||
// Move to the next page if we're not at the end
|
// Bail if the topic lacks posts
|
||||||
if(results.hasMoreItems())
|
if(results.getPage().size() == 0)
|
||||||
{
|
{
|
||||||
skip += pageSize;
|
// No posts in the topic
|
||||||
continue;
|
return null;
|
||||||
}
|
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grab the newest node
|
||||||
|
NodeBackedEntity node = results.getPage().get(0);
|
||||||
|
|
||||||
// Wrap and return
|
// Wrap and return
|
||||||
return buildPost(node.getNodeRef(), topic, node.getName(), null);
|
return buildPost(node.getNodeRef(), topic, node.getName(), null);
|
||||||
}
|
}
|
||||||
@@ -558,9 +546,9 @@ public class DiscussionServiceImpl implements DiscussionService
|
|||||||
@Override
|
@Override
|
||||||
public PagingResults<TopicInfo> listTopics(NodeRef nodeRef,
|
public PagingResults<TopicInfo> listTopics(NodeRef nodeRef,
|
||||||
PagingRequest paging) {
|
PagingRequest paging) {
|
||||||
// Do the listing
|
// Do the listing, oldest first
|
||||||
CannedQueryResults<NodeBackedEntity> nodes =
|
CannedQueryResults<NodeBackedEntity> nodes =
|
||||||
listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, paging);
|
listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, true, paging);
|
||||||
|
|
||||||
// Wrap and return
|
// Wrap and return
|
||||||
return wrap(nodes, nodeRef);
|
return wrap(nodes, nodeRef);
|
||||||
@@ -569,9 +557,9 @@ public class DiscussionServiceImpl implements DiscussionService
|
|||||||
@Override
|
@Override
|
||||||
public PagingResults<PostInfo> listPosts(TopicInfo topic, PagingRequest paging)
|
public PagingResults<PostInfo> listPosts(TopicInfo topic, PagingRequest paging)
|
||||||
{
|
{
|
||||||
// Do the listing
|
// Do the listing, oldest first
|
||||||
CannedQueryResults<NodeBackedEntity> nodes =
|
CannedQueryResults<NodeBackedEntity> nodes =
|
||||||
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, paging);
|
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, true, paging);
|
||||||
|
|
||||||
// Wrap and return
|
// Wrap and return
|
||||||
return wrap(nodes, topic);
|
return wrap(nodes, topic);
|
||||||
@@ -611,13 +599,21 @@ public class DiscussionServiceImpl implements DiscussionService
|
|||||||
* type, optionally filtered by creator
|
* type, optionally filtered by creator
|
||||||
*/
|
*/
|
||||||
private CannedQueryResults<NodeBackedEntity> listEntries(NodeRef parent,
|
private CannedQueryResults<NodeBackedEntity> listEntries(NodeRef parent,
|
||||||
QName nodeType, String creatorUsername, PagingRequest paging)
|
QName nodeType, String creatorUsername, boolean oldestFirst, PagingRequest paging)
|
||||||
{
|
{
|
||||||
// Grab the factory
|
// Grab the factory
|
||||||
GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
|
GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
|
||||||
|
|
||||||
// Do the sorting, newest first by created date
|
// Do the sorting, newest first or last by created date (as requested)
|
||||||
CannedQuerySortDetails sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails();
|
CannedQuerySortDetails sorting = null;
|
||||||
|
if(oldestFirst)
|
||||||
|
{
|
||||||
|
sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sorting = getChildrenCannedQueryFactory.createDateDescendingCQSortDetails();
|
||||||
|
}
|
||||||
|
|
||||||
// Run the canned query
|
// Run the canned query
|
||||||
GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
|
GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
|
||||||
|
Reference in New Issue
Block a user