mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9155 Canned query for links and wiki finding
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29524 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.AbstractCannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryPageDetails;
|
||||
import org.alfresco.query.CannedQuerySortDetails;
|
||||
@@ -32,7 +33,6 @@ import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -202,6 +202,45 @@ public abstract class AbstractQNameAwareCannedQueryFactory<R> extends AbstractCa
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of a {@link PropertyBasedComparator} for a {@link NodeBackedEntity}
|
||||
*/
|
||||
public static class NodeBackedEntityComparator extends PropertyBasedComparator<NodeBackedEntity>
|
||||
{
|
||||
public NodeBackedEntityComparator(QName comparableProperty)
|
||||
{
|
||||
super(comparableProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Comparable getProperty(NodeBackedEntity entity) {
|
||||
if (comparableProperty.equals(ContentModel.PROP_CREATED))
|
||||
{
|
||||
return entity.getCreatedDate();
|
||||
}
|
||||
else if (comparableProperty.equals(ContentModel.PROP_MODIFIED))
|
||||
{
|
||||
return entity.getModifiedDate();
|
||||
}
|
||||
else if (comparableProperty.equals(ContentModel.PROP_CREATOR))
|
||||
{
|
||||
return entity.getCreator();
|
||||
}
|
||||
else if (comparableProperty.equals(ContentModel.PROP_MODIFIER))
|
||||
{
|
||||
return entity.getModifier();
|
||||
}
|
||||
else if (comparableProperty.equals(ContentModel.PROP_NAME))
|
||||
{
|
||||
return entity.getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Unsupported calendar sort property: "+comparableProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class NestedComparator<R> implements Comparator<R>
|
||||
{
|
||||
private List<Pair<Comparator<R>, SortOrder>> comparators;
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.repo.query;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeEntity;
|
||||
import org.alfresco.repo.security.permissions.PermissionCheckValue;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -28,13 +29,16 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class NodeBackedEntity
|
||||
public class NodeBackedEntity implements PermissionCheckValue
|
||||
{
|
||||
private Long id; // node id
|
||||
|
||||
private String name;
|
||||
private NodeEntity node;
|
||||
|
||||
private String name;
|
||||
// Supplemental query-related parameters
|
||||
private Long parentNodeId;
|
||||
private Long nameQNameId;
|
||||
private Long contentTypeQNameId;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -43,6 +47,16 @@ public abstract class NodeBackedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query constructor
|
||||
*/
|
||||
public NodeBackedEntity(Long parentNodeId, Long nameQNameId, Long contentTypeQNameId)
|
||||
{
|
||||
this.parentNodeId = parentNodeId;
|
||||
this.nameQNameId = nameQNameId;
|
||||
this.contentTypeQNameId = contentTypeQNameId;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
@@ -71,6 +85,18 @@ public abstract class NodeBackedEntity
|
||||
return ((node != null && node.getAuditableProperties() != null) ? node.getAuditableProperties().getAuditCreator() : null);
|
||||
}
|
||||
|
||||
// helper (ISO 8061)
|
||||
public String getModifiedDate()
|
||||
{
|
||||
return ((node != null && node.getAuditableProperties() != null) ? node.getAuditableProperties().getAuditModified() : null);
|
||||
}
|
||||
|
||||
// helper
|
||||
public String getModifier()
|
||||
{
|
||||
return ((node != null && node.getAuditableProperties() != null) ? node.getAuditableProperties().getAuditModifier() : null);
|
||||
}
|
||||
|
||||
public NodeEntity getNode()
|
||||
{
|
||||
return node;
|
||||
@@ -90,4 +116,22 @@ public abstract class NodeBackedEntity
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
// Supplemental query-related parameters
|
||||
|
||||
public Long getParentNodeId()
|
||||
{
|
||||
return parentNodeId;
|
||||
}
|
||||
|
||||
public Long getNameQNameId()
|
||||
{
|
||||
return nameQNameId;
|
||||
}
|
||||
|
||||
public Long getContentTypeQNameId()
|
||||
{
|
||||
return contentTypeQNameId;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user