|
|
@ -10,6 +10,7 @@ import ru.ulstu.conference.model.ConferenceDto;
|
|
|
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
|
|
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
|
|
|
import ru.ulstu.conference.model.ConferenceUser;
|
|
|
|
import ru.ulstu.conference.model.ConferenceUser;
|
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
@ -22,6 +23,7 @@ import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
|
|
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
@ -101,7 +103,13 @@ public class ConferenceService {
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public Integer update(ConferenceDto conferenceDto) throws IOException {
|
|
|
|
public Integer update(ConferenceDto conferenceDto) throws IOException {
|
|
|
|
Conference conference = conferenceRepository.findOne(conferenceDto.getId());
|
|
|
|
Conference conference = conferenceRepository.findOne(conferenceDto.getId());
|
|
|
|
|
|
|
|
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
|
|
|
|
|
|
|
.map(this::copyDeadline)
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
Date oldBeginDate = conference.getBeginDate();
|
|
|
|
|
|
|
|
Date oldEndDate = conference.getEndDate();
|
|
|
|
conferenceRepository.save(copyFromDto(conference, conferenceDto));
|
|
|
|
conferenceRepository.save(copyFromDto(conference, conferenceDto));
|
|
|
|
|
|
|
|
sendNotificationAfterUpdate(conference, oldDeadlines, oldBeginDate, oldEndDate);
|
|
|
|
conferenceDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
|
|
|
conferenceDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
|
|
|
return conference.getId();
|
|
|
|
return conference.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -228,4 +236,36 @@ public class ConferenceService {
|
|
|
|
modelMap.addAttribute("nearshoreSales", nearshoreSales);
|
|
|
|
modelMap.addAttribute("nearshoreSales", nearshoreSales);
|
|
|
|
modelMap.addAttribute("offshoreSales", offshoreSales);
|
|
|
|
modelMap.addAttribute("offshoreSales", offshoreSales);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sendNotificationAfterUpdate(Conference conference, List<Deadline> oldDeadlines, Date oldBeginDate, Date oldEndDate) {
|
|
|
|
|
|
|
|
boolean isSendNotificationAboutDeadlines = false;
|
|
|
|
|
|
|
|
if (oldDeadlines.size() != conference.getDeadlines().size()) {
|
|
|
|
|
|
|
|
isSendNotificationAboutDeadlines = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Deadline deadline : conference.getDeadlines()) {
|
|
|
|
|
|
|
|
if (isSendNotificationAboutDeadlines) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Deadline oldDeadline : oldDeadlines) {
|
|
|
|
|
|
|
|
if (deadline.getId().equals(oldDeadline.getId())) {
|
|
|
|
|
|
|
|
if (!deadline.getDescription().equals(oldDeadline.getDescription()) || !deadline.getDate().equals(oldDeadline.getDate())) {
|
|
|
|
|
|
|
|
isSendNotificationAboutDeadlines = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSendNotificationAboutDeadlines) {
|
|
|
|
|
|
|
|
conferenceNotificationService.updateDeadlineNotification(conference);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!conference.getBeginDate().equals(oldBeginDate) || !conference.getEndDate().equals(oldEndDate)) {
|
|
|
|
|
|
|
|
conferenceNotificationService.updateConferencesDatesNotification(conference, oldBeginDate, oldEndDate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Deadline copyDeadline(Deadline oldDeadline) {
|
|
|
|
|
|
|
|
Deadline newDeadline = new Deadline(oldDeadline.getDate(), oldDeadline.getDescription());
|
|
|
|
|
|
|
|
newDeadline.setId(oldDeadline.getId());
|
|
|
|
|
|
|
|
return newDeadline;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|