本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.lte()
方法的一些代码示例,展示了Criteria.lte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.lte()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:lte
[英]Creates a criterion using the $lte operator.
[中]使用$lte运营商创建标准。
代码示例来源:origin: spring-projects/spring-data-mongodb
return criteria.lt(parameters.next());
case LESS_THAN_EQUAL:
return criteria.lte(parameters.next());
case BETWEEN:
return criteria.gt(parameters.next()).lt(parameters.next());
代码示例来源:origin: org.springframework.data/spring-data-mongodb
return criteria.lt(parameters.next());
case LESS_THAN_EQUAL:
return criteria.lte(parameters.next());
case BETWEEN:
return criteria.gt(parameters.next()).lt(parameters.next());
代码示例来源: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: keets2012/Lottor
@Override
public List<TxTransactionItem> listTxItemByDelay(Long delay) {
Timestamp current = new Timestamp(System.currentTimeMillis());
Timestamp ddl = new Timestamp(current.getTime() - delay * 60 * 1000);
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String toStr = sdf.format(ddl);
Criteria criteria = Criteria.where("createDate").lte(toStr).and("status").is(TransactionStatusEnum.PRE_COMMIT.getCode());
Query query = Query.query(criteria);
return mongoTemplate.find(query, TxTransactionItem.class, CollectionNameEnum.TxTransactionItem.name());
}
代码示例来源: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: 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.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: pl.edu.icm.crpd/crpd-persistence
@Override
public void deleteAllByCreationDateLessEqualTo(Date day) {
day = DateUtils.ceiling(day, Calendar.DAY_OF_MONTH);
mongoTemplate.remove(Query.query(Criteria.where("creationDate").lte(day)), ThesisTempLink.class);
}
}
代码示例来源:origin: keets2012/Lottor
@Override
public List<TransactionMsgAdapter> listTxMsgByDelay(Long delay) {
Long current = System.currentTimeMillis();
Long ddl = current - delay * 60 * 1000;
Criteria criteria = Criteria.where("createTime").lte(ddl).and("consumed").is(ConsumedStatus.UNCONSUMED.getStatus());
Query query = Query.query(criteria);
return mongoTemplate.find(query, TransactionMsgAdapter.class, CollectionNameEnum.TransactionMsg.name());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public Page<Launch> findModifiedBefore(String project, Date before,Pageable p) {
Query query = Query.query(Criteria.where(Modifiable.LAST_MODIFIED).lte((before)))
.addCriteria(Criteria.where(PROJECT_ID_REFERENCE).is(project));
query.with(p);
query.fields().include(ID_REFERENCE);
return pageByQuery(query, p, Launch.class);
}
代码示例来源: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);
Object valueToFind = ObjectId.isValid(filter.getValue()) ?
new ObjectId(filter.getValue()) :
this.castValue(criteriaHolder, filter.getValue(), INCORRECT_FILTER_PARAMETERS);
criteria.lte(valueToFind);
}
代码示例来源: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: rackerlabs/atom-hopper
private List<PersistedEntry> enhancedGetFeedPage(final String feedName, final PersistedEntry markerEntry,
final PageDirection direction, final CategoryCriteriaGenerator criteriaGenerator, final int pageSize) {
final LinkedList<PersistedEntry> feedPage = new LinkedList<PersistedEntry>();
final Query query = new Query(Criteria.where(FEED).is(feedName)).limit(pageSize);
criteriaGenerator.enhanceCriteria(query);
switch (direction) {
case FORWARD:
query.addCriteria(Criteria.where(DATE_LAST_UPDATED).gt(markerEntry.getCreationDate()));
query.sort().on(DATE_LAST_UPDATED, Order.ASCENDING);
feedPage.addAll(mongoTemplate.find(query, PersistedEntry.class, formatCollectionName(feedName)));
Collections.reverse(feedPage);
break;
case BACKWARD:
query.addCriteria(Criteria.where(DATE_LAST_UPDATED).lte(markerEntry.getCreationDate()));
query.sort().on(DATE_LAST_UPDATED, Order.DESCENDING);
feedPage.addAll(mongoTemplate.find(query, PersistedEntry.class, formatCollectionName(feedName)));
break;
}
return feedPage;
}
代码示例来源: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: 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;
}
}
代码示例来源:origin: 7040210/SuperBoot
operator.andOperator(
Criteria.where("execDate").lte(DateUtil.today()),
内容来源于网络,如有侵权,请联系作者删除!