org.springframework.data.mongodb.core.query.Criteria.gte()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(216)

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

Criteria.gte介绍

[英]Creates a criterion using the $gte operator.
[中]使用$gte运算符创建标准。

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

return criteria.gt(parameters.next());
case GREATER_THAN_EQUAL:
  return criteria.gte(parameters.next());
case BEFORE:
case LESS_THAN:

代码示例来源:origin: org.springframework.data/spring-data-mongodb

return criteria.gt(parameters.next());
case GREATER_THAN_EQUAL:
  return criteria.gte(parameters.next());
case BEFORE:
case LESS_THAN:

代码示例来源:origin: pl.edu.icm.polindex/polindex-core

private Criteria targetPublishedYearRangeCriterion(int beginYear, int endYear) {
  return Criteria.where(PROPERTY_TARGET_PUBLISHED_YEAR)
      .gte(beginYear)
      .lte(endYear);
}

代码示例来源:origin: pl.edu.icm.polindex/polindex-core

private Criteria targetPublishedYearRangeCriterion(Integer beginYear, Integer endYear) {
  Criteria result = Criteria.where(F_PUBLISHED_YEAR);
  
  if (beginYear != null) {
    result.gte(beginYear);
  }
  if (endYear != null) {
    result.lte(endYear);
  }
  
  return result;
}

代码示例来源:origin: io.gravitee.repository/gravitee-repository-mongodb

@Override
public Iterator<RateLimit> findAsyncAfter(long timestamp) {
  final Query query = Query.query(Criteria.where(FIELD_ASYNC).is(true).and(FIELD_UPDATED_AT).gte(timestamp));
  return mongoOperations.find(query, Document.class, RATE_LIMIT_COLLECTION)
      .stream()
      .map(this::convert)
      .iterator();
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public void addCondition(Criteria criteria, FilterCondition filter, CriteriaHolder criteriaHolder) {
  this.validate(criteriaHolder, filter.getValue(), filter.isNegative(), INCORRECT_FILTER_PARAMETERS);
  Object[] castedValues;
  if (filter.getValue().contains(",")) {
    castedValues = (Object[]) this.castValue(criteriaHolder, filter.getValue(), INCORRECT_FILTER_PARAMETERS);
  } else {
    String[] values = filter.getValue().split(";");
    ZoneOffset offset = ZoneOffset.of(values[2]);
    ZonedDateTime localDateTime = ZonedDateTime.now(offset).toLocalDate().atStartOfDay(offset);
    long start = from(localDateTime.plusMinutes(parseLong(values[0])).toInstant()).getTime();
    long end = from(localDateTime.plusMinutes(parseLong(values[1])).toInstant()).getTime();
    String newValue = start + "," + end;
    castedValues = (Object[]) this.castValue(criteriaHolder, newValue, INCORRECT_FILTER_PARAMETERS);
  }
  criteria.gte(castedValues[0]).lte(castedValues[1]);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-audit-mongo

@Override
  public Set<? extends AuditActionContext> getAuditRecordsSince(final LocalDate localDate) {
    val dt = DateTimeUtils.dateOf(localDate);
    LOGGER.debug("Retrieving audit records since [{}] from [{}]", dt, this.collectionName);
    val query = new Query().addCriteria(Criteria.where("whenActionWasPerformed").gte(dt));
    return new LinkedHashSet<>(this.mongoTemplate.find(query, AuditActionContext.class, this.collectionName));
  }
}

代码示例来源:origin: keets2012/Lottor

private Long countTxMsgs(Timestamp from, Timestamp to) {
  DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  String toStr = "";
  String fromStr = "";
  try {
    toStr = sdf.format(to);
    fromStr = sdf.format(from);
  } catch (Exception e) {
    LogUtil.error(LOGGER, "日期转换错误,cause is {}", e::getLocalizedMessage);
    throw new IllegalArgumentException("请检查传入的日期参数!");
  }
  Criteria criteria = Criteria.where("createDate").lte(toStr).gte(fromStr);
  Query query = Query.query(criteria);
  return mongoTemplate.count(query, TxTransactionItem.class, CollectionNameEnum.TxTransactionItem.name());
}

代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl

@Override
public List<ObservationObjectCount> getMostObservedObjects(ObservationObjectType objectType, Date fromDate, int limit) {
  Criteria criteria = Criteria.where(QUERY_PARAM_OBJECT_TYPE).is(objectType.name());
  if (fromDate != null) {
    criteria.andOperator(Criteria.where(QUERY_PARAM_CREATION_TIMESTAMP).gte(fromDate));
  }
  GroupBy groupBy = GroupBy.key(QUERY_PARAM_OBJECT_ID).initialDocument("{ count: 0 }").reduceFunction("function(doc, prev) { prev.count += 1 }");
  GroupByResults<ObservationObjectCount> groupByResults = mongoTemplate.group(criteria, mongoCollectionName, groupBy, ObservationObjectCount.class);
  List<ObservationObjectCount> result = new ArrayList<ObservationObjectCount>();
  for (Iterator<ObservationObjectCount> iterator = groupByResults.iterator(); iterator.hasNext();) {
    ObservationObjectCount objectCount = (ObservationObjectCount) iterator.next();
    result.add(objectCount);
  }
  Collections.sort(result);
  Collections.reverse(result);
  result = result.subList(0, limit);
  return result;
}

代码示例来源:origin: pl.edu.icm.polindex/polindex-tools

/**
 * Adds (inclusive) range criterion.
 * Query is not modified if both min and max objects are null. 
 */
public static void addRangeCriterion(Query query, String key, Object min, Object max) {
  if (min!=null || max!=null) {
    Criteria range = Criteria.where(key);
    
    if (min!=null) {
      range.gte(min);    
    }
    
    if (max!=null) {
      range.lte(max);
    }
    
    query.addCriteria(range);
  }
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public void addCondition(Criteria criteria, FilterCondition filter, CriteriaHolder criteriaHolder) {
  /* Validate only numbers & dates */
  this.validate(criteriaHolder, filter.getValue(), filter.isNegative(), INCORRECT_FILTER_PARAMETERS);
  criteria.gte(this.castValue(criteriaHolder, filter.getValue(), INCORRECT_FILTER_PARAMETERS));
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public List<Log> findTestItemErrorLogs(String testItemId, int limit) {
  Query query = query(where(ITEM_REFERENCE).is(testItemId)).addCriteria(where(LOG_LEVEL).gte(LogLevel.ERROR_INT))
      .limit(limit);
  return mongoTemplate.find(query, Log.class);
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public List<Log> findGreaterOrEqualLevel(List<String> testItemIds, LogLevel level) {
  Query query = query(where(ITEM_REFERENCE).in(testItemIds)).addCriteria(where(LOG_LEVEL).gte(level.toInt()));
  return mongoTemplate.find(query, Log.class);
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public Stream<Launch> streamModifiedInRange(String project, Date from, Date to) {
  Query query = Query.query(Criteria.where(Modifiable.LAST_MODIFIED).gte(from).lte((to)))
      .addCriteria(Criteria.where(PROJECT_ID_REFERENCE).is(project));
  query.fields().include(ID_REFERENCE);
  return Streams.stream(mongoTemplate.stream(query, Launch.class));
}

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

private Query buildPageableQuery(final Long from, final Long to) {
 // By default get 20 elements
 final int limit = 20;
 final Pageable pageable = new PageRequest(0, limit, Direction.DESC, "timestamp");
 final SearchFilter filter = new SearchFilter(pageable);
 if (TenantContextHolder.isEnabled()) {
  filter.addAndParam("tenant", TenantUtils.getRequestTenant());
 }
 final Criteria customCriteria = Criteria.where("timestamp").lte(to == null ? CatalogUtils.getMaxSystemTimeMillis() : to);
 if (from != null) {
  customCriteria.gte(from);
 }
 return buildQuery(filter, true, customCriteria);
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public Page<Launch> findModifiedInRange(String project, Date from, Date to, Pageable p) {
  Query query = Query.query(Criteria.where(Modifiable.LAST_MODIFIED).gte(from).lte((to)))
      .addCriteria(Criteria.where(PROJECT_ID_REFERENCE).is(project));
  query.with(p);
  query.fields().include(ID_REFERENCE);
  return pageByQuery(query, p, Launch.class);
}

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

@Override
public List<InvocationCount> aggregateDailyStatistics(String afterday, String beforeday) {
 // Build a query to pre-select the statistics that will be aggregated.
 Aggregation aggregation = newAggregation(
    match(Criteria.where("day").gte(afterday).lte(beforeday)),
    group("day").sum("dailyCount").as("number"),
    project("number").and("day").previousOperation(),
    sort(ASC, "day")
 );
 AggregationResults<InvocationCount> results = template.aggregate(aggregation, DailyStatistic.class, InvocationCount.class);
 return results.getMappedResults();
}

代码示例来源:origin: io.gravitee.repository/gravitee-repository-mongodb

@Override
  public Page<ApiKeyMongo> search(ApiKeyCriteria filter) {
    Query query = new Query();

    if (! filter.isIncludeRevoked()) {
      query.addCriteria(Criteria.where("revoked").is(false));
    }

    if (filter.getPlans() != null) {
      query.addCriteria(Criteria.where("plan").in(filter.getPlans()));
    }

    // set range query
    if (filter.getFrom() != 0 && filter.getTo() != 0) {
      query.addCriteria(Criteria.where("updatedAt").gte(new Date(filter.getFrom())).lt(new Date(filter.getTo())));
    }

    query.with(new Sort(Sort.Direction.DESC, "updatedAt"));

    List<ApiKeyMongo> events = mongoTemplate.find(query, ApiKeyMongo.class);
    long total = mongoTemplate.count(query, ApiKeyMongo.class);

    return new Page<>(events, 0, 0, total);
  }
}

代码示例来源:origin: melthaw/spring-backend-boilerplate

public static PageRequest processPagePart(Query query, PageQueryRequest queryRequest, Sort sort) {
  if (queryRequest instanceof DateRangedQueryRequest) {
    DateRangedQueryRequest dateRangedQueryRequest = (DateRangedQueryRequest) queryRequest;
    if (dateRangedQueryRequest.getBeginDate() != null && dateRangedQueryRequest.getEndDate() != null) {
      query.addCriteria(new Criteria().andOperator(Criteria.where("createdAt")
                                 .gte(dateRangedQueryRequest.getBeginDate()),
                             Criteria.where("createdAt")
                                 .lte(dateRangedQueryRequest.getEndDate())));
    }
    else if (dateRangedQueryRequest.getBeginDate() != null) {
      query.addCriteria(Criteria.where("createdAt").gte(dateRangedQueryRequest.getBeginDate()));
    }
    else if (dateRangedQueryRequest.getEndDate() != null) {
      query.addCriteria(Criteria.where("createdAt").lte(dateRangedQueryRequest.getEndDate()));
    }
  }
  int start = queryRequest.getStart();
  int limit = queryRequest.getLimit();
  PageRequest pageable = new PageRequest(start, limit, sort);
  query.with(pageable);
  return pageable;
}

代码示例来源:origin: dk.apaq.framework/criteria-mongo

public boolean interpret(Criteria clause, CompareRule filter) {
    
    Criteria c = clause.and(filter.getPropertyId());//Criteria.where(filter.getPropertyId());
    
    switch (filter.getCompareType()) {
      case Equals:
        c.is(filter.getValue());
        break;
      case GreaterOrEqual:
        c.gte(filter.getValue());
        break;
      case GreaterThan:
        c.gt(filter.getValue());
        break;
      case LessOrEqual:
        c.lte(filter.getValue());
        break;
      case LessThan:
        c.lt(filter.getValue());
        break;
    }
    return true;
  }
}

相关文章