info.magnolia.cms.core.search.QueryManager.createQuery()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中info.magnolia.cms.core.search.QueryManager.createQuery方法的一些代码示例,展示了QueryManager.createQuery的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryManager.createQuery方法的具体详情如下:
包路径:info.magnolia.cms.core.search.QueryManager
类名称:QueryManager
方法名:createQuery

QueryManager.createQuery介绍

[英]Description inherited from javax.jcr.query.QueryManager#createQuery(String, String)
Creates a new query by specifying the query statement itself and the language in which the query is stated. If the query statement is syntactically invalid, given the language specified, an InvalidQueryException is thrown. The language must be a string from among those returned by QueryManager.getSupportedQueryLanguages(); if it is not, then an InvalidQueryException is thrown.
[中]从javax继承的描述。jcr。查询QueryManager#createQuery(字符串,字符串)
通过指定查询statement本身和陈述查询的language来创建新查询。如果查询statement在语法上无效,给定指定的语言,将抛出InvalidQueryExceptionlanguage必须是QueryManager返回的字符串中的一个。getSupportedQueryLanguages();如果不是,则抛出一个InvalidQueryException

代码示例

代码示例来源:origin: info.magnolia/magnolia-gui

/**
 * Executes the query statement and returns the QueryResult.
 */
protected QueryResult getResult(String statement) throws InvalidQueryException, RepositoryException {
  Query q = MgnlContext.getQueryManager(this.repositoryId).createQuery(statement, Query.SQL);
  QueryResult result = q.execute();
  return result;
}

代码示例来源:origin: info.magnolia/magnolia-taglib-utility

public int doStartTag() throws JspException {
  final String queryString = useSimpleJcrQuery ? generateSimpleQuery(query) : generateComplexXPathQuery();
  if (queryString == null) {
    if (log.isDebugEnabled()) {
      log.debug("A valid query could not be built, skipping"); //$NON-NLS-1$
    }
    return EVAL_PAGE;
  }
  if (log.isDebugEnabled()) {
    log.debug("Executing xpath query " + queryString); //$NON-NLS-1$
  }
  Query q;
  try {
    q = MgnlContext.getQueryManager(repository).createQuery(queryString, "xpath"); //$NON-NLS-1$
    QueryResult result = q.execute();
    pageContext.setAttribute(var, result.getContent(itemType), scope);
  }
  catch (Exception e) {
    log.error(MessageFormat.format(
      "{0} caught while parsing query for search term [{1}] - query is [{2}]: {3}", //$NON-NLS-1$
      new Object[]{e.getClass().getName(), this.query, queryString, e.getMessage()}), e);
  }
  return EVAL_PAGE;
}

代码示例来源:origin: info.magnolia/magnolia-module-workflow

/**
 * Returns the number of expressions currently stored in that store.
 */
@Override
public int size() {
  try {
    final QueryManager qm = MgnlContext.getSystemContext().getQueryManager(WorkflowConstants.WORKSPACE_EXPRESSION);
    Query q = qm.createQuery(WorkflowConstants.STORE_ITERATOR_QUERY, Query.SQL);
    QueryResult qr = q.execute();
    return qr.getContent().size();
  } catch (final Exception e) {
    log.error("size() failed", e);
    return -1;
  }
}

代码示例来源:origin: info.magnolia/magnolia-templating-compatibility-taglib-cms

@Override
public int doEndTag() throws JspException {
  Query q;
  try {
    q = MgnlContext.getQueryManager(repository).createQuery(query, type);
  }
  catch (InvalidQueryException e) {
    throw new NestableRuntimeException("Invalid query: " + query, e);
  }
  catch (RepositoryException e) {
    throw new NestableRuntimeException(e);
  }
  QueryResult queryResult;
  try {
    queryResult = q.execute();
  }
  catch (RepositoryException e) {
    log.error("Error running query \"" + query + "\": " + e.getClass().getName() + " " + e.getMessage(), e);
    return EVAL_PAGE;
  }
  Collection result = queryResult.getContent(nodeType);
  pageContext.setAttribute(var, result);
  return EVAL_PAGE;
}

代码示例来源:origin: info.magnolia/magnolia-module-workflow

final QueryManager queryManager = MgnlContext.getSystemContext().getQueryManager(
    WorkflowConstants.WORKSPACE_STORE);
final Query q = queryManager.createQuery(queryString, language);

代码示例来源:origin: info.magnolia/magnolia-module-forum

@Override
public Collection<Content> getForumMessages(String forumName) throws RepositoryException {
  final String forumPath = "/" + forumName;
  final boolean showUnvalidatedMessages = config.isShowingUnvalidatedMessages();
  final String sql = getMessagesQueryString(forumPath, showUnvalidatedMessages, " order by creationDate desc");
  final HierarchyManager hm = getHierarchyManager();
  final info.magnolia.cms.core.search.QueryManager qm = hm.getQueryManager();
  info.magnolia.cms.core.search.Query query = qm.createQuery(sql, Query.SQL);
  info.magnolia.cms.core.search.QueryResult result = query.execute();
  return result.getContent(MESSAGE_NODETYPE);
}

相关文章

微信公众号

最新文章

更多

QueryManager类方法