#121 change Paper to PaperDto in attaching papers
This commit is contained in:
parent
ff7f535980
commit
e1907d3169
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user