mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9153 Start on the discussion replies CQ
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29831 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,8 +49,19 @@
|
||||
<property name="methodSecurity" ref="DiscussionService_security_listPosts"/>
|
||||
</bean>
|
||||
|
||||
<!-- The GetChildren Auditable with Target Assocs Canned Query Factory -->
|
||||
<bean name="discussionGetChildrenWithTargetAssocsAuditableCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenWithTargetAssocsAuditableCannedQueryFactory">
|
||||
<property name="registry" ref="discussionCannedQueryRegistry"/>
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<property name="nodeDAO" ref="nodeDAO"/>
|
||||
<property name="qnameDAO" ref="qnameDAO"/>
|
||||
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||
<property name="methodSecurity" ref="DiscussionService_security_listPosts"/>
|
||||
</bean>
|
||||
|
||||
<!-- Discussion Service base bean -->
|
||||
<bean id="discussionService" class="org.alfresco.repo.discussion.DiscussionServiceImpl">
|
||||
<property name="nodeDAO" ref="nodeDAO" />
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
<property name="contentService" ref="ContentService"/>
|
||||
|
@@ -71,6 +71,7 @@ Inbound settings from iBatis
|
||||
|
||||
<!--GetChildren by Auditable CQ -->
|
||||
<typeAlias alias="NodeBackedEntity" type="org.alfresco.repo.query.NodeBackedEntity"/>
|
||||
<typeAlias alias="NodeWithTargetsEntity" type="org.alfresco.repo.query.NodeWithTargetsEntity"/>
|
||||
|
||||
<!-- Authority CQ -->
|
||||
<typeAlias alias="AuthorityInfo" type="org.alfresco.repo.security.authority.AuthorityInfoEntity"/>
|
||||
|
@@ -14,6 +14,15 @@
|
||||
<association property="node" resultMap="alfresco.node.result_Node"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="result_NodeWithTargetsEntity" type="NodeWithTargetsEntity">
|
||||
<id property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
<association property="node" resultMap="alfresco.node.result_Node"/>
|
||||
<collection property="targetIds" column="target_node_id" jdbcType="BIGINT" javaType="ArrayList" ofType="java.lang.Long"/>
|
||||
<collection property="targetAssocTypeIds" column="target_assoc_type_id" jdbcType="BIGINT" javaType="ArrayList" ofType="java.lang.Long"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- GetChildrenAuditable Canned Query (model-specific) - note: date properties are stored as ISO 8061 string -->
|
||||
|
||||
<select id="select_GetChildrenAuditableCannedQuery" parameterType="NodeBackedEntity" resultMap="result_NodeBackedEntity">
|
||||
@@ -37,4 +46,33 @@
|
||||
and childNode.type_qname_id = #{contentTypeQNameId}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- GetChildrenWithTargetAssocsAuditable Canned Query (model-specific) - note: date properties are stored as ISO 8061 string -->
|
||||
|
||||
<select id="select_GetChildrenWithTargetAssocsAuditableCannedQuery" parameterType="NodeWithTargetsEntity" resultMap="result_NodeWithTargetsEntity">
|
||||
select
|
||||
childNode.id as id,
|
||||
childStore.protocol as protocol,
|
||||
childStore.identifier as identifier,
|
||||
childNode.uuid as uuid,
|
||||
childNode.audit_created as audit_created,
|
||||
childNode.audit_creator as audit_creator,
|
||||
childNode.audit_modified as audit_modified,
|
||||
childNode.audit_modifier as audit_modifier,
|
||||
prop_name.string_value as name,
|
||||
targetAssoc.parent_node_id as target_node_id,
|
||||
targetAssoc.type_qname_id as target_assoc_type_id
|
||||
from
|
||||
alf_child_assoc assoc
|
||||
join alf_node childNode on (childNode.id = assoc.child_node_id)
|
||||
join alf_store childStore on (childStore.id = childNode.store_id)
|
||||
left join alf_node_properties prop_name on (prop_name.node_id = childNode.id and prop_name.qname_id = #{nameQNameId})
|
||||
left join alf_child_assoc targetAssoc on (childNode.id = targetAssoc.child_node_id)
|
||||
where
|
||||
assoc.parent_node_id = #{parentNodeId}
|
||||
and childNode.type_qname_id = #{contentTypeQNameId}
|
||||
<if test="assocTypeId != null">
|
||||
and targetAssoc.type_qname_id = #{assocTypeId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -36,7 +36,10 @@ 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.node.getchildren.GetChildrenWithTargetAssocsAuditableCannedQuery;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenWithTargetAssocsAuditableCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
import org.alfresco.repo.query.NodeWithTargetsEntity;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.discussion.DiscussionService;
|
||||
import org.alfresco.service.cmr.discussion.PostInfo;
|
||||
@@ -67,6 +70,8 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
public static final String DISCUSSION_COMPONENT = "discussions";
|
||||
|
||||
protected static final String CANNED_QUERY_GET_CHILDREN = "discussionGetChildrenCannedQueryFactory";
|
||||
protected static final String CANNED_QUERY_GET_CHILDREN_TARGETS = "discussionGetChildrenWithTargetAssocsAuditableCannedQueryFactory";
|
||||
protected static final int MAX_REPLIES_FETCH_SIZE = 1000;
|
||||
|
||||
/**
|
||||
* The logger
|
||||
@@ -588,7 +593,25 @@ public class DiscussionServiceImpl implements DiscussionService
|
||||
@Override
|
||||
public PostWithReplies listPostReplies(PostInfo primaryPost, int levels)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
// Grab the factory
|
||||
GetChildrenWithTargetAssocsAuditableCannedQueryFactory cqFactory = (GetChildrenWithTargetAssocsAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN_TARGETS);
|
||||
|
||||
// Sort by date
|
||||
CannedQuerySortDetails sorting = cqFactory.createDateAscendingCQSortDetails();
|
||||
|
||||
// Run the canned query
|
||||
GetChildrenWithTargetAssocsAuditableCannedQuery cq = (GetChildrenWithTargetAssocsAuditableCannedQuery)cqFactory.getCannedQuery(
|
||||
primaryPost.getTopic().getNodeRef(), ForumModel.TYPE_POST,
|
||||
ContentModel.ASSOC_REFERENCES, sorting, new PagingRequest(MAX_REPLIES_FETCH_SIZE));
|
||||
|
||||
// Execute the canned query
|
||||
CannedQueryResults<NodeWithTargetsEntity> results = cq.execute();
|
||||
|
||||
// Prepare to invert
|
||||
// TODO
|
||||
Map<Long,NodeRef> idToNode = new HashMap<Long, NodeRef>();
|
||||
|
||||
// All done
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -672,6 +672,24 @@ public class DiscussionServiceImplTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the listing / nesting of replies is correct
|
||||
*/
|
||||
@Test public void replyListing() throws Exception
|
||||
{
|
||||
// Create two sites and test
|
||||
TopicInfo siteT1 = DISCUSSION_SERVICE.createTopic(DISCUSSION_SITE.getShortName(), "ST1");
|
||||
TopicInfo nodeT1 = DISCUSSION_SERVICE.createTopic(FORUM_NODE, "NT1");
|
||||
testNodesToTidy.add(siteT1.getNodeRef());
|
||||
testNodesToTidy.add(nodeT1.getNodeRef());
|
||||
|
||||
for(TopicInfo topic : new TopicInfo[] {siteT1, nodeT1})
|
||||
{
|
||||
// Listing initially gives nothing
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that when we try to write an entry to the
|
||||
* container of a new site, it is correctly setup for us.
|
||||
|
@@ -18,9 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.node.getchildren;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQuery;
|
||||
@@ -29,12 +27,10 @@ import org.alfresco.query.CannedQueryPageDetails;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.query.CannedQuerySortDetails;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||
import org.alfresco.repo.query.AbstractQNameAwareCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
@@ -91,22 +87,4 @@ public class GetChildrenAuditableCannedQueryFactory extends AbstractQNameAwareCa
|
||||
// return canned query instance
|
||||
return getCannedQuery(params);
|
||||
}
|
||||
|
||||
public CannedQuerySortDetails createDateAscendingCQSortDetails()
|
||||
{
|
||||
List<Pair<? extends Object,SortOrder>> sort = new ArrayList<Pair<? extends Object, SortOrder>>();
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_CREATED, SortOrder.ASCENDING));
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_MODIFIED, SortOrder.ASCENDING));
|
||||
|
||||
return new CannedQuerySortDetails(sort);
|
||||
}
|
||||
|
||||
public CannedQuerySortDetails createDateDescendingCQSortDetails()
|
||||
{
|
||||
List<Pair<? extends Object,SortOrder>> sort = new ArrayList<Pair<? extends Object, SortOrder>>();
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_CREATED, SortOrder.DESCENDING));
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_MODIFIED, SortOrder.DESCENDING));
|
||||
|
||||
return new CannedQuerySortDetails(sort);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.repo.node.getchildren;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.query.CannedQuery;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||
import org.alfresco.repo.query.NodeBackedEntity;
|
||||
import org.alfresco.repo.query.NodeWithTargetsEntity;
|
||||
import org.alfresco.repo.query.AbstractQNameAwareCannedQueryFactory.NestedComparator;
|
||||
import org.alfresco.repo.query.AbstractQNameAwareCannedQueryFactory.NodeBackedEntityComparator;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* This class provides support for {@link CannedQuery canned queries} which
|
||||
* filter by Auditable Properties and Target Assocs
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class GetChildrenWithTargetAssocsAuditableCannedQuery extends AbstractCannedQueryPermissions<NodeWithTargetsEntity>
|
||||
{
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private static final String QUERY_NAMESPACE = "alfresco.query.auditable";
|
||||
private static final String QUERY_SELECT_GET_NODES = "select_GetChildrenWithTargetAssocsAuditableCannedQuery";
|
||||
|
||||
private final CannedQueryDAO cannedQueryDAO;
|
||||
|
||||
public GetChildrenWithTargetAssocsAuditableCannedQuery(
|
||||
CannedQueryDAO cannedQueryDAO,
|
||||
MethodSecurityBean<NodeWithTargetsEntity> methodSecurity,
|
||||
CannedQueryParameters params)
|
||||
{
|
||||
super(params, methodSecurity);
|
||||
this.cannedQueryDAO = cannedQueryDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<NodeWithTargetsEntity> queryAndFilter(CannedQueryParameters parameters)
|
||||
{
|
||||
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
|
||||
|
||||
Object paramBeanObj = parameters.getParameterBean();
|
||||
if (paramBeanObj == null)
|
||||
throw new NullPointerException("Null GetChildrenWithTargetAssocsAuditable query params");
|
||||
|
||||
GetChildrenWithTargetAssocsAuditableCannedQueryParams paramBean = (GetChildrenWithTargetAssocsAuditableCannedQueryParams) paramBeanObj;
|
||||
|
||||
// note: refer to SQL for specific DB filtering (eg.parent nodes etc)
|
||||
List<NodeWithTargetsEntity> results = cannedQueryDAO.executeQuery(QUERY_NAMESPACE, QUERY_SELECT_GET_NODES, paramBean, 0, Integer.MAX_VALUE);
|
||||
|
||||
List<NodeWithTargetsEntity> filtered = new ArrayList<NodeWithTargetsEntity>(results.size());
|
||||
for (NodeWithTargetsEntity result : results)
|
||||
{
|
||||
boolean nextNodeIsAcceptable = true;
|
||||
|
||||
// Note - all filtering is currently done in the database
|
||||
|
||||
// Did it make the cut
|
||||
if (nextNodeIsAcceptable)
|
||||
{
|
||||
filtered.add(result);
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<? extends Object, SortOrder>> sortPairs = parameters.getSortDetails().getSortPairs();
|
||||
|
||||
// Do the sorting
|
||||
if (sortPairs != null && !sortPairs.isEmpty())
|
||||
{
|
||||
List<Pair<Comparator<NodeBackedEntity>, SortOrder>> comparators =
|
||||
new ArrayList<Pair<Comparator<NodeBackedEntity>,SortOrder>>();
|
||||
for(Pair<? extends Object, SortOrder> sortPair : sortPairs)
|
||||
{
|
||||
final QName sortProperty = (QName)sortPair.getFirst();
|
||||
final NodeBackedEntityComparator comparator = new NodeBackedEntityComparator(sortProperty);
|
||||
comparators.add(new Pair<Comparator<NodeBackedEntity>, SortOrder>(comparator, sortPair.getSecond()));
|
||||
}
|
||||
NestedComparator<NodeBackedEntity> comparator = new NestedComparator<NodeBackedEntity>(comparators);
|
||||
|
||||
// Sort
|
||||
Collections.sort(filtered, comparator);
|
||||
}
|
||||
|
||||
if (start != null)
|
||||
{
|
||||
logger.debug("Base query: "+filtered.size()+" in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isApplyPostQuerySorting()
|
||||
{
|
||||
// No post-query sorting. It's done within the queryAndFilter() method above.
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.repo.node.getchildren;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQuery;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryPageDetails;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.query.CannedQuerySortDetails;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.repo.query.AbstractQNameAwareCannedQueryFactory;
|
||||
import org.alfresco.repo.query.NodeWithTargetsEntity;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* A {@link CannedQueryFactory} for various queries relating to getting
|
||||
* {@link NodeWithTargetsEntity} entires filtering by auditable properties.
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class GetChildrenWithTargetAssocsAuditableCannedQueryFactory extends AbstractQNameAwareCannedQueryFactory<NodeWithTargetsEntity>
|
||||
{
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CannedQuery<NodeWithTargetsEntity> getCannedQuery(CannedQueryParameters parameters)
|
||||
{
|
||||
final GetChildrenWithTargetAssocsAuditableCannedQuery cq = new GetChildrenWithTargetAssocsAuditableCannedQuery(
|
||||
cannedQueryDAO, methodSecurity, parameters
|
||||
);
|
||||
|
||||
return (CannedQuery<NodeWithTargetsEntity>) cq;
|
||||
}
|
||||
|
||||
public CannedQuery<NodeWithTargetsEntity> getCannedQuery(NodeRef parentNodeRef,
|
||||
QName contentType, QName assocType,
|
||||
CannedQuerySortDetails sortDetails, PagingRequest pagingReq)
|
||||
{
|
||||
ParameterCheck.mandatory("parentNodeRef", parentNodeRef);
|
||||
ParameterCheck.mandatory("contentType", contentType);
|
||||
ParameterCheck.mandatory("pagingReq", pagingReq);
|
||||
|
||||
int requestTotalCountMax = pagingReq.getRequestTotalCountMax();
|
||||
|
||||
//FIXME Need tenant service like for GetChildren?
|
||||
GetChildrenWithTargetAssocsAuditableCannedQueryParams paramBean = new GetChildrenWithTargetAssocsAuditableCannedQueryParams(
|
||||
getNodeId(parentNodeRef),
|
||||
getQNameId(ContentModel.PROP_NAME),
|
||||
getQNameId(contentType),
|
||||
getQNameId(assocType)
|
||||
);
|
||||
|
||||
CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq);
|
||||
|
||||
// create query params holder
|
||||
CannedQueryParameters params = new CannedQueryParameters(
|
||||
paramBean, cqpd, sortDetails, requestTotalCountMax, pagingReq.getQueryExecutionId());
|
||||
|
||||
// return canned query instance
|
||||
return getCannedQuery(params);
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.repo.node.getchildren;
|
||||
|
||||
import org.alfresco.repo.query.NodeWithTargetsEntity;
|
||||
|
||||
/**
|
||||
* Parameter objects for {@link GetChildrenWithTargetAssocsAuditableCannedQuery}.
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class GetChildrenWithTargetAssocsAuditableCannedQueryParams extends NodeWithTargetsEntity
|
||||
{
|
||||
public GetChildrenWithTargetAssocsAuditableCannedQueryParams(Long parentNodeId,
|
||||
Long nameQNameId,
|
||||
Long contentTypeQNameId,
|
||||
Long assocTypeId)
|
||||
|
||||
{
|
||||
super(parentNodeId, nameQNameId, contentTypeQNameId, assocTypeId);
|
||||
}
|
||||
}
|
@@ -155,6 +155,24 @@ public abstract class AbstractQNameAwareCannedQueryFactory<R> extends AbstractCa
|
||||
return nodePair.getFirst();
|
||||
}
|
||||
|
||||
public CannedQuerySortDetails createDateAscendingCQSortDetails()
|
||||
{
|
||||
List<Pair<? extends Object,SortOrder>> sort = new ArrayList<Pair<? extends Object, SortOrder>>();
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_CREATED, SortOrder.ASCENDING));
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_MODIFIED, SortOrder.ASCENDING));
|
||||
|
||||
return new CannedQuerySortDetails(sort);
|
||||
}
|
||||
|
||||
public CannedQuerySortDetails createDateDescendingCQSortDetails()
|
||||
{
|
||||
List<Pair<? extends Object,SortOrder>> sort = new ArrayList<Pair<? extends Object, SortOrder>>();
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_CREATED, SortOrder.DESCENDING));
|
||||
sort.add(new Pair<QName, SortOrder>(ContentModel.PROP_MODIFIED, SortOrder.DESCENDING));
|
||||
|
||||
return new CannedQuerySortDetails(sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class to sort Entities on the basis of a Comparable property.
|
||||
* Comparisons of two null properties are considered 'equal' by this comparator.
|
||||
@@ -212,6 +230,7 @@ public abstract class AbstractQNameAwareCannedQueryFactory<R> extends AbstractCa
|
||||
super(comparableProperty);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Comparable getProperty(NodeBackedEntity entity) {
|
||||
if (comparableProperty.equals(ContentModel.PROP_CREATED))
|
||||
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.repo.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeEntity;
|
||||
|
||||
/**
|
||||
* Parent class of Canned Query Entities which are a
|
||||
* {@link NodeEntity} with additional properties
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class NodeWithTargetsEntity extends NodeBackedEntity
|
||||
{
|
||||
private List<Long> targetIds;
|
||||
private List<Long> targetAssocTypeIds;
|
||||
|
||||
// Supplemental query-related parameters
|
||||
private Long assocTypeId;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public NodeWithTargetsEntity()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query constructor
|
||||
*/
|
||||
public NodeWithTargetsEntity(Long parentNodeId, Long nameQNameId, Long contentTypeQNameId, Long assocTypeId)
|
||||
{
|
||||
super(parentNodeId, nameQNameId, contentTypeQNameId);
|
||||
this.assocTypeId = assocTypeId;
|
||||
}
|
||||
|
||||
public List<Long> getTargetIds()
|
||||
{
|
||||
return targetIds;
|
||||
}
|
||||
|
||||
public void setTargetIds(List<Long> targetIds)
|
||||
{
|
||||
this.targetIds = targetIds;
|
||||
}
|
||||
|
||||
public List<Long> getTargetAssocTypeIds()
|
||||
{
|
||||
return targetAssocTypeIds;
|
||||
}
|
||||
|
||||
public void setTargetAssocTypeIds(List<Long> targetAssocTypeIds)
|
||||
{
|
||||
this.targetAssocTypeIds = targetAssocTypeIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* If set, the ID of the assocation type to limit
|
||||
* the target assocs to.
|
||||
*/
|
||||
public Long getAssocTypeId()
|
||||
{
|
||||
return assocTypeId;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user