Resolve "Фильтрация участников гранта по двум новым параметрам" #204

Merged
tatyana_belousova merged 1 commits from 117-filter-users into dev 2019-05-03 09:58:21 +04:00

View File

@ -154,26 +154,23 @@ public class GrantService {
public List<User> getGrantAuthors(GrantDto grantDto) { public List<User> getGrantAuthors(GrantDto grantDto) {
List<User> filteredUsers = userService.filterByAgeAndDegree(grantDto.isHasAge(), grantDto.isHasDegree()); List<User> filteredUsers = userService.filterByAgeAndDegree(grantDto.isHasAge(), grantDto.isHasDegree());
if (grantDto.isWasLeader()) { if (grantDto.isWasLeader()) {
filteredUsers = filteredUsers filteredUsers = checkContains(filteredUsers, getCompletedGrantLeaders());
.stream()
.filter(getCompletedGrantLeaders()::contains)
.collect(toList());
} }
if (grantDto.isHasBAKPapers()) { if (grantDto.isHasBAKPapers()) {
filteredUsers = filteredUsers filteredUsers = checkContains(filteredUsers, getBAKAuthors());
.stream()
.filter(getBAKAuthors()::contains)
.collect(toList());
} }
if (grantDto.isHasScopusPapers()) { if (grantDto.isHasScopusPapers()) {
filteredUsers = filteredUsers filteredUsers = checkContains(filteredUsers, getScopusAuthors());
.stream()
.filter(getScopusAuthors()::contains)
.collect(toList());
} }
return filteredUsers; return filteredUsers;
} }
private List<User> checkContains(List<User> filteredUsers, List<User> checkUsers) {
return filteredUsers.stream()
.filter(checkUsers::contains)
.collect(toList());
}
private List<User> getCompletedGrantLeaders() { private List<User> getCompletedGrantLeaders() {
return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED) return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED)
.stream() .stream()