本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.exists()
方法的一些代码示例,展示了Criteria.exists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.exists()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:exists
[英]Creates a criterion using the $exists operator.
[中]使用$exists运算符创建条件。
代码示例来源:origin: spring-projects/spring-data-mongodb
return param instanceof Pattern ? criteria.regex((Pattern) param) : criteria.regex(param.toString());
case EXISTS:
return criteria.exists((Boolean) parameters.next());
case TRUE:
return criteria.is(true);
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(true));
long count = this.mongoTemplate.count(query, this.collectionName);
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
return (int) count;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(true));
long count = this.template.count(query, this.collectionName);
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
return (int) count;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public Iterator<MessageGroup> iterator() {
Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
Iterable<String> groupIds = mongoTemplate.getCollection(collectionName)
.distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), String.class);
return StreamSupport.stream(groupIds.spliterator(), false)
.map(this::getMessageGroup)
.iterator();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public Iterator<MessageGroup> iterator() {
List<MessageGroup> messageGroups = new ArrayList<>();
Query query = Query.query(Criteria.where(GROUP_ID_KEY).exists(true));
@SuppressWarnings("rawtypes")
Iterable<String> groupIds = this.template.getCollection(this.collectionName)
.distinct(GROUP_ID_KEY, query.getQueryObject(), String.class);
for (Object groupId : groupIds) {
messageGroups.add(getMessageGroup(groupId));
}
return messageGroups.iterator();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public long getMessageCount() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(false));
return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageGroupCount() {
Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
return this.mongoTemplate.getCollection(this.collectionName)
.distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
.into(new ArrayList<>())
.size();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public int getMessageGroupCount() {
Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
return this.template.getCollection(this.collectionName)
.distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
.into(new ArrayList<>())
.size();
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
return param instanceof Pattern ? criteria.regex((Pattern) param) : criteria.regex(param.toString());
case EXISTS:
return criteria.exists((Boolean) parameters.next());
case TRUE:
return criteria.is(true);
代码示例来源:origin: org.springframework.integration/spring-integration-mongodb
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
.and(MessageDocumentFields.GROUP_ID).exists(true));
long count = this.template.count(query, this.collectionName);
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
return (int) count;
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public List<String> getUniqueTicketsCount(List<Launch> launches) {
List<String> launchIds = launches.stream().map(Launch::getId).collect(toList());
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds)), match(where(ISSUE_TICKET).exists(true)),
unwind(ISSUE_TICKET), group(ISSUE_TICKET)
);
// Count be as
// Aggregation.group("issue.externalSystemIssues").count().as("count");
// but keep a whole
AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, TestItem.class, Map.class);
return result.getMappedResults().stream().map(entry -> entry.get("ticketId").toString()).collect(toList());
}
代码示例来源:origin: com.capitalone.dashboard/core
@Override
public List<com.capitalone.dashboard.model.Component> findComponents(CollectorType collectorType) {
Criteria c = Criteria.where("collectorItems." + collectorType).exists(true);
return template.find(new Query(c), com.capitalone.dashboard.model.Component.class);
}
代码示例来源:origin: org.springframework.integration/spring-integration-mongodb
@Override
public Iterator<MessageGroup> iterator() {
List<MessageGroup> messageGroups = new ArrayList<>();
Query query = Query.query(Criteria.where(GROUP_ID_KEY).exists(true));
@SuppressWarnings("rawtypes")
Iterable<String> groupIds = this.template.getCollection(this.collectionName)
.distinct(GROUP_ID_KEY, query.getQueryObject(), String.class);
for (Object groupId : groupIds) {
messageGroups.add(getMessageGroup(groupId));
}
return messageGroups.iterator();
}
代码示例来源:origin: org.springframework.integration/spring-integration-mongodb
@Override
@ManagedAttribute
public int getMessageGroupCount() {
Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
return this.mongoTemplate.getCollection(this.collectionName)
.distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
.into(new ArrayList<>())
.size();
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
@Override
public List<FlowDefinitionElement> findFlowsWithoutHash() {
Query query = new Query();
query.addCriteria(Criteria.where(CONTENT_HASH_KEY).exists(false));
return mongoTemplate.find(query, FlowDefinitionElement.class, collectionName);
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<TestItem> findInIssueTypeItems(String issueType, String launchId) {
Query query = query(where(LAUNCH_REFERENCE).is(launchId)).addCriteria(where(ISSUE).exists(true))
.addCriteria(where(ISSUE_TYPE).regex(Pattern.quote(issueType)));
return mongoTemplate.find(query, TestItem.class);
}
代码示例来源:origin: io.gravitee.repository/gravitee-repository-mongodb
@Override
public int findMaxPortalPageOrder() {
Query query = new Query();
query.limit(1);
query.with(new Sort(Sort.Direction.DESC, "order"));
query.addCriteria(where("api").exists(false));
PageMongo page = mongoTemplate.findOne(query, PageMongo.class);
return (page != null) ? page.getOrder() : 0;
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<TestItem> findItemsNotInIssueType(String issueType, String launchId) {
Query query = query(where(LAUNCH_REFERENCE).is(launchId)).addCriteria(where(ISSUE).exists(true))
.addCriteria(where(ISSUE_TYPE).ne(issueType));
return mongoTemplate.find(query, TestItem.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<RetryObject> findRetries(String launchId) {
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).is(launchId).and("retryProcessed").exists(true)),
sort(new Sort(Sort.Direction.ASC, "start_time")), group(Fields.fields("$uniqueId")).push(ROOT).as("retries")
);
return mongoTemplate.aggregate(aggregation, mongoTemplate.getCollectionName(TestItem.class), RetryObject.class).getMappedResults();
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<TestItem> findForSpecifiedSubType(List<String> launchesIds, boolean hasChild, StatisticSubType type) {
String issueField =
"statistics.issueCounter." + TestItemIssueType.valueOf(type.getTypeRef()).awareStatisticsField() + "." + type.getLocator();
Query query = query(where(LAUNCH_REFERENCE).in(launchesIds)).addCriteria(where(HAS_CHILD).is(hasChild))
.addCriteria(where(issueField).exists(true))
.with(new Sort(Sort.Direction.ASC, START_TIME));
return mongoTemplate.find(query, TestItem.class);
}
内容来源于网络,如有侵权,请联系作者删除!