Merge branch '121-reduce-paper-title' into 'dev'
Resolve "Сокращение названий статей в прикреплении" Closes #121 See merge request romanov73/ng-tracker!89
This commit is contained in:
commit
aaa21d591d
@ -13,7 +13,7 @@ import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.grant.model.GrantDto;
|
||||
import ru.ulstu.grant.service.GrantService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.user.model.User;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
@ -104,7 +104,6 @@ public class GrantController {
|
||||
return GRANT_PAGE;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/grant", params = "createProject")
|
||||
public String createProject(@Valid GrantDto grantDto, Errors errors) throws IOException {
|
||||
if (errors.hasErrors()) {
|
||||
@ -131,7 +130,7 @@ public class GrantController {
|
||||
}
|
||||
|
||||
@ModelAttribute("allPapers")
|
||||
public List<Paper> getAllPapers() {
|
||||
public List<PaperDto> getAllPapers() {
|
||||
return grantService.getAllUncompletedPapers();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,6 @@ public class Grant extends BaseEntity implements UserContainer {
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<FileData> files = new ArrayList<>();
|
||||
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "project_id")
|
||||
private Project project;
|
||||
|
@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.file.model.FileDataDto;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.project.model.ProjectDto;
|
||||
import ru.ulstu.user.model.UserDto;
|
||||
|
||||
@ -37,7 +37,7 @@ public class GrantDto {
|
||||
private boolean hasBAKPapers;
|
||||
private boolean hasScopusPapers;
|
||||
private List<Integer> paperIds = new ArrayList<>();
|
||||
private List<Paper> papers = new ArrayList<>();
|
||||
private List<PaperDto> papers = new ArrayList<>();
|
||||
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||
|
||||
public GrantDto() {
|
||||
@ -54,12 +54,12 @@ public class GrantDto {
|
||||
@JsonProperty("project") ProjectDto project,
|
||||
@JsonProperty("authorIds") Set<Integer> authorIds,
|
||||
@JsonProperty("authors") Set<UserDto> authors,
|
||||
@JsonProperty("leader") Integer leaderId,
|
||||
@JsonProperty("leaderId") Integer leaderId,
|
||||
@JsonProperty("wasLeader") boolean wasLeader,
|
||||
@JsonProperty("hasAge") boolean hasAge,
|
||||
@JsonProperty("hasDegree") boolean hasDegree,
|
||||
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||
@JsonProperty("papers") List<Paper> papers) {
|
||||
@JsonProperty("papers") List<PaperDto> papers) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
@ -92,7 +92,7 @@ public class GrantDto {
|
||||
this.hasAge = false;
|
||||
this.hasDegree = false;
|
||||
this.paperIds = convert(grant.getPapers(), paper -> paper.getId());
|
||||
this.papers = grant.getPapers();
|
||||
this.papers = convert(grant.getPapers(), PaperDto::new);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
@ -214,11 +214,11 @@ public class GrantDto {
|
||||
this.paperIds = paperIds;
|
||||
}
|
||||
|
||||
public List<Paper> getPapers() {
|
||||
public List<PaperDto> getPapers() {
|
||||
return papers;
|
||||
}
|
||||
|
||||
public void setPapers(List<Paper> papers) {
|
||||
public void setPapers(List<PaperDto> papers) {
|
||||
this.papers = papers;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.grant.model.GrantDto;
|
||||
import ru.ulstu.grant.repository.GrantRepository;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.project.model.ProjectDto;
|
||||
@ -34,7 +35,7 @@ import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION;
|
||||
|
||||
@Service
|
||||
public class GrantService {
|
||||
private final static int MAX_DISPLAY_SIZE = 40;
|
||||
private final static int MAX_DISPLAY_SIZE = 50;
|
||||
|
||||
private final GrantRepository grantRepository;
|
||||
private final ProjectService projectService;
|
||||
@ -210,17 +211,16 @@ public class GrantService {
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
public List<Paper> getGrantPapers(List<Integer> paperIds) {
|
||||
public List<PaperDto> getGrantPapers(List<Integer> paperIds) {
|
||||
return paperService.findAllSelect(paperIds);
|
||||
|
||||
}
|
||||
|
||||
public List<Paper> getAllPapers() {
|
||||
return paperService.findAll();
|
||||
}
|
||||
|
||||
public List<Paper> getAllUncompletedPapers() {
|
||||
return paperService.findAllNotCompleted();
|
||||
public List<PaperDto> getAllUncompletedPapers() {
|
||||
List<PaperDto> papers = paperService.findAllNotCompleted();
|
||||
papers.stream()
|
||||
.forEach(paper ->
|
||||
paper.setTitle(StringUtils.abbreviate(paper.getTitle(), MAX_DISPLAY_SIZE)));
|
||||
return papers;
|
||||
}
|
||||
|
||||
public void attachPaper(GrantDto grantDto) {
|
||||
|
@ -248,12 +248,12 @@ public class PaperService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Paper> findAllNotCompleted() {
|
||||
return paperRepository.findByStatusNot(COMPLETED);
|
||||
public List<PaperDto> findAllNotCompleted() {
|
||||
return convert(paperRepository.findByStatusNot(COMPLETED), PaperDto::new);
|
||||
}
|
||||
|
||||
public List<Paper> findAllSelect(List<Integer> paperIds) {
|
||||
return sortPapers(paperRepository.findAllByIdIn(paperIds));
|
||||
public List<PaperDto> findAllSelect(List<Integer> paperIds) {
|
||||
return convert(paperRepository.findAllByIdIn(paperIds), PaperDto::new);
|
||||
}
|
||||
|
||||
public List<User> getPaperAuthors() {
|
||||
|
@ -184,9 +184,9 @@
|
||||
value="Отобразить прикрепленную статью"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input th:type="hidden" th:field="*{papers}"/>
|
||||
<div class="form-control list-group div-selected-papers" id="selected-papers">
|
||||
<div th:each="paper, rowStat : *{papers}">
|
||||
<input type="hidden" th:field="*{papers[__${rowStat.index}__].id}"/>
|
||||
<div class="col">
|
||||
<a th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
|
||||
<img class="icon-paper" src="/img/conference/paper.png"/>
|
||||
@ -201,6 +201,7 @@
|
||||
Статус статьи
|
||||
</span>
|
||||
</div>
|
||||
<!--
|
||||
<div class="col" th:unless="${#lists.isEmpty(paper.grants)}">
|
||||
<label>Гранты: </label>
|
||||
<div th:each="grant, grantRowStat : *{papers[__${rowStat.index}__].grants}"
|
||||
@ -225,6 +226,7 @@
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user