Merge branch '109-paper-attach-control' into 'dev'

Resolve "Контроль прикрепления статей"

Closes #109

See merge request romanov73/ng-tracker!87
This commit is contained in:
Anton Romanov 2019-05-08 09:10:03 +00:00
commit 662847698e
6 changed files with 64 additions and 3 deletions

View File

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

View File

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

View File

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

View File

@ -18,4 +18,10 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findAllByIdIn(List<Integer> paperIds);
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) {
if (!paperIds.isEmpty()) {
return sortPapers(paperRepository.findByIdNotIn(paperIds));
return sortPapers(paperRepository.findByIdNotInAndConferencesIsNullAndStatusNot(paperIds, COMPLETED));
} 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) {

View File

@ -201,6 +201,30 @@
Статус статьи
</span>
</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>