@Override
public Page<EmployeeProjectView> findEmployeeProjectsExampleMatcher(EmployeeRequestDTO employeeRequestDTO)
{
/* Build Search object */
EmployeeProjectView employeeProjectView=new EmployeeProjectView();
employeeProjectView.setEmployeeId(employeeRequestDTO.getEmployeeId());
employeeProjectView.setLastName(employeeRequestDTO.getFilterText());
employeeProjectView.setFirstName(employeeRequestDTO.getFilterText());
try
{
employeeProjectView.setProjectId(Long.valueOf(employeeRequestDTO.getFilterText()));
employeeProjectView.setProjectBudget(Double.valueOf(employeeRequestDTO.getFilterText()));
}
catch (Exception e)
{
log.debug("Supplied filter text is not a Number");
}
employeeProjectView.setProjectName(employeeRequestDTO.getFilterText());
employeeProjectView.setProjectLocation(employeeRequestDTO.getFilterText());
/* Build Example and ExampleMatcher object */
ExampleMatcher customExampleMatcher = ExampleMatcher.matchingAny()
.withMatcher("firstName", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
.withMatcher("lastName", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
.withMatcher("projectId", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
.withMatcher("projectName", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
.withMatcher("projectLocation", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
.withMatcher("projectBudget", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase());
Example<EmployeeProjectView> employeeExample= Example.of(employeeProjectView, customExampleMatcher);
/* Get employees based on search criteria*/
return employeeProjectViewRepository.findAll(employeeExample, PageRequest.of(employeeRequestDTO.getCurrentPageNumber(),
employeeRequestDTO.getPageSize(), Sort.by(employeeRequestDTO.getSortColumnName()).descending()));
}
Created
January 6, 2021 04:14
-
-
Save pavankjadda/a4f5dfe0ae0f4dbb0f957073c7a56003 to your computer and use it in GitHub Desktop.
findEmployeeProjectsExampleMatcher
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment