|
|
|
@ -4,7 +4,12 @@ import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import ru.ulstu.activity.common.model.EventSource;
|
|
|
|
|
import ru.ulstu.activity.conference.model.Conference;
|
|
|
|
|
import ru.ulstu.activity.deadline.model.Deadline;
|
|
|
|
|
import ru.ulstu.activity.grant.model.Grant;
|
|
|
|
|
import ru.ulstu.activity.paper.model.Paper;
|
|
|
|
|
import ru.ulstu.activity.project.model.Project;
|
|
|
|
|
import ru.ulstu.activity.students.model.Task;
|
|
|
|
|
import ru.ulstu.activity.timeline.model.Event;
|
|
|
|
|
import ru.ulstu.activity.timeline.model.EventDto;
|
|
|
|
|
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
|
|
|
@ -61,20 +66,38 @@ public class EventService {
|
|
|
|
|
+ deadline.getDescription()
|
|
|
|
|
+ "' " + eventSource.getSuffix() + " '"
|
|
|
|
|
+ eventSource.getTitle() + "'");
|
|
|
|
|
newEvent.getRecipients().addAll(eventSource.getRecipients());
|
|
|
|
|
eventSource.addObjectToEvent(newEvent);
|
|
|
|
|
newEvent.setRecipients(eventSource.getRecipients());
|
|
|
|
|
newEvents.add(eventRepository.save(newEvent));
|
|
|
|
|
}
|
|
|
|
|
eventRepository.saveAll(newEvents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PageableItems<EventDto> createPageable(Page<Event> page) {
|
|
|
|
|
return convertPageable(new PageableItems<>(page.getTotalElements(), page.getContent()), EventDto::new);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteByObject(EventSource eventSource) {
|
|
|
|
|
public void deleteAll(List<Event> events) {
|
|
|
|
|
eventRepository.deleteAll(events);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Event> findByConference(Conference conference) {
|
|
|
|
|
return eventRepository.findAllByConference(conference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Event> findByGrant(Grant entity) {
|
|
|
|
|
return eventRepository.findAllByGrant(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Event> findByProject(Project entity) {
|
|
|
|
|
return eventRepository.findAllByProject(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Event> findByPaper(Paper entity) {
|
|
|
|
|
return eventRepository.findAllByPaper(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Event> findByTask(Task entity) {
|
|
|
|
|
return eventRepository.findAllByTask(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|