-
public interface SearchDescriptor<T extends Object>
Search Descriptor allows exposing automatically a search endpoint for an Entity.
The new endpoint is mapped to
/search/{searchDescriptorId}
wheresearchDescriptorId
is the id specified in theSearchDescriptor
.The easiest way to create a Search Descriptor is to use the SearchDescriptorBuilder which provides every options available to configure a
SearchDescriptor
.To expose the new Entity search endpoint,
SearchDescriptor
must be registered to the Spring Data Search Configuration:Implement the SearchConfigurer interface and override the addSearchDescriptors method:
@Configuration public class SearchDescriptorConfiguration implements SearchConfigurer { @Override public void addSearchDescriptors(SearchDescriptorRegistry registry) { SearchDescriptor searchDescriptor = new SearchDescriptorBuilder<Person>(Person.class).build(); registry.addSearchDescriptor(searchDescriptor); } }
Another solution is to add a new @Bean. This solution is useful when you want to create a
SearchDescriptor
which depends on other Beans:
@Configuration public class SearchDescriptorConfiguration { @Bean SearchDescriptor<Person> personSearchDescriptor(PersonRepository personRepository) { return new SearchDescriptorBuilder<Person>(Person.class) .specificationExecutor(personRepository) .build(); } }
-
-
Method Summary
Modifier and Type Method Description abstract String
getId()
String representing an identifier to find this Descriptor. abstract Class<T>
getEntityClass()
Entity Class to be searched. List<DataSearchValidator>
getValidators()
abstract DtoMapper<T, ?>
getDtoMapper()
Return the mapper to convert the entity to a specific DTO. abstract SpecificationExecutor<T>
getSpecificationExecutor()
Returns the SpecificationExecutor to search the entities. List<EntityJoinHandler>
getEntityJoinHandlers()
-
-
Method Detail
-
getEntityClass
abstract Class<T> getEntityClass()
Entity Class to be searched.
-
getValidators
List<DataSearchValidator> getValidators()
-
getDtoMapper
abstract DtoMapper<T, ?> getDtoMapper()
Return the mapper to convert the entity to a specific DTO.
By default, the method returns a mapper that just returns the given entity.
-
getSpecificationExecutor
abstract SpecificationExecutor<T> getSpecificationExecutor()
Returns the SpecificationExecutor to search the entities.
If it's not defined, it will be identified automatically by the instance of SpecificationExecutorFactory.
-
getEntityJoinHandlers
List<EntityJoinHandler> getEntityJoinHandlers()
-
-
-
-