本文整理了Java中org.springframework.data.mongodb.core.query.Field
类的一些代码示例,展示了Field
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field
类的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Field
类名称:Field
暂无
代码示例来源:origin: kaaproject/kaa
@Override
public MongoEndpointProfile findEndpointIdByKeyHash(byte[] endpointKeyHash) {
LOG.debug("Get count of endpoint profiles by endpoint key hash [{}] ", endpointKeyHash);
Query query = query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash));
query.fields().include(ID);
return findOne(query);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
public Field fields() {
if (this.fieldSpec == null) {
this.fieldSpec = new Field();
}
return this.fieldSpec;
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* @return the field {@link Document}.
*/
public Document getFieldsObject() {
return this.fieldSpec == null ? new Document() : fieldSpec.getFieldsObject();
}
代码示例来源:origin: sentilo/sentilo
public Query getDistinctSensorByProviderTypeQuery(final String providerId) {
final Query query = Query.query(Criteria.where("providerId").is(providerId));
query.fields().include("type");
query.fields().exclude("_id");
return query;
}
}
代码示例来源:origin: spring-projects/spring-integration
/**
* Get the {@code value} for the provided {@code key} performing {@code findOne} MongoDB operation.
* @param key the metadata entry key
* @return the metadata entry value or null if doesn't exist.
* @see MongoTemplate#findOne(Query, Class, String)
*/
@Override
public String get(String key) {
Assert.hasText(key, "'key' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key));
query.fields().exclude(ID_FIELD);
@SuppressWarnings("unchecked")
Map<String, String> result = this.template.findOne(query, Map.class, this.collectionName);
return result == null ? null : result.get(VALUE);
}
代码示例来源:origin: sentilo/sentilo
public Query getDistinctComponentByProviderTypeQuery(final String providerId) {
final Query query = Query.query(Criteria.where("providerId").is(providerId));
query.fields().include("componentType");
query.fields().exclude("_id");
return query;
}
代码示例来源:origin: spring-projects/spring-integration
/**
* Remove the metadata entry for the provided {@code key} and return its {@code value}, if any,
* using {@code findAndRemove} MongoDB operation.
* @param key the metadata entry key
* @return the metadata entry value or null if doesn't exist.
* @see MongoTemplate#findAndRemove(Query, Class, String)
*/
@Override
public String remove(String key) {
Assert.hasText(key, "'key' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key));
query.fields().exclude(ID_FIELD);
@SuppressWarnings("unchecked")
Map<String, String> result = this.template.findAndRemove(query, Map.class, this.collectionName);
return result == null ? null : result.get(VALUE);
}
代码示例来源:origin: kaaproject/kaa
@Override
public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) {
LOG.debug("Find endpoint profile body by endpoint key hash [{}] ", endpointKeyHash);
EndpointProfileBodyDto endpointProfileBodyDto = null;
Query query = Query.query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash));
query.fields()
.include(DaoConstants.PROFILE)
.include(EP_SERVER_PROFILE_PROPERTY)
.include(EP_APPLICATION_ID)
.include(EP_PROFILE_VERSION)
.include(EP_SERVER_PROFILE_VERSION_PROPERTY)
.include(EP_USE_RAW_SCHEMA);
EndpointProfileDto pf = mongoTemplate.findOne(query, getDocumentClass()).toDto();
if (pf != null) {
endpointProfileBodyDto = new EndpointProfileBodyDto(
endpointKeyHash,
pf.getClientProfileBody(),
pf.getServerProfileBody(),
pf.getClientProfileVersion(),
pf.getServerProfileVersion(),
pf.getApplicationId());
}
LOG.debug("[{}] Found client-side endpoint profile body {} with client-side endpoint "
+ "profile version {} and server-side endpoint profile body {} "
+ "with server-side endpoint profile version {} and application id {}",
endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(),
pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId());
return endpointProfileBodyDto;
}
代码示例来源:origin: sentilo/sentilo
public CatalogAdditionalFields getAdditionalFields(final String alertId) {
CatalogAdditionalFields additionalFields = alertAdditionalFieldsCache.get(alertId);
if (additionalFields == null) {
// The first step is to retrieve the component associated with alert {alertId}
Query query = Query.query(Criteria.where("_id").is(alertId));
query.fields().include("componentId");
query.fields().exclude("_id");
final CatalogAdditionalFields alertFields = mongoOperations.findOne(query, CatalogAdditionalFields.class, "alert");
// Later, retrieve the component location and its type (mobile or static)
if (alertFields != null) {
query = Query.query(Criteria.where("_id").is(alertFields.getComponentId()));
query.fields().include("location.centroid");
query.fields().exclude("_id");
query.fields().include("mobile");
final CatalogAdditionalFields componentFields = mongoOperations.findOne(query, CatalogAdditionalFields.class, "component");
if (componentFields.getMobile() == 0) {
componentFields.setComponentId(alertFields.getComponentId());
// If component is static (i.e mobile == 0), then componentFields is cached.
alertAdditionalFieldsCache.put(alertId, componentFields);
additionalFields = componentFields;
}
}
}
return additionalFields;
}
代码示例来源:origin: spring-projects/spring-integration
/**
* If the specified key is not already associated with a value, associate it with the given value.
* This is equivalent to
* <pre> {@code
* if (!map.containsKey(key))
* return map.put(key, value);
* else
* return map.get(key);
* }</pre>
* except that the action is performed atomically.
* <p>
* @param key the metadata entry key
* @param value the metadata entry value to store
* @return null if successful, the old value otherwise.
* @see java.util.concurrent.ConcurrentMap#putIfAbsent(Object, Object)
*/
@Override
public String putIfAbsent(String key, String value) {
Assert.hasText(key, "'key' must not be empty.");
Assert.hasText(value, "'value' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key));
query.fields().exclude(ID_FIELD);
@SuppressWarnings("unchecked")
Map<String, String> result = this.template.findAndModify(query, new Update().setOnInsert(VALUE, value),
new FindAndModifyOptions().upsert(true), Map.class, this.collectionName);
return result == null ? null : result.get(VALUE);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
public Field fields() {
if (this.fieldSpec == null) {
this.fieldSpec = new Field();
}
return this.fieldSpec;
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* @return the field {@link Document}.
*/
public Document getFieldsObject() {
return this.fieldSpec == null ? new Document() : fieldSpec.getFieldsObject();
}
代码示例来源:origin: kaaproject/kaa
query.skip(offs).limit(lim + 1);
query.fields()
.include(DaoConstants.PROFILE)
.include(EP_SERVER_PROFILE_PROPERTY)
.include(EP_ENDPOINT_KEY_HASH)
.include(EP_APPLICATION_ID)
.include(EP_PROFILE_VERSION)
.include(EP_SERVER_PROFILE_VERSION_PROPERTY)
.include(EP_USE_RAW_SCHEMA);
List<EndpointProfileDto> endpointProfileDtoList = convertDtoList(
mongoTemplate.find(query, getDocumentClass()));
代码示例来源:origin: sentilo/sentilo
public CatalogAdditionalFields getAlertAdditionalFields(final String alertId) {
CatalogAdditionalFields additionalFields = alertAdditionalFieldsCache.get(alertId);
if (additionalFields == null) {
// The first step is to retrieve the component associated with alert {alertId}
Query query = Query.query(Criteria.where("_id").is(alertId));
query.fields().include("componentId");
query.fields().exclude("_id");
final CatalogAdditionalFields alertFields = mongoOperations.findOne(query, CatalogAdditionalFields.class, "alert");
// Later, retrieve the component location and its type (mobile or static)
if (alertFields != null) {
query = Query.query(Criteria.where("_id").is(alertFields.getComponentId()));
query.fields().exclude("_id");
query.fields().include("mobile");
final CatalogAdditionalFields componentFields = mongoOperations.findOne(query, CatalogAdditionalFields.class, "component");
if (componentFields.getMobile() == 0) {
componentFields.setComponentId(alertFields.getComponentId());
// If component is static (i.e mobile == 0), then componentFields is cached.
alertAdditionalFieldsCache.put(alertId, componentFields);
additionalFields = componentFields;
}
}
}
return additionalFields;
}
代码示例来源:origin: org.springframework.integration/spring-integration-mongodb
/**
* Get the {@code value} for the provided {@code key} performing {@code findOne} MongoDB operation.
* @param key the metadata entry key
* @return the metadata entry value or null if doesn't exist.
* @see MongoTemplate#findOne(Query, Class, String)
*/
@Override
public String get(String key) {
Assert.hasText(key, "'key' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key));
query.fields().exclude(ID_FIELD);
@SuppressWarnings("unchecked")
Map<String, String> result = this.template.findOne(query, Map.class, this.collectionName);
return result == null ? null : result.get(VALUE);
}
代码示例来源:origin: kaaproject/kaa
private Long findVersionByKey(byte[] endpointKeyHash) {
LOG.debug("Find endpoint profile version by key hash [{}] ", endpointKeyHash);
Long version = null;
Query query = query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash));
query.fields().include(OPT_LOCK);
DBObject result = mongoTemplate.getDb()
.getCollection(getCollectionName())
.findOne(query.getQueryObject());
if (result != null) {
version = (Long) result.get(OPT_LOCK);
}
return version;
}
代码示例来源: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;
}
代码示例来源:origin: org.springframework.integration/spring-integration-mongodb
/**
* Remove the metadata entry for the provided {@code key} and return its {@code value}, if any,
* using {@code findAndRemove} MongoDB operation.
* @param key the metadata entry key
* @return the metadata entry value or null if doesn't exist.
* @see MongoTemplate#findAndRemove(Query, Class, String)
*/
@Override
public String remove(String key) {
Assert.hasText(key, "'key' must not be empty.");
Query query = new Query(Criteria.where(ID_FIELD).is(key));
query.fields().exclude(ID_FIELD);
@SuppressWarnings("unchecked")
Map<String, String> result = this.template.findAndRemove(query, Map.class, this.collectionName);
return result == null ? null : result.get(VALUE);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
fields.include(field);
代码示例来源:origin: com.bosch.bis.apiregistry/apidocrepo-apidocrepoclient-interface
private static Query createApiDocQuery(String clientId, String apiId) {
Query query = new Query()
.addCriteria(Criteria.where(ApiDocNames.CLIENT_ID).is(clientId))
.addCriteria(Criteria.where(ApiDocNames.API_ID).is(apiId));
query.fields().exclude(ApiDocNames.SWAGGER);
query.fields().exclude(ApiDocNames.BASE_API_DRAFT);
return query;
}
}
内容来源于网络,如有侵权,请联系作者删除!