#117 resolve last discussion

This commit is contained in:
T-Midnight 2019-05-02 22:49:58 +04:00
parent 0955388f27
commit 74d43dcd0d

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()