#117 add BAK papers filter

This commit is contained in:
T-Midnight 2019-04-26 00:29:20 +04:00
parent 88ec35faa0
commit 51e121ae24
5 changed files with 62 additions and 6 deletions

View File

@ -33,6 +33,8 @@ public class GrantDto {
private boolean wasLeader; private boolean wasLeader;
private boolean hasAge; private boolean hasAge;
private boolean hasDegree; private boolean hasDegree;
private boolean hasBAKPapers;
private boolean hasScopusPapers;
private List<Integer> paperIds = new ArrayList<>(); private List<Integer> paperIds = new ArrayList<>();
private List<Paper> papers = new ArrayList<>(); private List<Paper> papers = new ArrayList<>();
private List<Integer> removedDeadlineIds = new ArrayList<>(); private List<Integer> removedDeadlineIds = new ArrayList<>();
@ -224,4 +226,20 @@ public class GrantDto {
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) { public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
this.removedDeadlineIds = 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;
}
} }

View File

@ -18,11 +18,12 @@ 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.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 org.springframework.util.ObjectUtils.isEmpty; import static org.springframework.util.ObjectUtils.isEmpty;
import static ru.ulstu.core.util.StreamApiUtils.convert; import static ru.ulstu.core.util.StreamApiUtils.convert;
import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION; import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION;
@ -156,8 +157,15 @@ public class GrantService {
filteredUsers = filteredUsers filteredUsers = filteredUsers
.stream() .stream()
.filter(getCompletedGrantLeaders()::contains) .filter(getCompletedGrantLeaders()::contains)
.collect(Collectors.toList()); .collect(toList());
} }
if (grantDto.isHasBAKPapers()) {
filteredUsers = filteredUsers
.stream()
.filter(getCompletedBAKPapersAuthors()::contains)
.collect(toList());
}
return filteredUsers; return filteredUsers;
} }
@ -165,7 +173,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) {
@ -193,4 +201,22 @@ public class GrantService {
grantDto.getDeadlines().remove((int) deadlineId); grantDto.getDeadlines().remove((int) deadlineId);
} }
private List<User> getCompletedBAKPapersAuthors() {
List<Paper> papers = paperService.findCompletedVAKPapers()
.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
.stream()
.distinct()
.collect(toList());
}
} }

View File

@ -16,4 +16,6 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findByIdNotIn(List<Integer> paperIds); List<Paper> findByIdNotIn(List<Integer> paperIds);
List<Paper> findAllByIdIn(List<Integer> paperIds); List<Paper> findAllByIdIn(List<Integer> paperIds);
List<Paper> findByType(Paper.PaperType type);
} }

View File

@ -272,4 +272,11 @@ public class PaperService {
.map(User::getUserAbbreviate) .map(User::getUserAbbreviate)
.collect(Collectors.joining(", ")); .collect(Collectors.joining(", "));
} }
public List<Paper> findCompletedVAKPapers() {
return paperRepository.findByType(Paper.PaperType.VAK)
.stream()
.filter(findAllCompleted()::contains)
.collect(toList());
}
} }

View File

@ -90,7 +90,8 @@
aria-expanded="false" aria-expanded="false"
aria-controls="collapse-filter">Фильтр рабочей группы aria-controls="collapse-filter">Фильтр рабочей группы
</label> </label>
<div th:class="${grantDto.wasLeader || grantDto.hasAge || grantDto.hasDegree} ? <div th:class="${grantDto.wasLeader || grantDto.hasAge || grantDto.hasDegree
|| grantDto.hasBAKPapers || grantDto.hasScopusPapers} ?
'form-check' : 'form-check collapse'" id="collapse-filter"> 'form-check' : 'form-check collapse'" id="collapse-filter">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -111,14 +112,16 @@
<label class="form-check-label" for="f3">епень к.т.н.</label> <label class="form-check-label" for="f3">епень к.т.н.</label>
</div> </div>
<div class="col"> <div class="col">
<input class="form-check-input" type="checkbox" id="f4"/> <input class="form-check-input" type="checkbox" id="f4"
th:field="*{hasScopusPapers}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f4">Более 3-х публикаций в <label class="form-check-label" for="f4">Более 3-х публикаций в
scopus</label> scopus</label>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<input class="form-check-input" type="checkbox" id="f5"/> <input class="form-check-input" type="checkbox" id="f5"
th:field="*{hasBAKPapers}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f5">Наличие ВАК статей</label> <br/> <label class="form-check-label" for="f5">Наличие ВАК статей</label> <br/>
</div> </div>
<div class="col"> <div class="col">