diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index 3fb77c5..b60aec0 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -33,6 +33,8 @@ public class GrantDto { private boolean wasLeader; private boolean hasAge; private boolean hasDegree; + private boolean hasBAKPapers; + private boolean hasScopusPapers; private List paperIds = new ArrayList<>(); private List papers = new ArrayList<>(); private List removedDeadlineIds = new ArrayList<>(); @@ -224,4 +226,20 @@ public class GrantDto { public void setRemovedDeadlineIds(List removedDeadlineIds) { this.removedDeadlineIds = removedDeadlineIds; } + + public boolean isHasBAKPapers() { + return hasBAKPapers; + } + + public void setHasBAKPapers(boolean hasBAKPapers) { + this.hasBAKPapers = hasBAKPapers; + } + + public boolean isHasScopusPapers() { + return hasScopusPapers; + } + + public void setHasScopusPapers(boolean hasScopusPapers) { + this.hasScopusPapers = hasScopusPapers; + } } diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index cabed80..ba6e1e9 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -18,11 +18,12 @@ import ru.ulstu.user.model.User; import ru.ulstu.user.service.UserService; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; -import java.util.stream.Collectors; +import static java.util.stream.Collectors.toList; import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION; @@ -156,8 +157,15 @@ public class GrantService { filteredUsers = filteredUsers .stream() .filter(getCompletedGrantLeaders()::contains) - .collect(Collectors.toList()); + .collect(toList()); } + if (grantDto.isHasBAKPapers()) { + filteredUsers = filteredUsers + .stream() + .filter(getCompletedBAKPapersAuthors()::contains) + .collect(toList()); + } + return filteredUsers; } @@ -165,7 +173,7 @@ public class GrantService { return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED) .stream() .map(Grant::getLeader) - .collect(Collectors.toList()); + .collect(toList()); } public List getGrantPapers(List paperIds) { @@ -193,4 +201,22 @@ public class GrantService { grantDto.getDeadlines().remove((int) deadlineId); } + private List getCompletedBAKPapersAuthors() { + List papers = paperService.findCompletedVAKPapers() + .stream() + .filter(paper -> paper.getAuthors() != null) + .collect(toList()); + + List users = new ArrayList<>(); + for (Paper p : papers) { + p.getAuthors() + .stream() + .forEach(users::add); + } + + return users + .stream() + .distinct() + .collect(toList()); + } } diff --git a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java index cab9b1a..8bc59ce 100644 --- a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java +++ b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java @@ -16,4 +16,6 @@ public interface PaperRepository extends JpaRepository { List findByIdNotIn(List paperIds); List findAllByIdIn(List paperIds); + + List findByType(Paper.PaperType type); } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 325e377..648dbc9 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -272,4 +272,11 @@ public class PaperService { .map(User::getUserAbbreviate) .collect(Collectors.joining(", ")); } + + public List findCompletedVAKPapers() { + return paperRepository.findByType(Paper.PaperType.VAK) + .stream() + .filter(findAllCompleted()::contains) + .collect(toList()); + } } diff --git a/src/main/resources/templates/grants/grant.html b/src/main/resources/templates/grants/grant.html index 9c0736d..da59248 100644 --- a/src/main/resources/templates/grants/grant.html +++ b/src/main/resources/templates/grants/grant.html @@ -90,7 +90,8 @@ aria-expanded="false" aria-controls="collapse-filter">Фильтр рабочей группы -
@@ -111,14 +112,16 @@
- +
- +