#117 add scopus papers filter

This commit is contained in:
T-Midnight 2019-04-26 15:16:04 +04:00
parent 51e121ae24
commit 39f3c69479
2 changed files with 29 additions and 9 deletions

View File

@ -20,6 +20,7 @@ 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;
import java.util.List;
@ -162,10 +163,15 @@ public class GrantService {
if (grantDto.isHasBAKPapers()) {
filteredUsers = filteredUsers
.stream()
.filter(getCompletedBAKPapersAuthors()::contains)
.filter(getBAKAuthors()::contains)
.collect(toList());
}
if (grantDto.isHasScopusPapers()) {
filteredUsers = filteredUsers
.stream()
.filter(getScopusAuthors()::contains)
.collect(toList());
}
return filteredUsers;
}
@ -201,22 +207,36 @@ public class GrantService {
grantDto.getDeadlines().remove((int) deadlineId);
}
private List<User> getCompletedBAKPapersAuthors() {
List<Paper> papers = paperService.findCompletedVAKPapers()
.stream()
private List<User> getCompletedPapersAuthors(Paper.PaperType type) {
List<Paper> papers = paperService.findAllCompletedByType(type);
papers.stream()
.filter(paper -> paper.getAuthors() != null)
.collect(toList());
List<User> users = new ArrayList<>();
for (Paper p : papers) {
p.getAuthors()
.stream()
.forEach(users::add);
}
return users;
}
return users
private List<User> getBAKAuthors() {
return getCompletedPapersAuthors(Paper.PaperType.VAK)
.stream()
.distinct()
.collect(toList());
}
private List<User> getScopusAuthors() {
List<User> oldAuthors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS);
List<User> newAuthors = new ArrayList<>();
oldAuthors.forEach(author -> {
int count = Collections.frequency(oldAuthors, author);
if (count > 3) {
newAuthors.add(author);
}
});
return newAuthors;
}
}

View File

@ -273,8 +273,8 @@ public class PaperService {
.collect(Collectors.joining(", "));
}
public List<Paper> findCompletedVAKPapers() {
return paperRepository.findByType(Paper.PaperType.VAK)
public List<Paper> findAllCompletedByType(Paper.PaperType type) {
return paperRepository.findByType(type)
.stream()
.filter(findAllCompleted()::contains)
.collect(toList());