|
|
|
@ -8,11 +8,13 @@ import ru.ulstu.conference.model.Conference;
|
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
|
import ru.ulstu.grant.model.Grant;
|
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
|
import ru.ulstu.project.model.Project;
|
|
|
|
|
import ru.ulstu.students.model.Task;
|
|
|
|
|
import ru.ulstu.timeline.model.Event;
|
|
|
|
|
import ru.ulstu.timeline.model.EventDto;
|
|
|
|
|
import ru.ulstu.timeline.model.Timeline;
|
|
|
|
|
import ru.ulstu.timeline.repository.EventRepository;
|
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
|
import ru.ulstu.user.model.UserDto;
|
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
|
|
|
|
|
@ -205,6 +207,38 @@ public class EventService {
|
|
|
|
|
createFromGrant(grant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void createFromProject(Project newProject) {
|
|
|
|
|
List<Timeline> timelines = timelineService.findAll();
|
|
|
|
|
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
|
|
|
|
|
|
|
|
|
|
for (Deadline deadline : newProject.getDeadlines()
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(d -> d.getDate().after(new Date()) || DateUtils.isSameDay(d.getDate(), new Date()))
|
|
|
|
|
.collect(Collectors.toList())) {
|
|
|
|
|
Event newEvent = new Event();
|
|
|
|
|
newEvent.setTitle("Дедлайн проекта");
|
|
|
|
|
newEvent.setStatus(Event.EventStatus.NEW);
|
|
|
|
|
newEvent.setExecuteDate(deadline.getDate());
|
|
|
|
|
newEvent.setCreateDate(new Date());
|
|
|
|
|
newEvent.setUpdateDate(new Date());
|
|
|
|
|
newEvent.setDescription("Дедлайн '" + deadline.getDescription() + "' проекта '" + newProject.getTitle() + "'");
|
|
|
|
|
if (newProject.getExecutors() != null) {
|
|
|
|
|
newEvent.setRecipients(new ArrayList(newProject.getExecutors()));
|
|
|
|
|
}
|
|
|
|
|
newEvent.getRecipients().add((User) newProject.getExecutors());
|
|
|
|
|
newEvent.setProject(newProject);
|
|
|
|
|
eventRepository.save(newEvent);
|
|
|
|
|
|
|
|
|
|
timeline.getEvents().add(newEvent);
|
|
|
|
|
timelineService.save(timeline);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateProjectDeadlines(Project project) {
|
|
|
|
|
eventRepository.delete(eventRepository.findAllByProject(project));
|
|
|
|
|
createFromProject(project);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void removeConferencesEvent(Conference conference) {
|
|
|
|
|
List<Event> eventList = eventRepository.findAllByConference(conference);
|
|
|
|
|
eventList.forEach(event -> eventRepository.delete(event.getId()));
|
|
|
|
|