Skip to content

Commit

Permalink
removed custom Version as it is available in spring-data-commons 1.5 …
Browse files Browse the repository at this point in the history
…release
  • Loading branch information
Rizwan Idrees committed Mar 20, 2013
1 parent e9eed44 commit 2fe012e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 48 deletions.

This file was deleted.

Expand Up @@ -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);
Expand Down Expand Up @@ -76,22 +75,11 @@ public String getIndexType() {
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;
}
}
}
Expand Up @@ -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;
Expand All @@ -35,6 +34,7 @@
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>();

Expand All @@ -60,8 +60,15 @@ public boolean isIdProperty() {
}

@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
Expand Down
Expand Up @@ -19,8 +19,9 @@
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
Expand Down
Expand Up @@ -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;
Expand Down

0 comments on commit 2fe012e

Please sign in to comment.