|
|
@ -19,11 +19,11 @@ import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static java.util.stream.Collectors.toList;
|
|
|
|
import static java.util.stream.Collectors.toList;
|
|
|
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
|
|
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
|
|
@ -84,7 +84,6 @@ public class GrantService {
|
|
|
|
grant.setProject(projectService.findById(grantDto.getProject().getId()));
|
|
|
|
grant.setProject(projectService.findById(grantDto.getProject().getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
grant.setDeadlines(deadlineService.saveOrCreate(grantDto.getDeadlines()));
|
|
|
|
grant.setDeadlines(deadlineService.saveOrCreate(grantDto.getDeadlines()));
|
|
|
|
|
|
|
|
|
|
|
|
grant.setFiles(fileService.saveOrCreate(grantDto.getFiles().stream()
|
|
|
|
grant.setFiles(fileService.saveOrCreate(grantDto.getFiles().stream()
|
|
|
|
.filter(f -> !f.isDeleted())
|
|
|
|
.filter(f -> !f.isDeleted())
|
|
|
|
.collect(toList())));
|
|
|
|
.collect(toList())));
|
|
|
@ -110,7 +109,6 @@ public class GrantService {
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public Integer update(GrantDto grantDto) throws IOException {
|
|
|
|
public Integer update(GrantDto grantDto) throws IOException {
|
|
|
|
Grant grant = grantRepository.findOne(grantDto.getId());
|
|
|
|
Grant grant = grantRepository.findOne(grantDto.getId());
|
|
|
|
|
|
|
|
|
|
|
|
for (FileDataDto file : grantDto.getFiles().stream()
|
|
|
|
for (FileDataDto file : grantDto.getFiles().stream()
|
|
|
|
.filter(f -> f.isDeleted() && f.getId() != null)
|
|
|
|
.filter(f -> f.isDeleted() && f.getId() != null)
|
|
|
|
.collect(toList())) {
|
|
|
|
.collect(toList())) {
|
|
|
@ -181,7 +179,7 @@ public class GrantService {
|
|
|
|
return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED)
|
|
|
|
return grantRepository.findByStatus(Grant.GrantStatus.COMPLETED)
|
|
|
|
.stream()
|
|
|
|
.stream()
|
|
|
|
.map(Grant::getLeader)
|
|
|
|
.map(Grant::getLeader)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Paper> getGrantPapers(List<Integer> paperIds) {
|
|
|
|
public List<Paper> getGrantPapers(List<Integer> paperIds) {
|
|
|
@ -211,10 +209,16 @@ public class GrantService {
|
|
|
|
|
|
|
|
|
|
|
|
private List<User> getCompletedPapersAuthors(Paper.PaperType type) {
|
|
|
|
private List<User> getCompletedPapersAuthors(Paper.PaperType type) {
|
|
|
|
List<Paper> papers = paperService.findAllCompletedByType(type);
|
|
|
|
List<Paper> papers = paperService.findAllCompletedByType(type);
|
|
|
|
return papers.stream()
|
|
|
|
papers.stream()
|
|
|
|
.filter(paper -> paper.getAuthors() != null)
|
|
|
|
.filter(paper -> paper.getAuthors() != null)
|
|
|
|
.flatMap(paper-> paper.getAuthors().stream())
|
|
|
|
|
|
|
|
.collect(toList());
|
|
|
|
.collect(toList());
|
|
|
|
|
|
|
|
List<User> users = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Paper p : papers) {
|
|
|
|
|
|
|
|
p.getAuthors()
|
|
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
|
|
.forEach(users::add);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<User> getBAKAuthors() {
|
|
|
|
private List<User> getBAKAuthors() {
|
|
|
@ -225,10 +229,14 @@ public class GrantService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<User> getScopusAuthors() {
|
|
|
|
private List<User> getScopusAuthors() {
|
|
|
|
List<User> authors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS);
|
|
|
|
List<User> oldAuthors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS);
|
|
|
|
return authors
|
|
|
|
List<User> newAuthors = new ArrayList<>();
|
|
|
|
.stream()
|
|
|
|
oldAuthors.forEach(author -> {
|
|
|
|
.filter(author -> Collections.frequency(authors, author) > 3)
|
|
|
|
int count = Collections.frequency(oldAuthors, author);
|
|
|
|
.collect(toList());
|
|
|
|
if (count > 3) {
|
|
|
|
|
|
|
|
newAuthors.add(author);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return newAuthors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|