当前位置: 首页>>代码示例>>Java>>正文


Java Query.setLimit方法代码示例

本文整理汇总了Java中javax.jcr.query.Query.setLimit方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setLimit方法的具体用法?Java Query.setLimit怎么用?Java Query.setLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.query.Query的用法示例。


在下文中一共展示了Query.setLimit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retrievePlanNodes

import javax.jcr.query.Query; //导入方法依赖的package包/类
private NodeIterator retrievePlanNodes(long limit, long offset) throws RepositoryException {
    this.session.getWorkspace().getQueryManager();
    final QueryManager queryManager = this.session.getWorkspace().getQueryManager();
    final QueryObjectModelFactory factory = queryManager.getQOMFactory();

    final Source selector = factory.selector("scape:plan", "resourcesSelector");
    final Constraint constraints = factory.fullTextSearch("resourcesSelector", null, factory.literal(session.getValueFactory().createValue("*")));

    final Query query = factory.createQuery(selector, constraints, null, null);

    if (limit > 0) {
        query.setLimit(limit);
    }
    if (offset > 0) {
        query.setOffset(offset);
    }
    return query.execute().getNodes();
}
 
开发者ID:fasseg,项目名称:fcrepo4-scape,代码行数:19,代码来源:PlanList.java

示例2: getPosts

import javax.jcr.query.Query; //导入方法依赖的package包/类
/**
 * Get blog posts with pagination
 *
 * @param offset The starting point of blog posts to return.
 * @param limit The number of blog posts to return.
 * @return The blog posts.
 */
public NodeIterator getPosts(Long offset, Long limit) {
    NodeIterator nodes = null;

    if (session != null) {
        try {
            QueryManager queryManager = session.getWorkspace().getQueryManager();
            Query query = queryManager.createQuery(BLOG_QUERY, Query.JCR_SQL2);

            if (offset != null) {
                query.setOffset(offset);
            }

            if (limit != null) {
                query.setLimit(limit);
            }

            QueryResult result = query.execute();
            nodes = result.getNodes();
        } catch (RepositoryException e) {
            LOGGER.error("Could not search repository", e);
        }
    }

    return nodes;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:33,代码来源:BlogServiceImpl.java

示例3: searchObjectOfType

import javax.jcr.query.Query; //导入方法依赖的package包/类
/**
 * Search objects in Fedora with a given JCR Mixin Type using a simple term
 *
 * @param session
 *            the {@link Session} to use for the operation
 * @param mixinType
 *            the mixin type to look for
 * @param terms
 *            the search term to match objects against
 * @param offset
 *            the offset of the search results
 * @param limit
 *            the maximum number of search results
 * @return a {@link java.util.List} containing the paths of the found objects in
 *         Fedora
 * @throws RepositoryException
 *             if an error occurred searching in Fedora
 */
public List<String> searchObjectOfType(final Session session, final String mixinType, final String terms, final int offset, final int limit)
        throws RepositoryException {
    final QueryManager queryManager = session.getWorkspace().getQueryManager();

    final QueryObjectModelFactory factory = queryManager.getQOMFactory();

    final Source selector = factory.selector(mixinType, "resourcesSelector");
    final Constraint constraints = factory.fullTextSearch("resourcesSelector", null, factory.literal(session.getValueFactory().createValue(terms)));

    final Query query = factory.createQuery(selector, constraints, null, null);

    query.setLimit(limit);
    query.setOffset(offset);
    final QueryResult result = query.execute();
    final NodeIterator it = result.getNodes();
    final List<String> uris = new ArrayList<>();
    while (it.hasNext()) {
        Node n = it.nextNode();
        uris.add(n.getPath());
    }
    return uris;
}
 
开发者ID:fasseg,项目名称:fcrepo4-scape,代码行数:41,代码来源:ConnectorService.java

示例4: fetchResults

import javax.jcr.query.Query; //导入方法依赖的package包/类
private ResultsPage fetchResults(int limit, int offset) throws ReportException {
  prepareStatement();
  ResourceResolver resolver = request.getResourceResolver();
  Session session = resolver.adaptTo(Session.class);
  List<Object> results = new ArrayList<>();
  try {
    QueryManager queryMgr = session.getWorkspace().getQueryManager();

    Query query = queryMgr.createQuery(statement, config.getQueryLanguage());

    if (page != -1) {
      log.debug("Fetching results with limit {} and offset {}", new Object[] { limit, offset });
      query.setLimit(limit);
      query.setOffset(offset);
    } else {
      log.debug("Fetching all results");
    }
    QueryResult result = query.execute();
    NodeIterator nodes = result.getNodes();

    while (nodes.hasNext()) {
      results.add(resolver.getResource(nodes.nextNode().getPath()));
    }
  } catch (RepositoryException re) {
    log.error("Exception executing search results", re);
    throw new ReportException("Exception executing search results", re);
  }
  return new ResultsPage(results, config.getPageSize(), page);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:30,代码来源:QueryReportExecutor.java


注:本文中的javax.jcr.query.Query.setLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。