|
26 | 26 | import org.slf4j.Logger;
|
27 | 27 | import org.slf4j.LoggerFactory;
|
28 | 28 | import org.springframework.core.annotation.AnnotatedElementUtils;
|
29 |
| -import org.springframework.core.annotation.AnnotationAttributes; |
30 | 29 | import org.springframework.dao.InvalidDataAccessApiUsageException;
|
31 | 30 | import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
|
32 | 31 | import org.springframework.data.elasticsearch.annotations.Mapping;
|
|
44 | 43 |
|
45 | 44 | /**
|
46 | 45 | * Base implementation of {@link IndexOperations} common to Transport and Rest based Implementations of IndexOperations.
|
47 |
| - * |
| 46 | + * |
48 | 47 | * @author Peter-Josef Meisch
|
49 | 48 | * @author Sascha Woo
|
50 | 49 | * @since 4.0
|
@@ -107,13 +106,10 @@ public Document createSettings(Class<?> clazz) {
|
107 | 106 |
|
108 | 107 | Document settings = null;
|
109 | 108 |
|
110 |
| - if (AnnotatedElementUtils.hasAnnotation(clazz, Setting.class)) { |
111 |
| - AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz, Setting.class); |
| 109 | + Setting setting = AnnotatedElementUtils.findMergedAnnotation(clazz, Setting.class); |
112 | 110 |
|
113 |
| - if (attributes != null) { |
114 |
| - String settingPath = attributes.getString("settingPath"); |
115 |
| - settings = loadSettings(settingPath); |
116 |
| - } |
| 111 | + if (setting != null) { |
| 112 | + settings = loadSettings(setting.settingPath()); |
117 | 113 | }
|
118 | 114 |
|
119 | 115 | if (settings == null) {
|
@@ -230,21 +226,18 @@ public Document createMapping(Class<?> clazz) {
|
230 | 226 | protected Document buildMapping(Class<?> clazz) {
|
231 | 227 |
|
232 | 228 | // load mapping specified in Mapping annotation if present
|
233 |
| - if (AnnotatedElementUtils.hasAnnotation(clazz, Mapping.class)) { |
234 |
| - AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz, Mapping.class); |
235 |
| - |
236 |
| - if (attributes != null) { |
237 |
| - String mappingPath = attributes.getString("mappingPath"); |
| 229 | + Mapping mappingAnnotation = AnnotatedElementUtils.findMergedAnnotation(clazz, Mapping.class); |
| 230 | + if (mappingAnnotation != null) { |
| 231 | + String mappingPath = mappingAnnotation.mappingPath(); |
238 | 232 |
|
239 |
| - if (StringUtils.hasText(mappingPath)) { |
240 |
| - String mappings = ResourceUtil.readFileFromClasspath(mappingPath); |
| 233 | + if (StringUtils.hasText(mappingPath)) { |
| 234 | + String mappings = ResourceUtil.readFileFromClasspath(mappingPath); |
241 | 235 |
|
242 |
| - if (StringUtils.hasText(mappings)) { |
243 |
| - return Document.parse(mappings); |
244 |
| - } |
245 |
| - } else { |
246 |
| - LOGGER.info("mappingPath in @Mapping has to be defined. Building mappings using @Field"); |
| 236 | + if (StringUtils.hasText(mappings)) { |
| 237 | + return Document.parse(mappings); |
247 | 238 | }
|
| 239 | + } else { |
| 240 | + LOGGER.info("mappingPath in @Mapping has to be defined. Building mappings using @Field"); |
248 | 241 | }
|
249 | 242 | }
|
250 | 243 |
|
|
0 commit comments