public class MappingElasticsearchConverter extends Object implements ElasticsearchConverter, ApplicationContextAware, InitializingBean
EntityConverter
implementation based on domain type
metadata
.Constructor and Description |
---|
MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> mappingContext) |
MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> mappingContext,
GenericConversionService conversionService) |
Modifier and Type | Method and Description |
---|---|
protected void |
addCustomTypeKeyIfNecessary(Object source,
Map<String,Object> sink,
TypeInformation<?> type)
Adds custom typeInformation information to the given
Map if necessary. |
void |
afterPropertiesSet() |
protected List<Object> |
createCollection(Collection<?> collection,
ElasticsearchPersistentProperty property)
Writes the given
Collection using the given ElasticsearchPersistentProperty information. |
protected Map<String,Object> |
createMap(Map<?,?> map,
ElasticsearchPersistentProperty property)
Writes the given
Map using the given ElasticsearchPersistentProperty information. |
ConversionService |
getConversionService() |
MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> |
getMappingContext() |
protected Object |
getWriteComplexValue(ElasticsearchPersistentProperty property,
TypeInformation<?> typeHint,
Object value)
Deprecated.
since 4.2, use
writeInternal(Object, Map, TypeInformation) instead. |
protected Object |
getWriteSimpleValue(Object value)
Deprecated.
since 4.2, use
getPotentiallyConvertedSimpleWrite(Object, Class) instead. |
<R> R |
read(Class<R> type,
Document source) |
protected <R> R |
readEntity(ElasticsearchPersistentEntity<?> entity,
Map<String,Object> source) |
protected <R> R |
readProperties(ElasticsearchPersistentEntity<?> entity,
R instance,
org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.ElasticsearchPropertyValueProvider valueProvider) |
protected <R> R |
readValue(Object value,
ElasticsearchPersistentProperty property,
TypeInformation<?> type) |
boolean |
requiresTypeHint(Class<?> type)
Check if a given type requires a type hint (aka _class attribute) when writing to the document.
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setConversions(CustomConversions conversions)
Set the
CustomConversions to be applied during the mapping process. |
void |
updateCriteriaQuery(CriteriaQuery criteriaQuery,
Class<?> domainClass)
Updates a
CriteriaQuery by renaming the property names in the query to the correct mapped field names and
the values to the converted values if the ElasticsearchPersistentProperty for a property has a
ElasticsearchPersistentPropertyConverter . |
void |
write(Object source,
Document sink) |
protected void |
writeInternal(Object source,
Map<String,Object> sink,
ElasticsearchPersistentEntity<?> entity)
Internal write conversion method which should be used for nested invocations.
|
protected void |
writeInternal(Object source,
Map<String,Object> sink,
TypeInformation<?> typeInformation)
Internal write conversion method which should be used for nested invocations.
|
protected Map<String,Object> |
writeMapInternal(Map<?,?> source,
Map<String,Object> sink,
TypeInformation<?> propertyType)
|
protected void |
writeProperties(ElasticsearchPersistentEntity<?> entity,
PersistentPropertyAccessor<?> accessor,
org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.MapValueAccessor sink) |
protected void |
writeProperty(ElasticsearchPersistentProperty property,
Object value,
org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.MapValueAccessor sink) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertId, getProjectionFactory, mapObject, updateQuery
public MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> mappingContext)
public MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> mappingContext, @Nullable GenericConversionService conversionService)
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> getMappingContext()
getMappingContext
in interface EntityConverter<ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty,Object,Document>
public ConversionService getConversionService()
getConversionService
in interface EntityConverter<ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty,Object,Document>
public void setConversions(CustomConversions conversions)
CustomConversions
to be applied during the mapping process. bean initialization
.conversions
- must not be null.public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
public <R> R read(Class<R> type, Document source)
read
in interface EntityReader<Object,Document>
protected <R> R readEntity(ElasticsearchPersistentEntity<?> entity, Map<String,Object> source)
protected <R> R readProperties(ElasticsearchPersistentEntity<?> entity, R instance, org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.ElasticsearchPropertyValueProvider valueProvider)
@Nullable protected <R> R readValue(@Nullable Object value, ElasticsearchPersistentProperty property, TypeInformation<?> type)
public void write(Object source, Document sink)
write
in interface EntityWriter<Object,Document>
protected void writeInternal(@Nullable Object source, Map<String,Object> sink, @Nullable TypeInformation<?> typeInformation)
source
- sink
- typeInformation
- protected void writeInternal(@Nullable Object source, Map<String,Object> sink, @Nullable ElasticsearchPersistentEntity<?> entity)
source
- sink
- entity
- protected void writeProperties(ElasticsearchPersistentEntity<?> entity, PersistentPropertyAccessor<?> accessor, org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.MapValueAccessor sink)
protected void writeProperty(ElasticsearchPersistentProperty property, Object value, org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.MapValueAccessor sink)
protected List<Object> createCollection(Collection<?> collection, ElasticsearchPersistentProperty property)
Collection
using the given ElasticsearchPersistentProperty
information.collection
- must not be null.property
- must not be null.protected Map<String,Object> createMap(Map<?,?> map, ElasticsearchPersistentProperty property)
Map
using the given ElasticsearchPersistentProperty
information.map
- must not null.property
- must not be null.protected Map<String,Object> writeMapInternal(Map<?,?> source, Map<String,Object> sink, TypeInformation<?> propertyType)
source
- must not be null.sink
- must not be null.propertyType
- must not be null.@Nullable @Deprecated protected Object getWriteSimpleValue(Object value)
getPotentiallyConvertedSimpleWrite(Object, Class)
instead.@Deprecated protected Object getWriteComplexValue(ElasticsearchPersistentProperty property, TypeInformation<?> typeHint, Object value)
writeInternal(Object, Map, TypeInformation)
instead.protected void addCustomTypeKeyIfNecessary(Object source, Map<String,Object> sink, @Nullable TypeInformation<?> type)
Map
if necessary. That is if the value is not the same
as the one given. This is usually the case if you store a subtype of the actual declared typeInformation of the
property.source
- must not be null.sink
- must not be null.type
- public boolean requiresTypeHint(Class<?> type)
type
- must not be null.Collection
or type with custom write target.public void updateCriteriaQuery(CriteriaQuery criteriaQuery, Class<?> domainClass)
ElasticsearchConverter
CriteriaQuery
by renaming the property names in the query to the correct mapped field names and
the values to the converted values if the ElasticsearchPersistentProperty
for a property has a
ElasticsearchPersistentPropertyConverter
.updateCriteriaQuery
in interface ElasticsearchConverter
criteriaQuery
- the query that is internally updateddomainClass
- the class of the object that is searched with the queryCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.