fix update paper

pull/244/head
Anton Romanov 5 years ago
parent 1fbee8f0f2
commit c966a100da

@ -54,6 +54,9 @@ public class PaperService extends AbstractActivityService<Paper, PaperDto, Paper
private final EventService eventService;
private final PingService pingService;
private Paper.PaperStatus oldStatus;
private Set<User> oldAuthors;
public PaperService(PaperRepository paperRepository,
FileService fileService,
PaperNotificationService paperNotificationService,
@ -99,8 +102,6 @@ public class PaperService extends AbstractActivityService<Paper, PaperDto, Paper
@Transactional
public Paper update(Paper paper) {
Paper.PaperStatus oldStatus = paper.getStatus();
Set<User> oldAuthors = new HashSet<>(paper.getAuthors());
paperRepository.save(paper);
paperNotificationService.sendCreateNotification(paper, oldAuthors);
paperNotificationService.statusChangeNotification(paper, oldStatus);
@ -116,6 +117,8 @@ public class PaperService extends AbstractActivityService<Paper, PaperDto, Paper
public PaperDto update(PaperDto paperDto) {
Paper paper = paperRepository.findById(paperDto.getId())
.orElseThrow(() -> new EntityNotFoundException("Paper with id=" + paperDto.getId() + " not found"));
oldStatus = paper.getStatus();
oldAuthors = new HashSet<>(paper.getAuthors());
//TODO: move to service
if (paperDto.getFiles() != null) {

Loading…
Cancel
Save