Resolve "Ping конференции в списке конференций" #196
@ -86,7 +86,7 @@ public class ConferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/conference", params = "addDeadline")
|
@PostMapping(value = "/conference", params = "addDeadline")
|
||||||
public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) {
|
public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
filterEmptyDeadlines(conferenceDto);
|
filterEmptyDeadlines(conferenceDto);
|
||||||
if (errors.hasErrors()) {
|
if (errors.hasErrors()) {
|
||||||
return CONFERENCE_PAGE;
|
return CONFERENCE_PAGE;
|
||||||
@ -95,16 +95,6 @@ public class ConferenceController {
|
|||||||
return CONFERENCE_PAGE;
|
return CONFERENCE_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/conference", params = "addPaper")
|
|
||||||
public String addPaper(@Valid ConferenceDto conferenceDto, Errors errors) {
|
|
||||||
if (errors.hasErrors()) {
|
|
||||||
return CONFERENCE_PAGE;
|
|
||||||
}
|
|
||||||
conferenceService.addPaper(conferenceDto);
|
|
||||||
|
|
||||||
return CONFERENCE_PAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/conference", params = "removeDeadline")
|
@PostMapping(value = "/conference", params = "removeDeadline")
|
||||||
public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors,
|
public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors,
|
||||||
@RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException {
|
@RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException {
|
||||||
@ -115,6 +105,16 @@ public class ConferenceController {
|
|||||||
return CONFERENCE_PAGE;
|
return CONFERENCE_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "addPaper")
|
||||||
|
public String addPaper(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.addPaper(conferenceDto);
|
||||||
|
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/conference", params = "removePaper")
|
@PostMapping(value = "/conference", params = "removePaper")
|
||||||
public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors,
|
public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors,
|
||||||
@RequestParam(value = "removePaper") Integer paperIndex) throws IOException {
|
@RequestParam(value = "removePaper") Integer paperIndex) throws IOException {
|
||||||
|
@ -53,7 +53,7 @@ public class Conference extends BaseEntity {
|
|||||||
@OrderBy("date")
|
@OrderBy("date")
|
||||||
private List<Deadline> deadlines = new ArrayList<>();
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "paper_conference",
|
@JoinTable(name = "paper_conference",
|
||||||
joinColumns = {@JoinColumn(name = "conference_id")},
|
joinColumns = {@JoinColumn(name = "conference_id")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
||||||
|
@ -111,9 +111,19 @@ public class ConferenceService {
|
|||||||
conferenceDto.getDeadlines().remove((int) deadlineIndex);
|
conferenceDto.getDeadlines().remove((int) deadlineIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPaper(ConferenceDto conferenceDto) {
|
||||||
|
Paper paper = new Paper();
|
||||||
|
paper.setTitle(userService.getCurrentUser().getLastName() + "_" + conferenceDto.getTitle());
|
||||||
|
paper.setStatus(Paper.PaperStatus.DRAFT);
|
||||||
|
|
||||||
|
conferenceDto.getPapers().add(paper);
|
||||||
|
}
|
||||||
|
|
||||||
public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException {
|
public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException {
|
||||||
Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex);
|
Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex);
|
||||||
conferenceDto.getNotSelectedPapers().add(removedPaper);
|
if (removedPaper.getId() != null) {
|
||||||
|
conferenceDto.getNotSelectedPapers().add(removedPaper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
||||||
@ -144,7 +154,8 @@ public class ConferenceService {
|
|||||||
conference.setPing(0);
|
conference.setPing(0);
|
||||||
conference.setBeginDate(conferenceDto.getBeginDate());
|
conference.setBeginDate(conferenceDto.getBeginDate());
|
||||||
conference.setEndDate(conferenceDto.getEndDate());
|
conference.setEndDate(conferenceDto.getEndDate());
|
||||||
conference.setPapers(conferenceDto.getPapers());
|
conference.getPapers().clear();
|
||||||
|
conferenceDto.getPapers().forEach(paper -> conference.getPapers().add(paper.getId() != null ? paperService.findPaperById(paper.getId()) : paperService.create(paper)));
|
||||||
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
||||||
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
|
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
|
||||||
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
||||||
@ -173,10 +184,4 @@ public class ConferenceService {
|
|||||||
public List<Conference> findAllActive() {
|
public List<Conference> findAllActive() {
|
||||||
return conferenceRepository.findAllActive(new Date());
|
return conferenceRepository.findAllActive(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPaper(ConferenceDto conferenceDto) {
|
|
||||||
Paper paper = new Paper();
|
|
||||||
paper.setTitle(userService.getCurrentUser().getLastName() + "_" + conferenceDto.getTitle());
|
|
||||||
conferenceDto.getPapers().add(paper);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,14 @@ public class PaperService {
|
|||||||
return newPaper.getId();
|
return newPaper.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Paper create(Paper paper) {
|
||||||
|
Paper newPaper = paperRepository.save(paper);
|
||||||
|
paperNotificationService.sendCreateNotification(newPaper);
|
||||||
|
eventService.createFromPaper(newPaper);
|
||||||
|
return newPaper;
|
||||||
|
}
|
||||||
|
|
||||||
private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException {
|
private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException {
|
||||||
paper.setComment(paperDto.getComment());
|
paper.setComment(paperDto.getComment());
|
||||||
paper.setUrl(paperDto.getUrl());
|
paper.setUrl(paperDto.getUrl());
|
||||||
|
@ -131,9 +131,11 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="papers">Статьи:</label>
|
<label for="papers">Статьи:</label>
|
||||||
<div class="paper-list form-control list-group" id="papers">
|
<div class="paper-list form-control list-group" id="papers">
|
||||||
<input th:type="hidden" th:field="*{papers}"/>
|
<!--<input th:type="hidden" th:field="*{papers}"/>-->
|
||||||
<div class="paper d-flex list-group-item p-0"
|
<div class="paper d-flex list-group-item p-0"
|
||||||
th:each="paper, rowStat : *{papers}">
|
th:each="paper, rowStat : *{papers}">
|
||||||
|
<input type="hidden" th:field="*{papers[__${rowStat.index}__].id}"/>
|
||||||
|
<input type="hidden" th:field="*{papers[__${rowStat.index}__].title}"/>
|
||||||
<a class="paper-name"
|
<a class="paper-name"
|
||||||
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}"
|
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}"
|
||||||
th:if="*{papers[__${rowStat.index}__].id !=null}">
|
th:if="*{papers[__${rowStat.index}__].id !=null}">
|
||||||
|
Loading…
Reference in New Issue
Block a user