org.springframework.data.elasticsearch.annotations.Document Java Examples

The following examples show how to use org.springframework.data.elasticsearch.annotations.Document. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResultMapperExt.java    From roncoo-education with MIT License 6 votes vote down vote up
private <T> void setPersistentEntityVersion(T result, long version, Class<T> clazz) {
	if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

		ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
		ElasticsearchPersistentProperty versionProperty = persistentEntity.getVersionProperty();

		// Only deal with Long because ES versions are longs !
		if (versionProperty != null && versionProperty.getType().isAssignableFrom(Long.class)) {
			// check that a version was actually returned in the response, -1 would indicate
			// that
			// a search didn't request the version ids in the response, which would be an
			// issue
			Assert.isTrue(version != -1, "Version in response is -1");
			persistentEntity.getPropertyAccessor(result).setProperty(versionProperty, version);
		}
	}
}
 
Example #2
Source File: XiaoEUKResultMapper.java    From youkefu with Apache License 2.0 5 votes vote down vote up
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {

		if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

			ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
			PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
			
			// Only deal with String because ES generated Ids are strings !
			if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
				persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
			}
		}
	}
 
Example #3
Source File: UKResultMapper.java    From youkefu with Apache License 2.0 5 votes vote down vote up
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {

		if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

			ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
			PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
			
			// Only deal with String because ES generated Ids are strings !
			if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
				persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
			}
		}
	}
 
Example #4
Source File: ResultMapperExt.java    From roncoo-education with MIT License 5 votes vote down vote up
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {

		if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

			ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(clazz);
			ElasticsearchPersistentProperty idProperty = persistentEntity.getIdProperty();

			// Only deal with String because ES generated Ids are strings !
			if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
				persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
			}

		}
	}