Skip to content

DATAES630 - Remove GetResultMapper and friends from core package. #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.ResultsMapper;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;

/**
* @author Christoph Strobl
Expand All @@ -45,8 +44,7 @@ public abstract class AbstractElasticsearchConfiguration extends ElasticsearchCo
* @return never {@literal null}.
*/
@Bean(name = { "elasticsearchOperations", "elasticsearchTemplate" })
public ElasticsearchOperations elasticsearchOperations(MappingElasticsearchConverter mappingElasticsearchConverter,
ResultsMapper resultsMapper) {
return new ElasticsearchRestTemplate(elasticsearchClient(), mappingElasticsearchConverter, resultsMapper);
public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter) {
return new ElasticsearchRestTemplate(elasticsearchClient(), elasticsearchConverter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.ResultsMapper;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.lang.Nullable;

/**
* @author Christoph Strobl
* @author Peter-Josef Meisch
* @since 3.2
* @see ElasticsearchConfigurationSupport
*/
Expand All @@ -49,11 +49,10 @@ public abstract class AbstractReactiveElasticsearchConfiguration extends Elastic
* @return never {@literal null}.
*/
@Bean
public ReactiveElasticsearchOperations reactiveElasticsearchTemplate(
MappingElasticsearchConverter mappingElasticsearchConverter, ResultsMapper resultsMapper) {
public ReactiveElasticsearchOperations reactiveElasticsearchTemplate(ElasticsearchConverter elasticsearchConverter) {

ReactiveElasticsearchTemplate template = new ReactiveElasticsearchTemplate(reactiveElasticsearchClient(),
mappingElasticsearchConverter, resultsMapper);
elasticsearchConverter);
template.setIndicesOptions(indicesOptions());
template.setRefreshPolicy(refreshPolicy());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.core.DefaultResultMapper;
import org.springframework.data.elasticsearch.core.EntityMapper;
import org.springframework.data.elasticsearch.core.ResultsMapper;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
Expand All @@ -49,7 +46,7 @@
public class ElasticsearchConfigurationSupport {

@Bean
public MappingElasticsearchConverter elasticsearchEntityMapper(
public ElasticsearchConverter elasticsearchEntityMapper(
SimpleElasticsearchMappingContext elasticsearchMappingContext) {
return new MappingElasticsearchConverter(elasticsearchMappingContext);
}
Expand All @@ -72,17 +69,6 @@ public SimpleElasticsearchMappingContext elasticsearchMappingContext() {
return mappingContext;
}

/**
* Returns the {@link ResultsMapper} to be used for search responses.
*
* @see MappingElasticsearchConverter
* @return never {@literal null}.
*/
@Bean
public ResultsMapper resultsMapper(SimpleElasticsearchMappingContext elasticsearchMappingContext) {
return new DefaultResultMapper(elasticsearchMappingContext, elasticsearchEntityMapper(elasticsearchMappingContext));
}

/**
* Register custom {@link Converter}s in a {@link ElasticsearchCustomConversions} object if required.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,30 @@
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Mapping;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.index.MappingBuilder;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
import org.springframework.util.StringUtils;

/**
* AbstractElasticsearchTemplate
*
* @author Sascha Woo
* @author Peter-Josef Meisch
*/
public abstract class AbstractElasticsearchTemplate {
public abstract class AbstractElasticsearchTemplate implements ElasticsearchOperations {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractElasticsearchTemplate.class);

protected ElasticsearchConverter elasticsearchConverter;

protected ElasticsearchConverter createElasticsearchConverter() {
MappingElasticsearchConverter mappingElasticsearchConverter = new MappingElasticsearchConverter(
new SimpleElasticsearchMappingContext());
mappingElasticsearchConverter.afterPropertiesSet();
return mappingElasticsearchConverter;
}

protected String buildMapping(Class<?> clazz) {

// load mapping specified in Mapping annotation if present
Expand All @@ -43,4 +53,8 @@ protected String buildMapping(Class<?> clazz) {
}
}

@Override
public ElasticsearchConverter getElasticsearchConverter() {
return elasticsearchConverter;
}
}

This file was deleted.

Loading