本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.orOperator()
方法的一些代码示例,展示了Criteria.orOperator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.orOperator()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:orOperator
[英]Creates an 'or' criteria using the $or operator for all of the provided criteria
Note that mongodb doesn't support an $or operator to be wrapped in a $not operator.
[中]使用$or运算符为所有提供的条件创建“或”条件
请注意,mongodb不支持将$or运算符包装在$not运算符中。
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
protected Criteria or(Criteria base, Criteria criteria) {
Criteria result = new Criteria();
return result.orOperator(base, criteria);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
public Query getByIdInQuery(Collection<?> entities) {
MultiValueMap<String, Object> byIds = new LinkedMultiValueMap<>();
entities.stream() //
.map(this::forEntity) //
.forEach(it -> byIds.add(it.getIdFieldName(), it.getId()));
Criteria[] criterias = byIds.entrySet().stream() //
.map(it -> Criteria.where(it.getKey()).in(it.getValue())) //
.toArray(Criteria[]::new);
return new Query(criterias.length == 1 ? criterias[0] : new Criteria().orOperator(criterias));
}
代码示例来源:origin: kaaproject/kaa
@Override
public EndpointProfilesPageDto findByEndpointGroupId(PageLinkDto pageLink) {
LOG.debug("Find endpoint profiles by endpoint group id [{}] ",
pageLink.getEndpointGroupId());
EndpointProfilesPageDto endpointProfilesPageDto = new EndpointProfilesPageDto();
int lim = Integer.valueOf(pageLink.getLimit());
int offs = Integer.valueOf(pageLink.getOffset());
List<MongoEndpointProfile> mongoEndpointProfileList = find(
query(new Criteria()
.orOperator(where(EP_GROUP_STATE + "." + ENDPOINT_GROUP_ID)
.is(pageLink.getEndpointGroupId()),
where(EP_GROUP_STATE + "." + ENDPOINT_GROUP_ID)
.is(pageLink.getEndpointGroupId())))
.skip(offs)
.limit(lim + 1));
if (mongoEndpointProfileList.size() == (lim + 1)) {
String offset = Integer.toString(lim + offs);
pageLink.setOffset(offset);
mongoEndpointProfileList.remove(lim);
} else {
pageLink.setNext(DaoConstants.LAST_PAGE_MESSAGE);
}
endpointProfilesPageDto.setPageLinkDto(pageLink);
endpointProfilesPageDto.setEndpointProfiles(convertDtoList(mongoEndpointProfileList));
return endpointProfilesPageDto;
}
代码示例来源: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: kaaproject/kaa
Query query = Query.query(
new Criteria()
.orOperator(
where(EP_GROUP_STATE + "." + ENDPOINT_GROUP_ID)
.is(pageLink.getEndpointGroupId()),
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
protected Criteria or(Criteria base, Criteria criteria) {
Criteria result = new Criteria();
return result.orOperator(base, criteria);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
public Query getByIdInQuery(Collection<?> entities) {
MultiValueMap<String, Object> byIds = new LinkedMultiValueMap<>();
entities.stream() //
.map(this::forEntity) //
.forEach(it -> byIds.add(it.getIdFieldName(), it.getId()));
Criteria[] criterias = byIds.entrySet().stream() //
.map(it -> Criteria.where(it.getKey()).in(it.getValue())) //
.toArray(Criteria[]::new);
return new Query(criterias.length == 1 ? criterias[0] : new Criteria().orOperator(criterias));
}
代码示例来源:origin: com.github.rutledgepaulv/q-builders
@Override
protected Criteria visit(OrNode node) {
Criteria criteria = new Criteria();
List<Criteria> children = node.getChildren().stream()
.map(this::visitAny).collect(Collectors.toList());
return criteria.orOperator(children.toArray(new Criteria[children.size()]));
}
代码示例来源:origin: com.bq.oss.lib/queries-mongo
public Criteria getCriteriaFromResourceQueries(List<ResourceQuery> resourceQueries) {
List<Criteria> criterias = new ArrayList<>();
for (ResourceQuery resourceQuery : resourceQueries) {
criterias.add(getCriteriaFromResourceQuery(resourceQuery));
}
if (criterias.size() == 0) {
return new Criteria();
} else if (criterias.size() == 1) {
return criterias.get(0);
} else {
return new Criteria().orOperator(criterias.toArray(new Criteria[criterias.size()]));
}
}
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
currentEntityIds.add(ite.next());
if (i % chunkSize == (chunkSize - 1)) {
splittedInlist.orOperator(Criteria.where(IEntity.ID).in(currentEntityIds));
currentEntityIds = new LinkedHashSet<>();
complete = true;
splittedInlist.orOperator(Criteria.where(IEntity.ID).in(currentEntityIds));
代码示例来源:origin: com.epam.reportportal/commons-dao
/**
* Query of getting item child and item itself
*
* @param objectId Parent item
* @return Query
*/
private Query queryItems(String objectId) {
Criteria criteria = new Criteria();
criteria.orOperator(Criteria.where("path").in(singletonList(objectId)), Criteria.where("_id").is(objectId));
return Query.query(criteria);
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-core
private Criteria unconfirmedCriterion() {
return new Criteria()
.orOperator(
citationTextChangedCriterion(Boolean.TRUE),
targetArticleChangedCriterion(Boolean.TRUE),
proposalsExistsCriterion(Boolean.TRUE),
errorCriterion()
);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
private Query buildSearchUserQuery(String term, Pageable pageable) {
final String regex = "(?i).*" + Pattern.quote(term.toLowerCase()) + ".*";
Criteria login = where(LOGIN).regex(regex);
Criteria fullName = where(FULLNAME_DB_FIELD).regex(regex);
Criteria email = where(User.EMAIL).regex(regex);
Criteria criteria = new Criteria().orOperator(email, login, fullName);
return query(criteria).with(pageable);
}
代码示例来源:origin: danielfernandez/reactive-matchday
private Mono<MatchEvent> createEvent(final Match match) {
// Will create a match event of a random type for the selected match (and a random player)
final Query query =
Query.query(
new Criteria().orOperator(
Criteria.where("teamCode").is(match.getTeamACode()),
Criteria.where("teamCode").is(match.getTeamBCode())));
final Flux<Player> playersForMatch =
this.mongoTemplate.find(query, Player.class);
final Mono<Player> chosenPlayer =
playersForMatch.collectList().map(this::randomFromList);
return chosenPlayer.map(
p -> new MatchEvent(match.getId(), MatchEventUtils.randomEventType(), p.getTeamCode(), p.getId()));
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-core
private Criteria precedingByModificationDateAndIdCriterion(Date date, String id) {
Criteria criteria = new Criteria()
.orOperator(
Criteria.where(PROPERTY_MODIFICATION_DATE).lt(date),
new Criteria().andOperator(
Criteria.where(PROPERTY_MODIFICATION_DATE).is(date),
Criteria.where(F_ID).lt(id)
)
);
return criteria;
}
代码示例来源: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: com.epam.reportportal/commons-dao
@Override
public Page<T> findSharedEntitiesByName(String projectName, String term, Pageable pageable) {
final String regex = "(?i).*" + Pattern.quote(term.toLowerCase()) + ".*";
Query query = createSharedEntityQuery(projectName).with(pageable);
Criteria name = Criteria.where(ENTITY_NAME_FIELD).regex(regex);
Criteria owner = Criteria.where(ENTITY_OWNER_FIELD).regex(regex);
Criteria description = Criteria.where(ENTITY_DESCRIPTION_FIELD).regex(regex);
query.addCriteria(new Criteria().orOperator(name, owner, description));
Class<T> entityType = getEntityInformation().getJavaType();
List<T> searchResults = getMongoOperations().find(query, entityType);
return new PageImpl<>(searchResults, pageable, getMongoOperations().count(query, entityType));
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<UserFilter> findAvailableFilters(String projectName, String[] ids, String userName) {
//where ID from provided array AND it's shared on project
Query q = Query.query(where(ID).in(Arrays.asList(ids))
.andOperator(new Criteria()
.orOperator(
where(OWNER).is(userName),
where(PROJECT).is(projectName),
where(ENTRIES).elemMatch(where("projectId").is(projectName)))));
return mongoTemplate.find(q, UserFilter.class);
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
/**
* Create criteria for loading owned entities and shared to specified project entities
*
* @param projectName
* @param userName
* @return
*/
private Criteria getAllEntitiesCriteria(String projectName, String userName) {
return new Criteria().orOperator(new Criteria().andOperator(Criteria.where("acl.entries.projectId").is(projectName),
Criteria.where("acl.entries.permissions").is(AclPermissions.READ.name())
), new Criteria().andOperator(Criteria.where("acl.ownerUserId").is(userName), Criteria.where("projectName").is(projectName)));
}
}
代码示例来源:origin: sentilo/sentilo
protected Query buildQuery(final SearchFilter filter, final boolean pageable, final Criteria customCriteria) {
Criteria queryCriteria = new Criteria();
// If customCriteria is not null, initialize queryCriteria with this criteria
if (customCriteria != null) {
queryCriteria = customCriteria;
}
if (!filter.andParamsIsEmpty()) {
final Criteria[] aCriteria = buildAndParamsCriteria(filter.getAndParams());
queryCriteria = queryCriteria.andOperator(aCriteria);
}
if (!filter.paramsIsEmpty()) {
final Criteria[] aCriteria = buildOrParamsCriteria(filter.getParams());
queryCriteria = queryCriteria.orOperator(aCriteria);
}
final Query query = new Query(queryCriteria);
if (!filter.includeFieldsIsEmpty()) {
for (final String field : filter.getIncludeFields()) {
query.fields().include(field);
}
}
if (!filter.excludeFieldsIsEmpty()) {
for (final String field : filter.getExcludeFields()) {
query.fields().exclude(field);
}
}
if (pageable) {
query.with(filter.getPageable());
}
return query;
}
内容来源于网络,如有侵权,请联系作者删除!