mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added support for paging using SearchParameters on the SearchService API (ARCHIVE-85)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14651 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -63,11 +63,11 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
Query query;
|
||||
|
||||
CMISDictionaryService cmisDictionaryService;
|
||||
|
||||
|
||||
DictionaryService alfrescoDictionaryService;
|
||||
|
||||
|
||||
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService, DictionaryService alfrescoDictionaryService)
|
||||
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService,
|
||||
DictionaryService alfrescoDictionaryService)
|
||||
{
|
||||
this.wrapped = wrapped;
|
||||
this.options = options;
|
||||
@@ -125,17 +125,10 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
{
|
||||
for (ResultSet resultSet : wrapped.values())
|
||||
{
|
||||
if (resultSet.getResultSetMetaData().getLimitedBy() != LimitBy.UNLIMITED)
|
||||
if (resultSet.hasMore())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(resultSet.length() - getStart() > getLength() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -149,16 +142,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
{
|
||||
for (ResultSet resultSet : wrapped.values())
|
||||
{
|
||||
int max = options.getMaxItems();
|
||||
int skip = options.getSkipCount();
|
||||
if((max >= 0) && (max < (resultSet.length() - skip)))
|
||||
{
|
||||
return options.getMaxItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
return resultSet.length() - skip;
|
||||
}
|
||||
return resultSet.length();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -189,7 +173,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
for (String selector : wrapped.keySet())
|
||||
{
|
||||
ResultSet rs = wrapped.get(selector);
|
||||
refs.put(selector, rs.getNodeRef(getStart() + i));
|
||||
refs.put(selector, rs.getNodeRef(i));
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
@@ -200,7 +184,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
for (String selector : wrapped.keySet())
|
||||
{
|
||||
ResultSet rs = wrapped.get(selector);
|
||||
scores.put(selector, Float.valueOf(rs.getScore(getStart() + i)));
|
||||
scores.put(selector, Float.valueOf(rs.getScore(i)));
|
||||
}
|
||||
return scores;
|
||||
}
|
||||
@@ -211,8 +195,6 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
return nodeService.getPrimaryParent(nodeRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<ChildAssociationRef> getChildAssocRefs()
|
||||
{
|
||||
ArrayList<ChildAssociationRef> cars = new ArrayList<ChildAssociationRef>(length());
|
||||
@@ -226,7 +208,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
public NodeRef getNodeRef(int n)
|
||||
{
|
||||
Map<String, NodeRef> refs = getNodeRefs(n);
|
||||
if(refs.size() == 1)
|
||||
if (refs.size() == 1)
|
||||
{
|
||||
return refs.values().iterator().next();
|
||||
}
|
||||
@@ -253,15 +235,15 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
|
||||
public float getScore(int n)
|
||||
{
|
||||
Map<String, Float> scores = getScores(n);
|
||||
if(scores.size() == 1)
|
||||
{
|
||||
return scores.values().iterator().next();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Ambiguous selector");
|
||||
}
|
||||
Map<String, Float> scores = getScores(n);
|
||||
if (scores.size() == 1)
|
||||
{
|
||||
return scores.values().iterator().next();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Ambiguous selector");
|
||||
}
|
||||
}
|
||||
|
||||
public int length()
|
||||
|
@@ -54,6 +54,7 @@ import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.repository.datatype.Duration;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.antlr.runtime.ANTLRStringStream;
|
||||
@@ -77,10 +78,14 @@ public class QueryTest extends BaseCMISTest
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
|
||||
|
||||
f0 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 0", namespaceService), ContentModel.TYPE_FOLDER).getChildRef();
|
||||
nodeService.setProperty(f0, ContentModel.PROP_NAME, "Folder 0");
|
||||
folder_count++;
|
||||
|
||||
permissionService.setPermission(f0, "cmis", PermissionService.READ, true);
|
||||
|
||||
|
||||
NodeRef f1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 1", namespaceService), ContentModel.TYPE_FOLDER)
|
||||
.getChildRef();
|
||||
@@ -1593,6 +1598,13 @@ public class QueryTest extends BaseCMISTest
|
||||
testQuery("SELECT * FROM Document", 0, false, "ObjectId", new String(), false);
|
||||
|
||||
}
|
||||
|
||||
public void testBasicSelectAsCmis()
|
||||
{
|
||||
runAs("cmis");
|
||||
testQuery("SELECT * FROM Document", 7, false, "ObjectId", new String(), false);
|
||||
|
||||
}
|
||||
|
||||
public void testBasicSelect()
|
||||
{
|
||||
|
Reference in New Issue
Block a user