#117 resolve discussions

merge-requests/77/head
T-Midnight 5 years ago
parent 8b333ab3a6
commit b334b5d70e

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

@ -17,5 +17,5 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findAllByIdIn(List<Integer> paperIds);
List<Paper> findByTypeAndStatus(Paper.PaperType type, Paper.PaperStatus status);
List<Paper> findByType(Paper.PaperType type);
}

@ -305,6 +305,9 @@ public class PaperService {
}
public List<Paper> findAllCompletedByType(Paper.PaperType type) {
return paperRepository.findByTypeAndStatus(type, Paper.PaperStatus.COMPLETED);
return paperRepository.findByType(type)
.stream()
.filter(findAllCompleted()::contains)
.collect(toList());
}
}

@ -1,7 +1,7 @@
# Server Settings
spring.main.banner-mode=off
server.port=8443
server.http.port=8888
server.http.port=8080
spring.http.multipart.maxFileSize=20MB
spring.http.multipart.maxRequestSize=20MB
# Thymeleaf Settings
@ -24,7 +24,7 @@ spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFact
# JPA Settings
spring.datasource.url=jdbc:postgresql://localhost:5432/ng-tracker
spring.datasource.username=postgres
spring.datasource.password=superuser
spring.datasource.password=postgres
spring.datasource.driverclassName=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=validate
# Liquibase Settings

Loading…
Cancel
Save