0

I implemented a filter for Spring Data Rest using Query by Example in a custom controller, as described in this answer.

I would like all my entities to have this filter. How can I extend Spring Data Rest with a generic implementation of this filter?

Jefferson Lima
  • 5,186
  • 2
  • 28
  • 28

1 Answers1

0

Add @RequestMapping(value = "/{repository}/filter", method = RequestMethod.GET) to the controller.

Add @QuerydslPredicate RootResourceInformation resourceInformation and Map<String,String> map arguments to thee controller. The resoureceInformation will contain the typeInfo of the actual entity type (Spring Data Rest finds the appropriate entity by the repository pathvariable)

If you have the typeInfo and all the property name-values, then you can recreate the proper type of example.

--------------- Edit

I'm working on an extension for Spring Data Rest. Basically it's an access-control extension, but it has an inbuilt search function too. (Even more flexible than this general filter) However, switching to this package only because of the search feature would be a bit overkill. But if can find some other useful features you should consider giving it a try. ACL-search

Selindek
  • 3,269
  • 1
  • 18
  • 25