mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-28 23:02:12 +00:00
DATAES-369 - Polishing.
Fix linebreaks.
This commit is contained in:
parent
b5bab6b85e
commit
7dba0441bb
File diff suppressed because it is too large
Load Diff
@ -1,52 +1,52 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
|
||||
/**
|
||||
* ElasticsearchPersistentEntity
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, ElasticsearchPersistentProperty> {
|
||||
|
||||
String getIndexName();
|
||||
|
||||
String getIndexType();
|
||||
|
||||
short getShards();
|
||||
|
||||
short getReplicas();
|
||||
|
||||
boolean isUseServerConfiguration();
|
||||
|
||||
String getRefreshInterval();
|
||||
|
||||
String getIndexStoreType();
|
||||
|
||||
ElasticsearchPersistentProperty getVersionProperty();
|
||||
|
||||
String getParentType();
|
||||
|
||||
ElasticsearchPersistentProperty getParentIdProperty();
|
||||
|
||||
String settingPath();
|
||||
|
||||
boolean isCreateIndexAndMapping();
|
||||
}
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
|
||||
/**
|
||||
* ElasticsearchPersistentEntity
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, ElasticsearchPersistentProperty> {
|
||||
|
||||
String getIndexName();
|
||||
|
||||
String getIndexType();
|
||||
|
||||
short getShards();
|
||||
|
||||
short getReplicas();
|
||||
|
||||
boolean isUseServerConfiguration();
|
||||
|
||||
String getRefreshInterval();
|
||||
|
||||
String getIndexStoreType();
|
||||
|
||||
ElasticsearchPersistentProperty getVersionProperty();
|
||||
|
||||
String getParentType();
|
||||
|
||||
ElasticsearchPersistentProperty getParentIdProperty();
|
||||
|
||||
String settingPath();
|
||||
|
||||
boolean isCreateIndexAndMapping();
|
||||
}
|
||||
|
@ -1,171 +1,171 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import static org.springframework.util.StringUtils.*;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.expression.BeanFactoryAccessor;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Parent;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.mapping.model.BasicPersistentEntity;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ParserContext;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
||||
*
|
||||
* @param <T>
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty>
|
||||
implements ElasticsearchPersistentEntity<T>, ApplicationContextAware {
|
||||
|
||||
private final StandardEvaluationContext context;
|
||||
private final SpelExpressionParser parser;
|
||||
|
||||
private String indexName;
|
||||
private String indexType;
|
||||
private boolean useServerConfiguration;
|
||||
private short shards;
|
||||
private short replicas;
|
||||
private String refreshInterval;
|
||||
private String indexStoreType;
|
||||
private String parentType;
|
||||
private ElasticsearchPersistentProperty parentIdProperty;
|
||||
private String settingPath;
|
||||
private boolean createIndexAndMapping;
|
||||
|
||||
public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
super(typeInformation);
|
||||
this.context = new StandardEvaluationContext();
|
||||
this.parser = new SpelExpressionParser();
|
||||
|
||||
Class<T> clazz = typeInformation.getType();
|
||||
if (clazz.isAnnotationPresent(Document.class)) {
|
||||
Document document = clazz.getAnnotation(Document.class);
|
||||
Assert.hasText(document.indexName(),
|
||||
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
|
||||
this.indexName = document.indexName();
|
||||
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
|
||||
this.useServerConfiguration = document.useServerConfiguration();
|
||||
this.shards = document.shards();
|
||||
this.replicas = document.replicas();
|
||||
this.refreshInterval = document.refreshInterval();
|
||||
this.indexStoreType = document.indexStoreType();
|
||||
this.createIndexAndMapping = document.createIndex();
|
||||
}
|
||||
if (clazz.isAnnotationPresent(Setting.class)) {
|
||||
this.settingPath = typeInformation.getType().getAnnotation(Setting.class).settingPath();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context.addPropertyAccessor(new BeanFactoryAccessor());
|
||||
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
||||
context.setRootObject(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexName() {
|
||||
Expression expression = parser.parseExpression(indexName, ParserContext.TEMPLATE_EXPRESSION);
|
||||
return expression.getValue(context, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexType() {
|
||||
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
|
||||
return expression.getValue(context, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexStoreType() {
|
||||
return indexStoreType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShards() {
|
||||
return shards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getReplicas() {
|
||||
return replicas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseServerConfiguration() {
|
||||
return useServerConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefreshInterval() {
|
||||
return refreshInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentType() {
|
||||
return parentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElasticsearchPersistentProperty getParentIdProperty() {
|
||||
return parentIdProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String settingPath() {
|
||||
return settingPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreateIndexAndMapping() {
|
||||
return createIndexAndMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
||||
super.addPersistentProperty(property);
|
||||
|
||||
Parent annotation = property.findAnnotation(Parent.class);
|
||||
|
||||
if (annotation != null) {
|
||||
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
|
||||
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
|
||||
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
|
||||
this.parentIdProperty = property;
|
||||
this.parentType = annotation.type();
|
||||
}
|
||||
|
||||
if (property.isVersionProperty()) {
|
||||
Assert.isTrue(property.getType() == Long.class, "Version property should be Long");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import static org.springframework.util.StringUtils.*;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.expression.BeanFactoryAccessor;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Parent;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.mapping.model.BasicPersistentEntity;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ParserContext;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
||||
*
|
||||
* @param <T>
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty>
|
||||
implements ElasticsearchPersistentEntity<T>, ApplicationContextAware {
|
||||
|
||||
private final StandardEvaluationContext context;
|
||||
private final SpelExpressionParser parser;
|
||||
|
||||
private String indexName;
|
||||
private String indexType;
|
||||
private boolean useServerConfiguration;
|
||||
private short shards;
|
||||
private short replicas;
|
||||
private String refreshInterval;
|
||||
private String indexStoreType;
|
||||
private String parentType;
|
||||
private ElasticsearchPersistentProperty parentIdProperty;
|
||||
private String settingPath;
|
||||
private boolean createIndexAndMapping;
|
||||
|
||||
public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
super(typeInformation);
|
||||
this.context = new StandardEvaluationContext();
|
||||
this.parser = new SpelExpressionParser();
|
||||
|
||||
Class<T> clazz = typeInformation.getType();
|
||||
if (clazz.isAnnotationPresent(Document.class)) {
|
||||
Document document = clazz.getAnnotation(Document.class);
|
||||
Assert.hasText(document.indexName(),
|
||||
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
|
||||
this.indexName = document.indexName();
|
||||
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
|
||||
this.useServerConfiguration = document.useServerConfiguration();
|
||||
this.shards = document.shards();
|
||||
this.replicas = document.replicas();
|
||||
this.refreshInterval = document.refreshInterval();
|
||||
this.indexStoreType = document.indexStoreType();
|
||||
this.createIndexAndMapping = document.createIndex();
|
||||
}
|
||||
if (clazz.isAnnotationPresent(Setting.class)) {
|
||||
this.settingPath = typeInformation.getType().getAnnotation(Setting.class).settingPath();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context.addPropertyAccessor(new BeanFactoryAccessor());
|
||||
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
||||
context.setRootObject(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexName() {
|
||||
Expression expression = parser.parseExpression(indexName, ParserContext.TEMPLATE_EXPRESSION);
|
||||
return expression.getValue(context, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexType() {
|
||||
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
|
||||
return expression.getValue(context, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexStoreType() {
|
||||
return indexStoreType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShards() {
|
||||
return shards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getReplicas() {
|
||||
return replicas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseServerConfiguration() {
|
||||
return useServerConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefreshInterval() {
|
||||
return refreshInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentType() {
|
||||
return parentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElasticsearchPersistentProperty getParentIdProperty() {
|
||||
return parentIdProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String settingPath() {
|
||||
return settingPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreateIndexAndMapping() {
|
||||
return createIndexAndMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
||||
super.addPersistentProperty(property);
|
||||
|
||||
Parent annotation = property.findAnnotation(Parent.class);
|
||||
|
||||
if (annotation != null) {
|
||||
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
|
||||
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
|
||||
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
|
||||
this.parentIdProperty = property;
|
||||
this.parentType = annotation.type();
|
||||
}
|
||||
|
||||
if (property.isVersionProperty()) {
|
||||
Assert.isTrue(property.getType() == Long.class, "Version property should be Long");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,94 +1,94 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repository.support;
|
||||
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||
import org.springframework.data.repository.core.support.PersistentEntityInformation;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific implementation of
|
||||
* {@link org.springframework.data.repository.core.support.AbstractEntityInformation}
|
||||
*
|
||||
* @param <T>
|
||||
* @param <ID>
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Ryan Henszey
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class MappingElasticsearchEntityInformation<T, ID> extends PersistentEntityInformation<T, ID>
|
||||
implements ElasticsearchEntityInformation<T, ID> {
|
||||
|
||||
private final ElasticsearchPersistentEntity<T> entityMetadata;
|
||||
private final String indexName;
|
||||
private final String type;
|
||||
|
||||
public MappingElasticsearchEntityInformation(ElasticsearchPersistentEntity<T> entity) {
|
||||
this(entity, entity.getIndexName(), entity.getIndexType());
|
||||
}
|
||||
|
||||
public MappingElasticsearchEntityInformation(ElasticsearchPersistentEntity<T> entity, String indexName, String type) {
|
||||
super(entity);
|
||||
|
||||
Assert.notNull(indexName, "IndexName must not be null!");
|
||||
Assert.notNull(type, "IndexType must not be null!");
|
||||
|
||||
this.entityMetadata = entity;
|
||||
this.indexName = indexName;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttribute() {
|
||||
return entityMetadata.getRequiredIdProperty().getFieldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getVersion(T entity) {
|
||||
|
||||
ElasticsearchPersistentProperty versionProperty = entityMetadata.getVersionProperty();
|
||||
try {
|
||||
return versionProperty != null ? (Long) entityMetadata.getPropertyAccessor(entity).getProperty(versionProperty) : null;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("failed to load version field", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentId(T entity) {
|
||||
|
||||
ElasticsearchPersistentProperty parentProperty = entityMetadata.getParentIdProperty();
|
||||
try {
|
||||
return parentProperty != null ? (String) entityMetadata.getPropertyAccessor(entity).getProperty(parentProperty) : null;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("failed to load parent ID: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repository.support;
|
||||
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||
import org.springframework.data.repository.core.support.PersistentEntityInformation;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific implementation of
|
||||
* {@link org.springframework.data.repository.core.support.AbstractEntityInformation}
|
||||
*
|
||||
* @param <T>
|
||||
* @param <ID>
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Ryan Henszey
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class MappingElasticsearchEntityInformation<T, ID> extends PersistentEntityInformation<T, ID>
|
||||
implements ElasticsearchEntityInformation<T, ID> {
|
||||
|
||||
private final ElasticsearchPersistentEntity<T> entityMetadata;
|
||||
private final String indexName;
|
||||
private final String type;
|
||||
|
||||
public MappingElasticsearchEntityInformation(ElasticsearchPersistentEntity<T> entity) {
|
||||
this(entity, entity.getIndexName(), entity.getIndexType());
|
||||
}
|
||||
|
||||
public MappingElasticsearchEntityInformation(ElasticsearchPersistentEntity<T> entity, String indexName, String type) {
|
||||
super(entity);
|
||||
|
||||
Assert.notNull(indexName, "IndexName must not be null!");
|
||||
Assert.notNull(type, "IndexType must not be null!");
|
||||
|
||||
this.entityMetadata = entity;
|
||||
this.indexName = indexName;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttribute() {
|
||||
return entityMetadata.getRequiredIdProperty().getFieldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getVersion(T entity) {
|
||||
|
||||
ElasticsearchPersistentProperty versionProperty = entityMetadata.getVersionProperty();
|
||||
try {
|
||||
return versionProperty != null ? (Long) entityMetadata.getPropertyAccessor(entity).getProperty(versionProperty) : null;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("failed to load version field", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentId(T entity) {
|
||||
|
||||
ElasticsearchPersistentProperty parentProperty = entityMetadata.getParentIdProperty();
|
||||
try {
|
||||
return parentProperty != null ? (String) entityMetadata.getPropertyAccessor(entity).getProperty(parentProperty) : null;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("failed to load parent ID: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user