mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
On advice from Derek, pre-load node details when wrapping CQ results as higher level objects, for Calendar, Wiki, Links and Discussions
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29796 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
|
||||
<!-- Calendar Service base bean -->
|
||||
<bean id="calendarService" class="org.alfresco.repo.calendar.CalendarServiceImpl">
|
||||
<property name="nodeDAO" ref="nodeDAO" />
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
<property name="taggingService" ref="TaggingService"/>
|
||||
|
@@ -51,6 +51,7 @@
|
||||
|
||||
<!-- Links Service base bean -->
|
||||
<bean id="linksService" class="org.alfresco.repo.links.LinksServiceImpl">
|
||||
<property name="nodeDAO" ref="nodeDAO" />
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
|
@@ -51,6 +51,7 @@
|
||||
|
||||
<!-- Wiki Service base bean -->
|
||||
<bean id="wikiService" class="org.alfresco.repo.wiki.WikiServiceImpl">
|
||||
<property name="nodeDAO" ref="nodeDAO" />
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
<property name="contentService" ref="ContentService"/>
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.calendar.cannedqueries.GetCalendarEntriesCannedQuery;
|
||||
import org.alfresco.repo.calendar.cannedqueries.GetCalendarEntriesCannedQueryFactory;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
@@ -75,6 +76,7 @@ public class CalendarServiceImpl implements CalendarService
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(CalendarServiceImpl.class);
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private TaggingService taggingService;
|
||||
@@ -82,6 +84,11 @@ public class CalendarServiceImpl implements CalendarService
|
||||
private TransactionService transactionService;
|
||||
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -320,6 +327,10 @@ public class CalendarServiceImpl implements CalendarService
|
||||
*/
|
||||
private PagingResults<CalendarEntry> wrap(final PagingResults<NodeRef> results, final NodeRef container)
|
||||
{
|
||||
// Pre-load the nodes before we create them
|
||||
nodeDAO.cacheNodes(results.getPage());
|
||||
|
||||
// Wrap
|
||||
return new PagingResults<CalendarEntry>()
|
||||
{
|
||||
@Override
|
||||
|
@@ -33,12 +33,14 @@ import org.alfresco.query.CannedQuerySortDetails;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQuery;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.discussion.DiscussionService;
|
||||
import org.alfresco.service.cmr.discussion.PostInfo;
|
||||
import org.alfresco.service.cmr.discussion.PostWithReplies;
|
||||
import org.alfresco.service.cmr.discussion.TopicInfo;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -72,6 +74,7 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(DiscussionServiceImpl.class);
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private ContentService contentService;
|
||||
@@ -80,6 +83,11 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
private TransactionService transactionService;
|
||||
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -567,19 +575,24 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
|
||||
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPostReplies(PostInfo primaryPost,
|
||||
int levels, PagingRequest paging) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public PostWithReplies listPostReplies(TopicInfo topic, int levels)
|
||||
{
|
||||
PostInfo primaryPost = getPrimaryPost(topic);
|
||||
if(primaryPost == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return listPostReplies(primaryPost, levels);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPostReplies(TopicInfo forum, int levels,
|
||||
PagingRequest paging) {
|
||||
public PostWithReplies listPostReplies(PostInfo primaryPost, int levels)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPosts(NodeRef nodeRef,
|
||||
PagingRequest paging) {
|
||||
@@ -633,6 +646,15 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
*/
|
||||
private PagingResults<TopicInfo> wrap(final PagingResults<NodeBackedEntity> results, final NodeRef container)
|
||||
{
|
||||
// Pre-load the nodes before we create them
|
||||
List<Long> ids = new ArrayList<Long>();
|
||||
for(NodeBackedEntity node : results.getPage())
|
||||
{
|
||||
ids.add(node.getId());
|
||||
}
|
||||
nodeDAO.cacheNodesById(ids);
|
||||
|
||||
// Wrap
|
||||
return new PagingResults<TopicInfo>()
|
||||
{
|
||||
@Override
|
||||
@@ -671,6 +693,15 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
*/
|
||||
private PagingResults<PostInfo> wrap(final PagingResults<NodeBackedEntity> results, final TopicInfo topic)
|
||||
{
|
||||
// Pre-load the nodes before we create them
|
||||
List<Long> ids = new ArrayList<Long>();
|
||||
for(NodeBackedEntity node : results.getPage())
|
||||
{
|
||||
ids.add(node.getId());
|
||||
}
|
||||
nodeDAO.cacheNodesById(ids);
|
||||
|
||||
// Wrap
|
||||
return new PagingResults<PostInfo>()
|
||||
{
|
||||
@Override
|
||||
|
@@ -31,6 +31,7 @@ import org.alfresco.query.CannedQueryResults;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQuery;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
@@ -74,6 +75,7 @@ public class LinksServiceImpl implements LinksService
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(LinksServiceImpl.class);
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private SearchService searchService;
|
||||
@@ -83,6 +85,11 @@ public class LinksServiceImpl implements LinksService
|
||||
private TransactionService transactionService;
|
||||
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -446,6 +453,15 @@ public class LinksServiceImpl implements LinksService
|
||||
*/
|
||||
private PagingResults<LinkInfo> wrap(final PagingResults<NodeBackedEntity> results, final NodeRef container)
|
||||
{
|
||||
// Pre-load the nodes before we create them
|
||||
List<Long> ids = new ArrayList<Long>();
|
||||
for(NodeBackedEntity node : results.getPage())
|
||||
{
|
||||
ids.add(node.getId());
|
||||
}
|
||||
nodeDAO.cacheNodesById(ids);
|
||||
|
||||
// Wrap
|
||||
return new PagingResults<LinkInfo>()
|
||||
{
|
||||
@Override
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.query.CannedQuerySortDetails;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQuery;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
@@ -71,6 +72,7 @@ public class WikiServiceImpl implements WikiService
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(WikiServiceImpl.class);
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private ContentService contentService;
|
||||
@@ -79,6 +81,11 @@ public class WikiServiceImpl implements WikiService
|
||||
private TransactionService transactionService;
|
||||
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -341,6 +348,15 @@ public class WikiServiceImpl implements WikiService
|
||||
*/
|
||||
private PagingResults<WikiPageInfo> wrap(final PagingResults<NodeBackedEntity> results, final NodeRef container)
|
||||
{
|
||||
// Pre-load the nodes before we create them
|
||||
List<Long> ids = new ArrayList<Long>();
|
||||
for(NodeBackedEntity node : results.getPage())
|
||||
{
|
||||
ids.add(node.getId());
|
||||
}
|
||||
nodeDAO.cacheNodesById(ids);
|
||||
|
||||
// Wrap
|
||||
return new PagingResults<WikiPageInfo>()
|
||||
{
|
||||
@Override
|
||||
|
@@ -174,13 +174,13 @@ public interface DiscussionService {
|
||||
* Retrieves all replies on a Topic
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingResults<PostInfo> listPostReplies(TopicInfo forum, int levels, PagingRequest paging);
|
||||
PostWithReplies listPostReplies(TopicInfo forum, int levels);
|
||||
|
||||
/**
|
||||
* Retrieves all replies to a Post
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingResults<PostInfo> listPostReplies(PostInfo primaryPost, int levels, PagingRequest paging);
|
||||
PostWithReplies listPostReplies(PostInfo primaryPost, int levels);
|
||||
|
||||
/**
|
||||
* Retrieves all posts in a site, across all topics
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.discussion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.security.permissions.PermissionCheckValue;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* This class holds a post and all replies to it, possibly nested.
|
||||
*
|
||||
* This is used with {@link DiscussionService#listPostReplies(PostWithReplies, int, org.alfresco.query.PagingRequest)}
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class PostWithReplies implements PermissionCheckValue
|
||||
{
|
||||
private PostInfo post;
|
||||
private List<PostWithReplies> replies;
|
||||
|
||||
public PostWithReplies(PostInfo post, List<PostWithReplies> replies)
|
||||
{
|
||||
this.post = post;
|
||||
this.replies = replies;
|
||||
}
|
||||
|
||||
public PostInfo getPost()
|
||||
{
|
||||
return post;
|
||||
}
|
||||
|
||||
public List<PostWithReplies> getReplies()
|
||||
{
|
||||
return replies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return post.getNodeRef();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user