org.xwiki.query.Query.bindValue()方法的使用及代码示例

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

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

Query.bindValue介绍

[英]Bind named parameter var with a value that will be constructed using calls to QueryParameter#literal(String), QueryParameter#anychar() and QueryParameter#anyChars(). In order to perserve the fluent API, it's also possible to call QueryParameter#query() to get back the Query.
[中]将命名参数var与一个值绑定,该值将通过调用QueryParameter#literal(String)、QueryParameter#anychar()和QueryParameter#anyChars()来构造。为了保持fluent API,还可以调用QueryParameter#query()返回查询。

代码示例

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public Query bindValue(int index, Object val)
{
  this.query.bindValue(index, val);
  return this;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public Query bindValue(String var, Object val)
{
  this.query.bindValue(var, val);
  return this;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public QueryParameter bindValue(String var)
{
  return getWrappedQuery().bindValue(var);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public Query bindValue(String var, Object val)
{
  return getWrappedQuery().bindValue(var, val);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public Query bindValue(int index, Object val)
{
  return getWrappedQuery().bindValue(index, val);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager

@Override
public QueryParameter bindValue(String var)
{
  QueryParameter parameter = this.query.bindValue(var);
  return new ScriptQueryParameter(this, parameter);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-crypto-store-wiki

/**
 * Execute the query.
 *
 * @param issuer the issuer name.
 * @param serial the serial number.
 * @return the query result.
 * @throws QueryException on query error.
 */
protected <T> List<T> execute(PrincipalIndentifier issuer, BigInteger serial) throws QueryException
{
  return getQuery().bindValue(ISSUER, issuer.getName()).bindValue(SERIAL, serial.toString()).execute();
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

private List<String> getDocumentsWithTag(String tag) throws QueryException
  {
    String query =
      "select doc.fullName from XWikiDocument as doc, BaseObject as obj, DBStringListProperty as prop "
        + "where obj.name=doc.fullName and obj.className='XWiki.TagClass' and obj.id=prop.id.id "
        + "and prop.id.name='tags' and :tag in elements(prop.list) order by doc.name asc";

    List<String> documentsWithTag = queryManager.createQuery(query, Query.HQL).bindValue("tag", tag).execute();

    return documentsWithTag;
  }
}

代码示例来源:origin: phenotips/phenotips

private List<String> runQuery(String queryString, String input)
{
  String formattedInput = String.format(PhenotipsFamilyExport.INPUT_FORMAT, input.toLowerCase());
  // Query patients
  Query query = null;
  List<String> queryResults = null;
  try {
    query = this.qm.createQuery(queryString, Query.XWQL);
    query.bindValue(PhenotipsFamilyExport.INPUT_PARAMETER, formattedInput);
    queryResults = query.execute();
  } catch (QueryException e) {
    this.logger.error("Error while performing patients/families query: [{}] ", e.getMessage());
    return Collections.emptyList();
  }
  return queryResults;
}

代码示例来源:origin: phenotips/phenotips

/**
 * Retrieves and collects patient entities that correspond to the provided external ID.
 *
 * @param patientsBuilder a patient entity set builder
 * @param eids external patient IDs, as a list
 * @throws QueryException if the query fails
 */
private void collectPatientsFromEids(@Nonnull final ImmutableSet.Builder<PrimaryEntity> patientsBuilder,
  @Nonnull final List<Object> eids) throws QueryException
{
  final Query q = this.qm.createQuery("from doc.object(PhenoTips.PatientClass) p where p.external_id in (:eids)",
    Query.XWQL);
  q.bindValue("eids", eids);
  final List<Object> patientIds = q.execute();
  addIds(patientsBuilder, patientIds);
}

代码示例来源:origin: phenotips/phenotips

protected Patient getPatientByGUID(String guid)
{
  try {
    Query q =
      this.queryManager.createQuery("from doc.object(PhenoTips.PatientClass) as o where o.guid = :guid",
        Query.XWQL).bindValue("guid", guid);
    List<String> results = q.<String>execute();
    if (results.size() == 1) {
      DocumentReference reference =
        this.stringResolver.resolve(results.get(0), Patient.DEFAULT_DATA_SPACE);
      return new PhenoTipsPatient((XWikiDocument) this.bridge.getDocument(reference));
    }
  } catch (Exception ex) {
    this.logger.warn("Failed to get patient with GUID [{}]: [{}] {}", guid, ex.getMessage(), ex);
  }
  return null;
}

代码示例来源:origin: org.phenotips/patient-data-sharing-receiver-api

protected Patient getPatientByGUID(String guid)
{
  try {
    Query q =
      this.queryManager.createQuery("from doc.object(PhenoTips.PatientClass) as o where o.guid = :guid",
        Query.XWQL).bindValue("guid", guid);
    List<String> results = q.<String>execute();
    if (results.size() == 1) {
      DocumentReference reference =
        this.stringResolver.resolve(results.get(0), Patient.DEFAULT_DATA_SPACE);
      return new PhenoTipsPatient((XWikiDocument) this.bridge.getDocument(reference));
    }
  } catch (Exception ex) {
    this.logger.warn("Failed to get patient with GUID [{}]: [{}] {}", guid, ex.getMessage(), ex);
  }
  return null;
}

代码示例来源:origin: org.phenotips/family-studies-api

private List<String> runQuery(String queryString, String input, int resultsLimit)
{
  String formattedInput = String.format(PhenotipsFamilyExport.INPUT_FORMAT, input);
  // Query patients
  Query query = null;
  List<String> queryResults = null;
  try {
    query = this.qm.createQuery(queryString, Query.XWQL);
    query.setLimit(resultsLimit);
    query.bindValue(PhenotipsFamilyExport.INPUT_PARAMETER, formattedInput);
    queryResults = query.execute();
  } catch (QueryException e) {
    this.logger.error("Error while performing patiets query: [{}] ", e.getMessage());
    return Collections.emptyList();
  }
  return queryResults;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-crypto-store-wiki

/**
 * Execute the query.
 *
 * @param subject the subject name
 * @return the query result.
 * @throws QueryException on query error.
 */
protected <T> List<T> execute(PrincipalIndentifier subject) throws QueryException
{
  return getQuery().bindValue(SUBJECT, subject.getName()).execute();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-messagestream-api

@Override
public void deleteMessage(String id)
{
  Query q;
  try {
    q = this.qm.createQuery("where event.id = :id", Query.XWQL);
    q.bindValue("id", id);
    List<Event> events = this.stream.searchEvents(q);
    if (events == null || events.isEmpty()) {
      throw new IllegalArgumentException("This message does not exist");
    } else if (events.get(0).getUser().equals(this.bridge.getCurrentUserReference())) {
      this.stream.deleteEvent(events.get(0));
    } else {
      throw new IllegalArgumentException("You are not authorized to delete this message");
    }
  } catch (QueryException ex) {
    LOG.warn("Failed to delete message: {}", ex.getMessage());
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-crypto-store-wiki

/**
 * Execute the query.
 *
 * @param keyId the subject key identifier.
 * @return the query result.
 * @throws IOException on encoding error.
 * @throws QueryException on query error.
 */
protected <T> List<T> execute(byte[] keyId) throws IOException, QueryException
{
  return getQuery().bindValue(KEYID, getEncoder().encode(keyId)).execute();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-messagestream-api

@Override
public List<Event> getRecentPersonalMessages(DocumentReference author, int limit, int offset)
{
  List<Event> result = new ArrayList<Event>();
  try {
    Query q = this.qm.createQuery(
      "where event.application = 'MessageStream' and event.type = 'personalMessage'"
        + " and event.user = :user order by event.date desc",
      Query.XWQL);
    q.bindValue("user", this.serializer.serialize(author));
    q.setLimit(limit > 0 ? limit : 30).setOffset(offset >= 0 ? offset : 0);
    result = this.stream.searchEvents(q);
  } catch (QueryException ex) {
    LOG.warn("Failed to search personal messages: {}", ex.getMessage());
  }
  return result;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-messagestream-api

@Override
public List<Event> getRecentMessagesForGroup(DocumentReference group, int limit, int offset)
{
  List<Event> result = new ArrayList<Event>();
  try {
    Query q = this.qm.createQuery(
      "where event.application = 'MessageStream' and event.type = 'groupMessage'"
        + " and event.stream = :group order by event.date desc",
      Query.XWQL);
    q.bindValue("group", this.serializer.serialize(group));
    q.setLimit(limit > 0 ? limit : 30).setOffset(offset >= 0 ? offset : 0);
    result = this.stream.searchEvents(q);
  } catch (QueryException ex) {
    LOG.warn("Failed to search group messages: {}", ex.getMessage());
  }
  return result;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-messagestream-api

@Override
public List<Event> getRecentDirectMessages(int limit, int offset)
{
  List<Event> result = new ArrayList<Event>();
  try {
    Query q = this.qm.createQuery(
      "where event.application = 'MessageStream' and event.type = 'directMessage'"
        + " and event.stream = :targetUser order by event.date desc",
      Query.XWQL);
    q.bindValue("targetUser", this.serializer.serialize(this.bridge.getCurrentUserReference()));
    q.setLimit(limit > 0 ? limit : 30).setOffset(offset >= 0 ? offset : 0);
    result = this.stream.searchEvents(q);
  } catch (QueryException ex) {
    LOG.warn("Failed to search direct messages: {}", ex.getMessage());
  }
  return result;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

public List<String> getSpaceDocsName(String spaceName, XWikiContext context) throws XWikiException
{
  try {
    return getStore().getQueryManager().getNamedQuery("getSpaceDocsName").bindValue("space", spaceName)
      .execute();
  } catch (QueryException ex) {
    throw new XWikiException(0, 0, ex.getMessage(), ex);
  }
}

相关文章