本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.gt()
方法的一些代码示例,展示了Criteria.gt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.gt()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:gt
[英]Creates a criterion using the $gt operator.
[中]使用$gt运算符创建条件。
代码示例来源:origin: spring-projects/spring-data-mongodb
case AFTER:
case GREATER_THAN:
return criteria.gt(parameters.next());
case GREATER_THAN_EQUAL:
return criteria.gte(parameters.next());
return criteria.lte(parameters.next());
case BETWEEN:
return criteria.gt(parameters.next()).lt(parameters.next());
case IS_NOT_NULL:
return criteria.ne(null);
代码示例来源:origin: kaaproject/kaa
@Override
public List<MongoNotification>
findNotificationsByTopicIdAndVersionAndStartSecNum(
String topicId,
int seqNumber,
int sysNfVersion,
int userNfVersion
) {
LOG.debug("Find notifications by topic id [{}], sequence number start [{}], "
+ "system schema version [{}], user schema version [{}]",
topicId, seqNumber, sysNfVersion, userNfVersion);
return find(query(where(NF_TOPIC_ID)
.is(topicId)
.and(NF_SEQ_NUM)
.gt(seqNumber)
.orOperator(where(NF_VERSION)
.is(sysNfVersion)
.and(NF_TYPE)
.is(SYSTEM),
where(NF_VERSION)
.is(userNfVersion)
.and(NF_TYPE)
.is(USER))));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
case AFTER:
case GREATER_THAN:
return criteria.gt(parameters.next());
case GREATER_THAN_EQUAL:
return criteria.gte(parameters.next());
return criteria.lte(parameters.next());
case BETWEEN:
return criteria.gt(parameters.next()).lt(parameters.next());
case IS_NOT_NULL:
return criteria.ne(null);
代码示例来源:origin: com.epam.reportportal/commons-dao
/**
* Find entities modified lately
*
* @param period
* @return
*/
public static Query findModifiedLately(final Duration period) {
return Query.query(Criteria.where(Modifiable.LAST_MODIFIED).gt(Date.from(Instant.now().minusSeconds(period.getSeconds()))));
}
}
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
break;
case ComparableQueryStructureDescriptor.GT:
queryStructureRestriction.gt(compareValue);
break;
case ComparableQueryStructureDescriptor.GE:
代码示例来源:origin: pl.edu.icm.polindex/polindex-core
private Criteria followingByModificationDateAndIdCriterion(Date date, String id) {
Criteria criteria = new Criteria()
.orOperator(
Criteria.where(PROPERTY_MODIFICATION_DATE).gt(date),
new Criteria().andOperator(
Criteria.where(PROPERTY_MODIFICATION_DATE).is(date),
Criteria.where(F_ID).gt(id)
)
);
return criteria;
}
代码示例来源: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: Apereo-Learning-Analytics-Initiative/OpenLRW
query.addCriteria(where("event.eventTime").gt(dateFormat.parse(from)));
} catch (Exception e) {
throw new BadRequestException("Not able to parse the date, it has to be in the following format: `yyyy-MM-dd hh:mm` ");
query.addCriteria(where("event.eventTime").lt(dateFormat.parse(to)).gt(dateFormat.parse(from)));
} catch (Exception e) {
throw new BadRequestException("Not able to parse the date, it has to be in the following format: `yyyy-MM-dd hh:mm` ");
代码示例来源:origin: com.github.rutledgepaulv/q-builders
@Override
protected Criteria visit(ComparisonNode node) {
ComparisonOperator operator = node.getOperator();
Collection<?> values = node.getValues().stream().map(normalizer).collect(Collectors.toList());
String field = node.getField().asKey();
if(ComparisonOperator.EQ.equals(operator)) {
return where(field).is(single(values));
} else if(ComparisonOperator.NE.equals(operator)) {
return where(field).ne(single(values));
} else if (ComparisonOperator.EX.equals(operator)) {
return where(field).exists((Boolean)single(values));
} else if (ComparisonOperator.GT.equals(operator)) {
return where(field).gt(single(values));
} else if (ComparisonOperator.LT.equals(operator)) {
return where(field).lt(single(values));
} else if (ComparisonOperator.GTE.equals(operator)) {
return where(field).gte(single(values));
} else if (ComparisonOperator.LTE.equals(operator)) {
return where(field).lte(single(values));
} else if (ComparisonOperator.IN.equals(operator)) {
return where(field).in(values);
} else if (ComparisonOperator.NIN.equals(operator)) {
return where(field).nin(values);
} else if (ComparisonOperator.RE.equals(operator)) {
return where(field).regex((String)single(values));
} else if (ComparisonOperator.SUB_CONDITION_ANY.equals(operator)) {
return where(field).elemMatch(condition(node));
}
throw new UnsupportedOperationException("This visitor does not support the operator " + operator + ".");
}
代码示例来源: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.gt(this.castValue(criteriaHolder, filter.getValue(), INCORRECT_FILTER_PARAMETERS));
}
代码示例来源:origin: com.bq.oss.lib/queries-mongo
private Criteria criteria(QueryOperator operator, String field, QueryLiteral<?> value) {
Criteria criteria = new Criteria(field);
switch (operator) {
case $ALL:
return criteria.all(((ListQueryLiteral) value).getLiterals());
case $EQ:
return criteria.is(value.getLiteral());
case $GT:
return criteria.gt(value.getLiteral());
case $GTE:
return criteria.gte(value.getLiteral());
case $IN:
return criteria.in(((ListQueryLiteral) value).getLiterals());
case $NIN:
return criteria.nin(((ListQueryLiteral) value).getLiterals());
case $LT:
return criteria.lt(value.getLiteral());
case $LTE:
return criteria.lte(value.getLiteral());
case $NE:
return criteria.ne(value.getLiteral());
case $LIKE:
return criteria.regex((String) value.getLiteral(), "i"); // i means case insensitive
case $ELEM_MATCH:
return criteria.elemMatch(getCriteriaFromResourceQuery((ResourceQuery) value.getLiteral()));
case $EXISTS:
return criteria.exists((Boolean) value.getLiteral());
}
return criteria;
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Cacheable(value = { CacheConfiguration.PROJECT_INFO_CACHE })
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map<String, Integer> findGroupedLaunchesByOwner(String projectName, String mode, Date from) {
Map<String, Integer> output = new HashMap<>();
Aggregation aggregation = newAggregation(match(where(PROJECT_ID_REFERENCE).is(projectName)),
match(where(MODE).is(mode)),
match(where(STATUS).ne(IN_PROGRESS.name())),
match(where(START_TIME).gt(from)),
group("$userRef").count().as("count")
);
AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, Launch.class, Map.class);
for (Map<String, String> entry : result.getMappedResults()) {
String username = entry.get("_id");
String count = String.valueOf(entry.get("count"));
output.put(username, Integer.valueOf(count));
}
return output;
}
代码示例来源: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: com.epam.reportportal/commons-dao
@Override
public List<FlakyHistory> getFlakyItemStatusHistory(List<String> launchIds) {
/*
db.testItem.aggregate([
{ "$match" : { $and: [ "launchRef" : { "$in" : [""]}, has_childs : false ]}},
{ "$sort" : { "start_time" : 1}},
{ "$group" : {
"_id" : "$uniqueId" ,
"total" : { "$sum" : 1 },
"statusHistory" : { "$push" : {
"status" : "$status",
"time" : "$start_time"
}
},
"statusSet" : { "$addToSet" : "$status" },
"name" : {"$first" : "$name"},
}},
{ "$addFields" : { "size" : {"$size" : "$statusSet" }}},
{ "$match" : { "size " : {"$gt" : 1}}}
])
*/
final int MINIMUM_FOR_FLAKY = 1;
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds).and(HAS_CHILD).is(false)),
sort(Sort.Direction.ASC, START_TIME), flakyItemsGroup(), addFields("size", new BasicDBObject("$size", "$statusSet")),
match(where("size").gt(MINIMUM_FOR_FLAKY))
);
return mongoTemplate.aggregate(aggregation, mongoTemplate.getCollectionName(TestItem.class), FlakyHistory.class).getMappedResults();
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public Long findLaunchesQuantity(String projectId, String mode, Date from) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(STATUS).ne(IN_PROGRESS.name()))
.addCriteria(where(MODE).is(mode));
if (null != from) {
query = query.addCriteria(where(START_TIME).gt(from));
}
return mongoTemplate.count(query, Launch.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<Launch> findLaunchesByProjectId(String projectId, Date from, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(STATUS).ne(IN_PROGRESS.name()))
.addCriteria(where(MODE).is(mode))
.addCriteria(where(START_TIME).gt(from))
.with(new Sort(Sort.Direction.ASC, START_TIME));
return mongoTemplate.find(query, Launch.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
Sort orders = new Sort(new Sort.Order(DESC, FAILED), new Sort.Order(ASC, TOTAL));
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds).and(HAS_CHILD).is(false)),
sort(Sort.Direction.ASC, START_TIME), mostFailedGroup(criteria), match(where(FAILED).gt(MINIMUM_FOR_FAILED)), sort(orders),
limit(limit)
);
内容来源于网络,如有侵权,请联系作者删除!