mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-07-08 19:42:45 +00:00
removed custom Version as it is available in spring-data-commons 1.5 release
This commit is contained in:
parent
e9eed44b98
commit
2fe012e87f
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 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.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Version
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface Version {
|
||||
}
|
@ -45,7 +45,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
private final StandardEvaluationContext context;
|
||||
private String indexName;
|
||||
private String indexType;
|
||||
private ElasticsearchPersistentProperty versionProperty;
|
||||
|
||||
public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
super(typeInformation);
|
||||
@ -76,22 +75,11 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
return indexType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElasticsearchPersistentProperty getVersionProperty() {
|
||||
return this.versionProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
||||
super.addPersistentProperty(property);
|
||||
if(property.isVersionProperty()){
|
||||
if (this.versionProperty != null) {
|
||||
throw new MappingException(String.format(
|
||||
"Attempt to add version property %s but already have property %s registered "
|
||||
+ "as version. Check your mapping configuration!", property.getField(), versionProperty.getField()));
|
||||
}
|
||||
Assert.isTrue(property.getType() == Long.class, "Version property should be Long");
|
||||
this.versionProperty = property;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import org.springframework.data.elasticsearch.annotations.Version;
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
||||
@ -35,6 +34,7 @@ import java.util.Set;
|
||||
public class SimpleElasticsearchPersistentProperty extends AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements
|
||||
ElasticsearchPersistentProperty {
|
||||
|
||||
private static final Class FIELD_ANNOTATION = org.springframework.data.elasticsearch.annotations.Field.class;
|
||||
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
|
||||
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
|
||||
|
||||
@ -60,8 +60,15 @@ public class SimpleElasticsearchPersistentProperty extends AnnotationBasedPersis
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVersionProperty(){
|
||||
return field.isAnnotationPresent(Version.class);
|
||||
public String getMappingType() {
|
||||
return isAnnotationPresent(FIELD_ANNOTATION)?
|
||||
((org.springframework.data.elasticsearch.annotations.Field) findAnnotation(FIELD_ANNOTATION)).type(): null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnalyzer() {
|
||||
return isAnnotationPresent(FIELD_ANNOTATION)?
|
||||
((org.springframework.data.elasticsearch.annotations.Field) findAnnotation(FIELD_ANNOTATION)).analyzer(): null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,8 +19,9 @@ package org.springframework.data.elasticsearch;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Version;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.elasticsearch.annotations.Version;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.mapping.model.MappingException;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
|
Loading…
x
Reference in New Issue
Block a user