From de625923e96ba4172ac4ae047560c85fc13e12c2 Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 2 May 2019 21:56:54 +0400 Subject: [PATCH] #117 resolve discussions v.2 --- .../ru/ulstu/grant/service/GrantService.java | 26 ++++++------------- .../paper/repository/PaperRepository.java | 2 +- .../ru/ulstu/paper/service/PaperService.java | 5 +--- src/main/resources/application.properties | 2 +- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 2450440..daf50db 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -19,7 +19,6 @@ 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.Collections; import java.util.Date; @@ -209,16 +208,11 @@ public class GrantService { private List getCompletedPapersAuthors(Paper.PaperType type) { List papers = paperService.findAllCompletedByType(type); - papers.stream() + return papers.stream() .filter(paper -> paper.getAuthors() != null) + .flatMap(paper -> paper.getAuthors().stream()) .collect(toList()); - List users = new ArrayList<>(); - for (Paper p : papers) { - p.getAuthors() - .stream() - .forEach(users::add); - } - return users; + } private List getBAKAuthors() { @@ -229,14 +223,10 @@ public class GrantService { } private List getScopusAuthors() { - List oldAuthors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS); - List newAuthors = new ArrayList<>(); - oldAuthors.forEach(author -> { - int count = Collections.frequency(oldAuthors, author); - if (count > 3) { - newAuthors.add(author); - } - }); - return newAuthors; + List authors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS); + return authors + .stream() + .filter(author -> Collections.frequency(authors, author) > 3) + .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 8bc59ce..f935247 100644 --- a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java +++ b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java @@ -17,5 +17,5 @@ public interface PaperRepository extends JpaRepository { List findAllByIdIn(List paperIds); - List findByType(Paper.PaperType type); + List findByTypeAndStatus(Paper.PaperType type, Paper.PaperStatus status); } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 97efafb..f98997d 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -305,9 +305,6 @@ public class PaperService { } public List findAllCompletedByType(Paper.PaperType type) { - return paperRepository.findByType(type) - .stream() - .filter(findAllCompleted()::contains) - .collect(toList()); + return paperRepository.findByTypeAndStatus(type, Paper.PaperStatus.COMPLETED); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 038ddcf..64194c9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ # Server Settings spring.main.banner-mode=off server.port=8443 -server.http.port=8080 +server.http.port=8888 spring.http.multipart.maxFileSize=20MB spring.http.multipart.maxRequestSize=20MB # Thymeleaf Settings