Java Code Examples for org.alfresco.query.PagingRequest#getQueryExecutionId()
The following examples show how to use
org.alfresco.query.PagingRequest#getQueryExecutionId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiteServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public PagingResults<SiteMembership> listMembersPaged(String shortName, boolean collapseGroups, List<Pair<SiteService.SortFields, Boolean>> sortProps, PagingRequest pagingRequest) { CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems()); // sort details CannedQuerySortDetails sortDetails = null; if(sortProps != null) { List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size()); for (Pair<SiteService.SortFields, Boolean> sortProp : sortProps) { sortPairs.add(new Pair<SiteService.SortFields, SortOrder>(sortProp.getFirst(), (sortProp.getSecond() ? SortOrder.ASCENDING : SortOrder.DESCENDING))); } sortDetails = new CannedQuerySortDetails(sortPairs); } SiteMembersCannedQueryParams parameterBean = new SiteMembersCannedQueryParams(shortName, collapseGroups); CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId()); CannedQuery<SiteMembership> query = new SiteMembersCannedQuery(this, personService, nodeService, params); CannedQueryResults<SiteMembership> results = query.execute(); return getPagingResults(pagingRequest, results); }
Example 2
Source File: SiteServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public PagingResults<FileInfo> listContainers(String shortName, PagingRequest pagingRequest) { SiteContainersCannedQueryFactory sitesContainersCannedQueryFactory = (SiteContainersCannedQueryFactory)cannedQueryRegistry.getNamedObject("siteContainersCannedQueryFactory"); CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems()); CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING)); SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName)); CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId()); CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params); CannedQueryResults<FileInfo> results = query.execute(); return getPagingResults(pagingRequest, results); }
Example 3
Source File: GetBlogPostsCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public CannedQuery<BlogEntity> getGetPublishedCannedQuery(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq) { ParameterCheck.mandatory("blogContainerNode", blogContainerNode); ParameterCheck.mandatory("pagingReq", pagingReq); int requestTotalCountMax = pagingReq.getRequestTotalCountMax(); boolean isPublished = true; GetBlogPostsCannedQueryParams paramBean = new GetBlogPostsCannedQueryParams(getNodeId(blogContainerNode), getQNameId(ContentModel.PROP_NAME), getQNameId(ContentModel.PROP_PUBLISHED), getQNameId(ContentModel.TYPE_CONTENT), byUser, isPublished, fromDate, toDate, null, null); CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq); CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING); // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 4
Source File: GetNodesWithAspectCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Retrieve an unsorted instance of a {@link CannedQuery} based on parameters including * request for a total count (up to a given max) * * @param storeRef the store to search in, if requested * @param aspectQNames qnames of aspects to search for * @param pagingRequest skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax * * @return an implementation that will execute the query */ public CannedQuery<NodeRef> getCannedQuery(StoreRef storeRef, Set<QName> aspectQNames, PagingRequest pagingRequest) { ParameterCheck.mandatory("aspectQNames", aspectQNames); ParameterCheck.mandatory("pagingRequest", pagingRequest); int requestTotalCountMax = pagingRequest.getRequestTotalCountMax(); // specific query params - context (parent) and inclusive filters (child types, property values) GetNodesWithAspectCannedQueryParams paramBean = new GetNodesWithAspectCannedQueryParams(storeRef, aspectQNames); // page details CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT); // no sort details - no sorting done // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, null, requestTotalCountMax, pagingRequest.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 5
Source File: GetPeopleCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Retrieve an optionally filtered/sorted instance of a {@link CannedQuery} based on parameters including request for a total count (up to a given max) * * Note: if both filtering and sorting is required then the combined total of unique QName properties should be the 0 to 3. * * @param parentRef parent node ref * @param pattern the pattern to use to filter children (wildcard character is '*') * @param filterProps filter props * @param inclusiveAspects If not null, only child nodes with any aspect in this collection will be included in the results. * @param exclusiveAspects If not null, any child nodes with any aspect in this collection will be excluded in the results. * @param includeAdministrators include administrators in the returned results * @param sortProps sort property pairs (QName and Boolean - true if ascending) * @param pagingRequest skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax * * @return an implementation that will execute the query */ public CannedQuery<NodeRef> getCannedQuery(NodeRef parentRef, String pattern, List<QName> filterProps, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, boolean includeAdministrators, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest) { ParameterCheck.mandatory("parentRef", parentRef); ParameterCheck.mandatory("pagingRequest", pagingRequest); int requestTotalCountMax = pagingRequest.getRequestTotalCountMax(); // specific query params - context (parent) and inclusive filters (property values) GetPeopleCannedQueryParams paramBean = new GetPeopleCannedQueryParams(tenantService.getName(parentRef), filterProps, pattern, inclusiveAspects, exclusiveAspects, includeAdministrators); // page details CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT); // sort details CannedQuerySortDetails cqsd = null; if (sortProps != null) { List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size()); for (Pair<QName, Boolean> sortProp : sortProps) { boolean sortAsc = ((sortProp.getSecond() == null) || sortProp.getSecond()); sortPairs.add(new Pair<QName, SortOrder>(sortProp.getFirst(), (sortAsc ? SortOrder.ASCENDING : SortOrder.DESCENDING))); } cqsd = new CannedQuerySortDetails(sortPairs); } // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 6
Source File: GetCalendarEntriesCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public CannedQuery<CalendarEntry> getCannedQuery(NodeRef[] containerNodes, Date fromDate, Date toDate, PagingRequest pagingReq) { ParameterCheck.mandatory("containerNodes", containerNodes); ParameterCheck.mandatory("pagingReq", pagingReq); int requestTotalCountMax = pagingReq.getRequestTotalCountMax(); Long[] containerIds = new Long[containerNodes.length]; for(int i=0; i<containerIds.length; i++) { containerIds[i] = getNodeId(containerNodes[i]); } //FIXME Need tenant service like for GetChildren? GetCalendarEntriesCannedQueryParams paramBean = new GetCalendarEntriesCannedQueryParams( containerIds, getQNameId(ContentModel.PROP_NAME), getQNameId(CalendarModel.TYPE_EVENT), getQNameId(CalendarModel.PROP_FROM_DATE), getQNameId(CalendarModel.PROP_TO_DATE), getQNameId(CalendarModel.PROP_RECURRENCE_RULE), getQNameId(CalendarModel.PROP_RECURRENCE_LAST_MEETING), fromDate, toDate ); CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq); CannedQuerySortDetails cqsd = createCQSortDetails(); // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 7
Source File: DocumentLinkServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public List<Long> getNodeLinksIds(NodeRef nodeRef) { /* Validate input */ PropertyCheck.mandatory(this, "nodeRef", nodeRef); /* Get all links of the given nodeRef */ PagingRequest pagingRequest = new PagingRequest(0, 100000); List<Long> nodeLinks = new ArrayList<Long>(); Pair<Long, QName> nameQName = qnameDAO.getQName(ContentModel.PROP_LINK_DESTINATION); if (nameQName != null) { // Execute the canned query if there are links in the database GetDoclinkNodesCannedQueryParams parameterBean = new GetDoclinkNodesCannedQueryParams(nodeRef.toString(), nameQName.getFirst(), pagingRequest.getMaxItems()); CannedQueryParameters params = new CannedQueryParameters(parameterBean, null, null, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId()); CannedQuery<Long> query = new GetDoclinkNodesCannedQuery(cannedQueryDAO, params); CannedQueryResults<Long> results = query.execute(); for (Long nodeId : results.getPage()) { nodeLinks.add(nodeId); } } return nodeLinks; }
Example 8
Source File: DraftsAndPublishedBlogPostsCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public CannedQuery<BlogEntity> getCannedQuery(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq) { ParameterCheck.mandatory("blogContainerNode", blogContainerNode); ParameterCheck.mandatory("pagingReq", pagingReq); int requestTotalCountMax = pagingReq.getRequestTotalCountMax(); //FIXME Need tenant service like for GetChildren? DraftsAndPublishedBlogPostsCannedQueryParams paramBean = new DraftsAndPublishedBlogPostsCannedQueryParams( getNodeId(blogContainerNode), getQNameId(ContentModel.PROP_NAME), getQNameId(ContentModel.PROP_PUBLISHED), getQNameId(ContentModel.TYPE_CONTENT), byUser, fromDate, toDate); CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq); List<Pair<QName, Boolean>> sortPairs = new ArrayList<Pair<QName, Boolean>>(2); // Sort by created then published. We want a list of all published (most recently published first), // followed by all unpublished (most recently created first) sortPairs.add(new Pair<QName, Boolean>(ContentModel.PROP_CREATED, Boolean.FALSE)); sortPairs.add(new Pair<QName, Boolean>(ContentModel.PROP_PUBLISHED, Boolean.FALSE)); CannedQuerySortDetails cqsd = createCQSortDetails(sortPairs); // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 9
Source File: GetBlogPostsCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public CannedQuery<BlogEntity> getGetDraftsCannedQuery(NodeRef blogContainerNode, String username, PagingRequest pagingReq) { ParameterCheck.mandatory("blogContainerNode", blogContainerNode); ParameterCheck.mandatory("pagingReq", pagingReq); int requestTotalCountMax = pagingReq.getRequestTotalCountMax(); //FIXME Need tenant service like for GetChildren? boolean isPublished = false; GetBlogPostsCannedQueryParams paramBean = new GetBlogPostsCannedQueryParams(getNodeId(blogContainerNode), getQNameId(ContentModel.PROP_NAME), getQNameId(ContentModel.PROP_PUBLISHED), getQNameId(ContentModel.TYPE_CONTENT), username, isPublished, null, null, null, null); CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq); CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_CREATED, SortOrder.DESCENDING); // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 10
Source File: GetDiscussionTopcisWithPostsCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public CannedQuery<NodeWithChildrenEntity> getCannedQuery(NodeRef parentNodeRef, Date topicCreatedFrom, Date postCreatedFrom, boolean excludePrimaryPosts, CannedQuerySortDetails sortDetails, PagingRequest pagingReq) { ParameterCheck.mandatory("parentNodeRef", parentNodeRef); ParameterCheck.mandatory("pagingReq", pagingReq); int requestTotalCountMax = pagingReq.getRequestTotalCountMax(); //FIXME Need tenant service like for GetChildren? GetDiscussionTopcisWithPostsCannedQueryParams paramBean = new GetDiscussionTopcisWithPostsCannedQueryParams( getNodeId(parentNodeRef), getQNameId(ContentModel.PROP_NAME), getQNameId(ForumModel.TYPE_TOPIC), getQNameId(ForumModel.TYPE_POST), topicCreatedFrom, postCreatedFrom, excludePrimaryPosts); 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); }
Example 11
Source File: GetArchivedNodesCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @param archiveStoreRootNodeRef NodeRef * @param assocTypeQName QName * @param filter String * @param filterIgnoreCase boolean * @param pagingRequest PagingRequest * @param sortOrderAscending boolean * @return an implementation that will execute the query */ public CannedQuery<ArchivedNodeEntity> getCannedQuery(NodeRef archiveStoreRootNodeRef, QName assocTypeQName, String filter, boolean filterIgnoreCase, PagingRequest pagingRequest, boolean sortOrderAscending) { ParameterCheck.mandatory("pagingRequest", pagingRequest); Long nodeId = (archiveStoreRootNodeRef == null) ? -1 : getNodeId(archiveStoreRootNodeRef); Long qnameId = (assocTypeQName == null) ? -1 : getQNameId(assocTypeQName); int requestTotalCountMax = pagingRequest.getRequestTotalCountMax(); GetArchivedNodesCannedQueryParams paramBean = new GetArchivedNodesCannedQueryParams(nodeId, qnameId, filter, filterIgnoreCase, getQNameId(ContentModel.PROP_NAME), sortOrderAscending); // page details CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT); // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, null, requestTotalCountMax, pagingRequest.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 12
Source File: GetChildrenWithTargetAssocsAuditableCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
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); }
Example 13
Source File: GetChildrenCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Retrieve an optionally filtered/sorted instance of a {@link CannedQuery} based on parameters including request for a total count (up to a given max) * * Note: if both filtering and sorting is required then the combined total of unique QName properties should be the 0 to 3. * * @param parentRef parent node ref * @param pattern the pattern to use to filter children (wildcard character is '*') * @param assocTypeQNames qnames of assocs to include (may be null) * @param childTypeQNames type qnames of children nodes (pre-filter) * @param inclusiveAspects If not null, only child nodes with any aspect in this collection will be included in the results. * @param exclusiveAspects If not null, any child nodes with any aspect in this collection will be excluded in the results. * @param filterProps filter properties * @param sortProps sort property pairs (QName and Boolean - true if ascending) * @param pagingRequest skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax * * @return an implementation that will execute the query */ public CannedQuery<NodeRef> getCannedQuery(NodeRef parentRef, String pattern, Set<QName> assocTypeQNames, Set<QName> childTypeQNames, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, List<FilterProp> filterProps, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest) { ParameterCheck.mandatory("parentRef", parentRef); ParameterCheck.mandatory("pagingRequest", pagingRequest); int requestTotalCountMax = pagingRequest.getRequestTotalCountMax(); // specific query params - context (parent) and inclusive filters (child types, property values) GetChildrenCannedQueryParams paramBean = new GetChildrenCannedQueryParams(tenantService.getName(parentRef), assocTypeQNames, childTypeQNames, inclusiveAspects, exclusiveAspects, filterProps, pattern); // page details CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT); // sort details CannedQuerySortDetails cqsd = null; if (sortProps != null) { List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size()); for (Pair<QName, Boolean> sortProp : sortProps) { sortPairs.add(new Pair<QName, SortOrder>(sortProp.getFirst(), (sortProp.getSecond() ? SortOrder.ASCENDING : SortOrder.DESCENDING))); } cqsd = new CannedQuerySortDetails(sortPairs); } // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 14
Source File: GetChildrenAuditableCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public CannedQuery<NodeBackedEntity> getCannedQuery(NodeRef parentNodeRef, QName contentType, String createdBy, Date createdFrom, Date createdTo, String modifiedBy, Date modifiedFrom, Date modifiedTo, 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? GetChildrenAuditableCannedQueryParams paramBean = new GetChildrenAuditableCannedQueryParams( getNodeId(parentNodeRef), getQNameId(ContentModel.PROP_NAME), getQNameId(contentType), createdBy, createdFrom, createdTo, modifiedBy, modifiedFrom, modifiedTo ); 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); }
Example 15
Source File: ScriptPagingDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public ScriptPagingDetails(PagingRequest paging) { super(paging.getSkipCount(), paging.getMaxItems(), paging.getQueryExecutionId()); setRequestTotalCountMax(paging.getRequestTotalCountMax()); }
Example 16
Source File: GetAuthoritiesCannedQueryFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public CannedQuery<AuthorityInfo> getCannedQuery(AuthorityType type, NodeRef containerRef, String displayNameFilter, String sortBy, boolean sortAscending, PagingRequest pagingRequest) { ParameterCheck.mandatory("containerRef", containerRef); ParameterCheck.mandatory("pagingRequest", pagingRequest); int requestTotalCountMax = pagingRequest.getRequestTotalCountMax(); Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(tenantService.getName(containerRef)); if (nodePair == null) { throw new InvalidNodeRefException("Container ref does not exist: " + containerRef, containerRef); } Long containerNodeId = nodePair.getFirst(); Long qnameAuthDisplayNameId = Long.MIN_VALUE; // We query but using a value that won't return results Pair<Long, QName> qnameAuthDisplayNamePair = qnameDAO.getQName(ContentModel.PROP_AUTHORITY_DISPLAY_NAME); if (qnameAuthDisplayNamePair != null) { qnameAuthDisplayNameId = qnameAuthDisplayNamePair.getFirst(); } // this can be null, in which case, there is no filtering on type, done at the database level Long typeQNameId = getQNameIdForType(type); // specific query params GetAuthoritiesCannedQueryParams paramBean = new GetAuthoritiesCannedQueryParams(type, typeQNameId, containerNodeId, qnameAuthDisplayNameId, displayNameFilter); // page details CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT); // sort details CannedQuerySortDetails cqsd = null; if (sortBy != null) { List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(1); sortPairs.add(new Pair<String, SortOrder>(sortBy, (sortAscending ? SortOrder.ASCENDING : SortOrder.DESCENDING))); cqsd = new CannedQuerySortDetails(sortPairs); } // create query params holder CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId()); // return canned query instance return getCannedQuery(params); }
Example 17
Source File: PageCollator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private PagingResults<R> collate(List<R> objects, final PagingResults<R> objectPageSurce, int pageSkip, final PagingRequest pagingRequest, Comparator<R> comparator) { final int pageSize = pagingRequest.getMaxItems(); final List<R> inPageList = objectPageSurce.getPage(); final List<R> collatedPageList = new LinkedList<>(); final boolean endOfCollation = collate(objects, inPageList, pageSkip, pageSize, comparator, collatedPageList); final int resultsSize = objects.size(); final Pair<Integer, Integer> pageTotal = objectPageSurce.getTotalResultCount(); Integer pageTotalFirst = null; Integer pageTotalSecond = null; if (pageTotal != null) { pageTotalFirst = pageTotal.getFirst(); pageTotalSecond = pageTotal.getSecond(); } final Pair<Integer, Integer> total = new Pair<>(pageTotalFirst == null ? null : pageTotalFirst + resultsSize, pageTotalSecond == null ? null : pageTotalSecond + resultsSize); final boolean hasMoreItems = objectPageSurce.hasMoreItems() || !endOfCollation; return new PagingResults<R>() { @Override public List<R> getPage() { return collatedPageList; } @Override public boolean hasMoreItems() { return hasMoreItems; } @Override public Pair<Integer, Integer> getTotalResultCount() { return total; } @Override public String getQueryExecutionId() { return pagingRequest.getQueryExecutionId(); } }; }
Example 18
Source File: PageCollator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @param objects * @param objectPageSurce * @param pagingRequest * @param comparator * @return a {@link PagingResults} R objects obtained from merging a * collection of R objects with a paged result obtained from a * {@link PagingResultsSource} considering the a merged result * {@link PagingRequest} * @throws PageCollationException */ public PagingResults<R> collate(List<R> objects, PagingResultsSource<R> objectPageSurce, PagingRequest pagingRequest, Comparator<R> comparator) throws PageCollationException { final int skip = pagingRequest.getSkipCount(); final int pageSize = pagingRequest.getMaxItems(); if (skip < 0 || pageSize < 0) { throw new InvalidPageBounds("Negative page skip index and/or bounds."); } int preemptiveSkip = Math.max(0, skip - objects.size()); int pageSkip = skip - preemptiveSkip; int preemptiveSize = pageSize + pageSkip; PagingResults<R> pageResults = null; try { PagingRequest preemptiveRequest = new PagingRequest(preemptiveSkip, preemptiveSize, pagingRequest.getQueryExecutionId()); preemptiveRequest.setRequestTotalCountMax(pagingRequest.getRequestTotalCountMax()); pageResults = objectPageSurce.retrieve(preemptiveRequest); } catch (InvalidPageBounds e) { if (logger.isDebugEnabled()) { logger.debug(e); } pageResults = new PagingResults<R>() { @Override public List<R> getPage() { return Collections.emptyList(); } @Override public boolean hasMoreItems() { return false; } @Override public Pair<Integer, Integer> getTotalResultCount() { return new Pair<Integer, Integer>(null, null); } @Override public String getQueryExecutionId() { return null; } }; } return collate(objects, pageResults, pageSkip, pagingRequest, comparator); }