From 74d43dcd0d131213f0f6862524b1df89045b5f80 Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 2 May 2019 22:49:58 +0400 Subject: [PATCH] #117 resolve last discussion --- .../ru/ulstu/grant/service/GrantService.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index daf50db..cb86b7a 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -154,26 +154,23 @@ public class GrantService { public List getGrantAuthors(GrantDto grantDto) { List 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 checkContains(List filteredUsers, List checkUsers) { + return filteredUsers.stream() + .filter(checkUsers::contains) + .collect(toList()); + } + private List getCompletedGrantLeaders() { return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED) .stream()