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:
Nick Burch
2011-08-16 14:59:58 +00:00
parent 4d361282bd
commit 9f67fd6ded
9 changed files with 146 additions and 9 deletions

View File

@@ -66,6 +66,7 @@
<!-- Calendar Service base bean --> <!-- Calendar Service base bean -->
<bean id="calendarService" class="org.alfresco.repo.calendar.CalendarServiceImpl"> <bean id="calendarService" class="org.alfresco.repo.calendar.CalendarServiceImpl">
<property name="nodeDAO" ref="nodeDAO" />
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="siteService" ref="SiteService"/> <property name="siteService" ref="SiteService"/>
<property name="taggingService" ref="TaggingService"/> <property name="taggingService" ref="TaggingService"/>

View File

@@ -51,6 +51,7 @@
<!-- Links Service base bean --> <!-- Links Service base bean -->
<bean id="linksService" class="org.alfresco.repo.links.LinksServiceImpl"> <bean id="linksService" class="org.alfresco.repo.links.LinksServiceImpl">
<property name="nodeDAO" ref="nodeDAO" />
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="siteService" ref="SiteService"/> <property name="siteService" ref="SiteService"/>
<property name="searchService" ref="SearchService"/> <property name="searchService" ref="SearchService"/>

View File

@@ -51,6 +51,7 @@
<!-- Wiki Service base bean --> <!-- Wiki Service base bean -->
<bean id="wikiService" class="org.alfresco.repo.wiki.WikiServiceImpl"> <bean id="wikiService" class="org.alfresco.repo.wiki.WikiServiceImpl">
<property name="nodeDAO" ref="nodeDAO" />
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="siteService" ref="SiteService"/> <property name="siteService" ref="SiteService"/>
<property name="contentService" ref="ContentService"/> <property name="contentService" ref="ContentService"/>

View File

@@ -34,6 +34,7 @@ import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; import org.alfresco.query.PagingResults;
import org.alfresco.repo.calendar.cannedqueries.GetCalendarEntriesCannedQuery; import org.alfresco.repo.calendar.cannedqueries.GetCalendarEntriesCannedQuery;
import org.alfresco.repo.calendar.cannedqueries.GetCalendarEntriesCannedQueryFactory; 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.GetChildrenCannedQuery;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory; import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
import org.alfresco.repo.site.SiteServiceImpl; import org.alfresco.repo.site.SiteServiceImpl;
@@ -75,6 +76,7 @@ public class CalendarServiceImpl implements CalendarService
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(CalendarServiceImpl.class); private static Log logger = LogFactory.getLog(CalendarServiceImpl.class);
private NodeDAO nodeDAO;
private NodeService nodeService; private NodeService nodeService;
private SiteService siteService; private SiteService siteService;
private TaggingService taggingService; private TaggingService taggingService;
@@ -82,6 +84,11 @@ public class CalendarServiceImpl implements CalendarService
private TransactionService transactionService; private TransactionService transactionService;
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry; private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.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) 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>() return new PagingResults<CalendarEntry>()
{ {
@Override @Override

View File

@@ -33,12 +33,14 @@ import org.alfresco.query.CannedQuerySortDetails;
import org.alfresco.query.EmptyPagingResults; import org.alfresco.query.EmptyPagingResults;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; 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.GetChildrenAuditableCannedQuery;
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory; import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
import org.alfresco.repo.query.NodeBackedEntity; import org.alfresco.repo.query.NodeBackedEntity;
import org.alfresco.repo.site.SiteServiceImpl; import org.alfresco.repo.site.SiteServiceImpl;
import org.alfresco.service.cmr.discussion.DiscussionService; import org.alfresco.service.cmr.discussion.DiscussionService;
import org.alfresco.service.cmr.discussion.PostInfo; 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.discussion.TopicInfo;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -72,6 +74,7 @@ public class DiscussionServiceImpl implements DiscussionService
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(DiscussionServiceImpl.class); private static Log logger = LogFactory.getLog(DiscussionServiceImpl.class);
private NodeDAO nodeDAO;
private NodeService nodeService; private NodeService nodeService;
private SiteService siteService; private SiteService siteService;
private ContentService contentService; private ContentService contentService;
@@ -80,6 +83,11 @@ public class DiscussionServiceImpl implements DiscussionService
private TransactionService transactionService; private TransactionService transactionService;
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry; private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
@@ -567,19 +575,24 @@ public class DiscussionServiceImpl implements DiscussionService
@Override @Override
public PagingResults<PostInfo> listPostReplies(PostInfo primaryPost, public PostWithReplies listPostReplies(TopicInfo topic, int levels)
int levels, PagingRequest paging) { {
// TODO Auto-generated method stub PostInfo primaryPost = getPrimaryPost(topic);
return null; if(primaryPost == null)
{
return null;
}
return listPostReplies(primaryPost, levels);
} }
@Override @Override
public PagingResults<PostInfo> listPostReplies(TopicInfo forum, int levels, public PostWithReplies listPostReplies(PostInfo primaryPost, int levels)
PagingRequest paging) { {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public PagingResults<PostInfo> listPosts(NodeRef nodeRef, public PagingResults<PostInfo> listPosts(NodeRef nodeRef,
PagingRequest paging) { PagingRequest paging) {
@@ -633,6 +646,15 @@ public class DiscussionServiceImpl implements DiscussionService
*/ */
private PagingResults<TopicInfo> wrap(final PagingResults<NodeBackedEntity> results, final NodeRef container) 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>() return new PagingResults<TopicInfo>()
{ {
@Override @Override
@@ -671,6 +693,15 @@ public class DiscussionServiceImpl implements DiscussionService
*/ */
private PagingResults<PostInfo> wrap(final PagingResults<NodeBackedEntity> results, final TopicInfo topic) 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>() return new PagingResults<PostInfo>()
{ {
@Override @Override

View File

@@ -31,6 +31,7 @@ import org.alfresco.query.CannedQueryResults;
import org.alfresco.query.EmptyPagingResults; import org.alfresco.query.EmptyPagingResults;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; 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.GetChildrenAuditableCannedQuery;
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory; import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
import org.alfresco.repo.query.NodeBackedEntity; import org.alfresco.repo.query.NodeBackedEntity;
@@ -74,6 +75,7 @@ public class LinksServiceImpl implements LinksService
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(LinksServiceImpl.class); private static Log logger = LogFactory.getLog(LinksServiceImpl.class);
private NodeDAO nodeDAO;
private NodeService nodeService; private NodeService nodeService;
private SiteService siteService; private SiteService siteService;
private SearchService searchService; private SearchService searchService;
@@ -83,6 +85,11 @@ public class LinksServiceImpl implements LinksService
private TransactionService transactionService; private TransactionService transactionService;
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry; private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.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) 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>() return new PagingResults<LinkInfo>()
{ {
@Override @Override

View File

@@ -33,6 +33,7 @@ import org.alfresco.query.CannedQuerySortDetails;
import org.alfresco.query.EmptyPagingResults; import org.alfresco.query.EmptyPagingResults;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; 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.GetChildrenAuditableCannedQuery;
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory; import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
import org.alfresco.repo.query.NodeBackedEntity; import org.alfresco.repo.query.NodeBackedEntity;
@@ -71,6 +72,7 @@ public class WikiServiceImpl implements WikiService
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(WikiServiceImpl.class); private static Log logger = LogFactory.getLog(WikiServiceImpl.class);
private NodeDAO nodeDAO;
private NodeService nodeService; private NodeService nodeService;
private SiteService siteService; private SiteService siteService;
private ContentService contentService; private ContentService contentService;
@@ -79,6 +81,11 @@ public class WikiServiceImpl implements WikiService
private TransactionService transactionService; private TransactionService transactionService;
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry; private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.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) 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>() return new PagingResults<WikiPageInfo>()
{ {
@Override @Override

View File

@@ -174,13 +174,13 @@ public interface DiscussionService {
* Retrieves all replies on a Topic * Retrieves all replies on a Topic
*/ */
@NotAuditable @NotAuditable
PagingResults<PostInfo> listPostReplies(TopicInfo forum, int levels, PagingRequest paging); PostWithReplies listPostReplies(TopicInfo forum, int levels);
/** /**
* Retrieves all replies to a Post * Retrieves all replies to a Post
*/ */
@NotAuditable @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 * Retrieves all posts in a site, across all topics

View File

@@ -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();
}
}