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

Merged
tatyana_belousova merged 1 commits from 117-filter-users into dev 2019-05-03 09:58:21 +04:00
Showing only changes of commit 74d43dcd0d - Show all commits

View File

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