use of org.alfresco.repo.virtual.page.PageCollator in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method list.
@Override
public PagingResults<Reference> list(final Reference ref, boolean actual, boolean virtual, final boolean files, final boolean folders, final String pattern, final Set<QName> searchTypeQNames, final Set<QName> ignoreTypeQNames, final Set<QName> ignoreAspectQNames, final List<Pair<QName, Boolean>> sortProps, final PagingRequest pagingRequest) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(ref);
List<Reference> virtualRefs = null;
// constraints should handle folder & file filtering
if (virtual && folders) {
virtualRefs = createChildReferences(ref, structure);
} else {
virtualRefs = Collections.emptyList();
}
if (actual) {
final VirtualQuery query = structure.getQuery();
if (query != null) {
// we have a query we must collate results
PagingResultsSource<Reference> querySourc = new PagingResultsSource<Reference>() {
@Override
public PagingResults<Reference> retrieve(PagingRequest pr) throws PageCollationException {
try {
return query.perform(environment, files, folders, pattern, searchTypeQNames, ignoreTypeQNames, ignoreAspectQNames, sortProps, pr, ref);
} catch (VirtualizationException e) {
throw new PageCollationException(e);
}
}
};
PageCollator<Reference> collator = new PageCollator<>();
try {
return collator.collate(virtualRefs, querySourc, pagingRequest, new ReferenceComparator(this, sortProps));
} catch (PageCollationException e) {
throw new VirtualizationException(e);
}
}
}
return new ListBackedPagingResults<>(virtualRefs);
}
Aggregations