Merge remote-tracking branch 'remotes/origin/dev' into 119-notification-grants

This commit is contained in:
T-Midnight 2019-05-08 16:22:39 +04:00
commit e3ad5ba510
8 changed files with 79 additions and 3 deletions

View File

@ -132,7 +132,7 @@ public class GrantController {
@ModelAttribute("allPapers") @ModelAttribute("allPapers")
public List<Paper> getAllPapers() { public List<Paper> getAllPapers() {
return grantService.getAllPapers(); return grantService.getAllUncompletedPapers();
} }
private void filterEmptyDeadlines(GrantDto grantDto) { private void filterEmptyDeadlines(GrantDto grantDto) {

View File

@ -196,6 +196,10 @@ public class GrantService {
return paperService.findAll(); return paperService.findAll();
} }
public List<Paper> getAllUncompletedPapers() {
return paperService.findAllNotCompleted();
}
public void attachPaper(GrantDto grantDto) { public void attachPaper(GrantDto grantDto) {
if (!grantDto.getPaperIds().isEmpty()) { if (!grantDto.getPaperIds().isEmpty()) {
grantDto.getPapers().clear(); grantDto.getPapers().clear();

View File

@ -3,10 +3,12 @@ package ru.ulstu.paper.model;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.core.model.UserContainer; import ru.ulstu.core.model.UserContainer;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileData; import ru.ulstu.file.model.FileData;
import ru.ulstu.grant.model.Grant;
import ru.ulstu.timeline.model.Event; import ru.ulstu.timeline.model.Event;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
@ -114,6 +116,12 @@ public class Paper extends BaseEntity implements UserContainer {
@Column(name = "latex_text") @Column(name = "latex_text")
private String latexText; private String latexText;
@ManyToMany(mappedBy = "papers")
private List<Conference> conferences;
@ManyToMany(mappedBy = "papers")
private List<Grant> grants;
public PaperStatus getStatus() { public PaperStatus getStatus() {
return status; return status;
} }
@ -218,6 +226,22 @@ public class Paper extends BaseEntity implements UserContainer {
this.latexText = latexText; this.latexText = latexText;
} }
public List<Conference> getConferences() {
return conferences;
}
public void setConferences(List<Conference> conferences) {
this.conferences = conferences;
}
public List<Grant> getGrants() {
return grants;
}
public void setGrants(List<Grant> grants) {
this.grants = grants;
}
@Override @Override
public Set<User> getUsers() { public Set<User> getUsers() {
return getAuthors(); return getAuthors();

View File

@ -18,4 +18,10 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findAllByIdIn(List<Integer> paperIds); List<Paper> findAllByIdIn(List<Integer> paperIds);
List<Paper> findByTypeAndStatus(Paper.PaperType type, Paper.PaperStatus status); List<Paper> findByTypeAndStatus(Paper.PaperType type, Paper.PaperStatus status);
List<Paper> findByStatusNot(Paper.PaperStatus status);
List<Paper> findByConferencesIsNullAndStatusNot(Paper.PaperStatus status);
List<Paper> findByIdNotInAndConferencesIsNullAndStatusNot(List<Integer> paperIds, Paper.PaperStatus status);
} }

View File

@ -242,11 +242,14 @@ public class PaperService {
public List<Paper> findAllNotSelect(List<Integer> paperIds) { public List<Paper> findAllNotSelect(List<Integer> paperIds) {
if (!paperIds.isEmpty()) { if (!paperIds.isEmpty()) {
return sortPapers(paperRepository.findByIdNotIn(paperIds)); return sortPapers(paperRepository.findByIdNotInAndConferencesIsNullAndStatusNot(paperIds, COMPLETED));
} else { } else {
return sortPapers(paperRepository.findAll()); return sortPapers(paperRepository.findByConferencesIsNullAndStatusNot(COMPLETED));
} }
}
public List<Paper> findAllNotCompleted() {
return paperRepository.findByStatusNot(COMPLETED);
} }
public List<Paper> findAllSelect(List<Integer> paperIds) { public List<Paper> findAllSelect(List<Integer> paperIds) {

View File

@ -0,0 +1,14 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="tanya" id="20190507_000001-1">
<sql>
update grants
set leader_id =
(select u.id
from users u
where u.last_name = 'Романов' AND u.first_name = 'Антон');
</sql>
</changeSet>
</databaseChangeLog>

View File

@ -39,4 +39,5 @@
<include file="db/changelog-20190430_000000-schema.xml"/> <include file="db/changelog-20190430_000000-schema.xml"/>
<include file="db/changelog-20190505_000000-schema.xml"/> <include file="db/changelog-20190505_000000-schema.xml"/>
<include file="db/changelog-20190507_000000-schema.xml"/> <include file="db/changelog-20190507_000000-schema.xml"/>
<include file="db/changelog-20190507_000001-schema.xml"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -201,6 +201,30 @@
Статус статьи Статус статьи
</span> </span>
</div> </div>
<div class="col" th:unless="${#lists.isEmpty(paper.grants)}">
<label>Гранты: </label>
<div th:each="grant, grantRowStat : *{papers[__${rowStat.index}__].grants}"
th:remove="tag">
<div th:unless="${grant.id}==*{id}" th:remove="tag">
<li>
<a th:href="@{'/grants/grant?id=' + ${grant.id} + ''}">
<span th:text="${grant.title} "></span>
</a>
</li>
</div>
</div>
</div>
<div class="col" th:unless="${#lists.isEmpty(paper.conferences)}">
<label>Конференции: </label>
<div th:each="conference, conferenceRowStat : *{papers[__${rowStat.index}__].conferences}"
th:remove="tag">
<li>
<a th:href="@{'/conferences/conference?id=' + ${conference.id} + ''}">
<span th:text="${conference.title}"></span>
</a>
</li>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>