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


Java Criterion类代码示例

本文整理汇总了Java中org.folio.rest.persist.Criteria.Criterion的典型用法代码示例。如果您正苦于以下问题:Java Criterion类的具体用法?Java Criterion怎么用?Java Criterion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Criterion类属于org.folio.rest.persist.Criteria包,在下文中一共展示了Criterion类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.folio.rest.persist.Criteria.Criterion; //导入依赖的package包/类
/**
 * select query
 * @param table - table to query
 * @param clazz - class of objects to be returned
 * @param filter - see Criterion class
 * @param returnCount - whether to return the amount of records matching the query
 * @param setId - whether to automatically set the "id" field of the returned object
 * @param replyHandler
 * @throws Exception
 */
public void get(String table, Class<?> clazz, Criterion filter, boolean returnCount, boolean setId,
    List<FacetField> facets, Handler<AsyncResult<Results>> replyHandler) throws Exception {

  StringBuilder sb = new StringBuilder();
  StringBuilder fromClauseFromCriteria = new StringBuilder();
  if (filter != null) {
    sb.append(filter.toString());
    fromClauseFromCriteria.append(filter.from2String());
    if (fromClauseFromCriteria.length() > 0) {
      fromClauseFromCriteria.insert(0, ",");
    }
  }
  get(table, clazz, DEFAULT_JSONB_FIELD_NAME, fromClauseFromCriteria.toString() + sb.toString(),
    returnCount, true, setId, facets, replyHandler);
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:26,代码来源:PostgresClient.java

示例2: delete

import org.folio.rest.persist.Criteria.Criterion; //导入依赖的package包/类
/**
 * Delete based on filter
 * @param table
 * @param filter
 * @param replyHandler
 * @throws Exception
 */
public void delete(String table, Criterion filter, Handler<AsyncResult<UpdateResult>> replyHandler) throws Exception {
  StringBuilder sb = new StringBuilder();
  if (filter != null) {
    sb.append(filter.toString());
  }
  delete(table, sb.toString(), false, replyHandler);
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:15,代码来源:PostgresClient.java

示例3: join

import org.folio.rest.persist.Criteria.Criterion; //导入依赖的package包/类
public void join(JoinBy from, JoinBy to, String operation, String joinType, Criterion cr
    ,Handler<AsyncResult<?>> replyHandler){
  String filter = "";
  if(cr != null){
    filter = cr.toString();
  }
  join(from, to, operation, joinType, filter, null, true, replyHandler);
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:9,代码来源:PostgresClient.java

示例4: persistentlyCacheResult

import org.folio.rest.persist.Criteria.Criterion; //导入依赖的package包/类
/**
 * For queries where you only want to populate the where clause
 * <br/>
 * See {@link #persistentlyCacheResult(String, String, Handler) }
 * @param cacheName
 * @param tableName
 * @param filter
 * @param replyHandler
 */
public void persistentlyCacheResult(String cacheName, String tableName, Criterion filter, Handler<AsyncResult<Integer>> replyHandler){
  String where = "";
  if(filter != null){
    where = filter.toString();
  }
  String q =
      "SELECT * FROM " + convertToPsqlStandard(tenantId) + "." + tableName + " " + where;
  persistentlyCacheResult(cacheName, q, replyHandler);
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:19,代码来源:PostgresClient.java

示例5: update

import org.folio.rest.persist.Criteria.Criterion; //导入依赖的package包/类
/**
 * update a section / field / object in the pojo -
 * <br>
 * for example:
 * <br> if a json called po_line contains the following field
 * <pre>
 *     "po_line_status": {
 *       "value": "SENT",
 *       "desc": "sent to vendor"
 *     },
 * </pre>
 *  this translates into a po_line_status object within the po_line object - to update the entire object / section
 *  create an updateSection object pushing into the section the po line status as the field and the value (string / json / etc...) to replace it with
 *  <pre>
 *  a = new UpdateSection();
 *  a.addField("po_line_status");
 *  a.setValue(new JsonObject("{\"value\":\"SOMETHING_NEW4\",\"desc\":\"sent to vendor again\"}"));
 *  </pre>
 * Note that postgres does not update inplace the json but rather will create a new json with the
 * updated section and then reference the id to that newly created json
 * <br>
 * Queries generated will look something like this:
 * <pre>
 *
 * update test.po_line set jsonb = jsonb_set(jsonb, '{po_line_status}', '{"value":"SOMETHING_NEW4","desc":"sent to vendor"}') where _id = 19;
 * update test.po_line set jsonb = jsonb_set(jsonb, '{po_line_status, value}', '"SOMETHING_NEW5"', false) where _id = 15;
 * </pre>
 *
 * @param table - table to update
 * @param section - see UpdateSection class
 * @param when - Criterion object
 * @param replyHandler
 * @throws Exception
 *
 */
public void update(String table, UpdateSection section, Criterion when, boolean returnUpdatedIdsCount,
    Handler<AsyncResult<UpdateResult>> replyHandler) throws Exception {
  long start = System.nanoTime();
  client.getConnection(res -> {
    if (res.succeeded()) {
      SQLConnection connection = res.result();
      StringBuilder sb = new StringBuilder();
      if (when != null) {
        sb.append(when.toString());
      }
      StringBuilder returning = new StringBuilder();
      if (returnUpdatedIdsCount) {
        returning.append(returningId);
      }
      try {
        String q = UPDATE + convertToPsqlStandard(tenantId) + "." + table + SET + DEFAULT_JSONB_FIELD_NAME + " = jsonb_set(" + DEFAULT_JSONB_FIELD_NAME + ","
            + section.getFieldsString() + ", '" + section.getValue() + "', false) " + sb.toString() + " " + returning;
        log.debug("query = " + q);
        connection.update(q, query -> {
          connection.close();
          if (query.failed()) {
            log.error(query.cause().getMessage(), query.cause());
            replyHandler.handle(Future.failedFuture(query.cause()));
          } else {
            replyHandler.handle(Future.succeededFuture(query.result()));
          }
          long end = System.nanoTime();
          StatsTracker.addStatElement(STATS_KEY+".update", (end-start));
          if(log.isDebugEnabled()){
            log.debug("timer: get " +q+ " (ns) " + (end-start));
          }
        });
      } catch (Exception e) {
        if(connection != null){
          connection.close();
        }
        log.error(e.getMessage(), e);
        replyHandler.handle(Future.failedFuture(e));
      }
    } else {
      replyHandler.handle(Future.failedFuture(res.cause()));
    }
  });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:80,代码来源:PostgresClient.java


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