#70 added new column to event
This commit is contained in:
parent
34925b81ff
commit
51877023d1
@ -146,13 +146,4 @@ public class Conference extends BaseEntity {
|
||||
.filter(d -> d.getDate().after(new Date()))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
public boolean lastDeadlineFailed() {
|
||||
return !deadlines
|
||||
.stream()
|
||||
.filter(deadline -> deadline.getDate() != null)
|
||||
.filter(d -> d.getDate().after(new Date()))
|
||||
.findAny()
|
||||
.isPresent();
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ public class ConferenceScheduler {
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 21-22 * * *", zone = "Europe/Samara")
|
||||
@Scheduled(cron = "0 0 8 * * *", zone = "Europe/Samara")
|
||||
public void checkDeadlineBeforeWeek() {
|
||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started");
|
||||
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 21-22 * * ?", zone = "Europe/Samara")
|
||||
@Scheduled(cron = "0 0 8 * * ?", zone = "Europe/Samara")
|
||||
public void checkDeadlineAfterWeek() {
|
||||
log.debug("ConferenceScheduler.checkDeadlineAfterWeek started");
|
||||
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(), !IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
|
@ -15,6 +15,7 @@ import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.ping.service.PingService;
|
||||
import ru.ulstu.timeline.service.EventService;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
@ -39,6 +40,7 @@ public class ConferenceService {
|
||||
private final UserService userService;
|
||||
private final PingService pingService;
|
||||
private final ConferenceNotificationService conferenceNotificationService;
|
||||
private final EventService eventService;
|
||||
|
||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||
ConferenceUserService conferenceUserService,
|
||||
@ -46,7 +48,8 @@ public class ConferenceService {
|
||||
PaperService paperService,
|
||||
UserService userService,
|
||||
PingService pingService,
|
||||
ConferenceNotificationService conferenceNotificationService) {
|
||||
ConferenceNotificationService conferenceNotificationService,
|
||||
EventService eventService) {
|
||||
this.conferenceRepository = conferenceRepository;
|
||||
this.conferenceUserService = conferenceUserService;
|
||||
this.deadlineService = deadlineService;
|
||||
@ -54,6 +57,7 @@ public class ConferenceService {
|
||||
this.userService = userService;
|
||||
this.pingService = pingService;
|
||||
this.conferenceNotificationService = conferenceNotificationService;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
public ConferenceDto getExistConferenceById(Integer id) {
|
||||
@ -97,6 +101,7 @@ public class ConferenceService {
|
||||
Conference newConference = copyFromDto(new Conference(), conferenceDto);
|
||||
newConference = conferenceRepository.save(newConference);
|
||||
conferenceNotificationService.sendCreateNotification(newConference);
|
||||
eventService.createFromConference(newConference);
|
||||
return newConference.getId();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.timeline.model.Event;
|
||||
@ -140,4 +141,28 @@ public class EventService {
|
||||
public List<EventDto> findAllFutureDto() {
|
||||
return convert(findAllFuture(), EventDto::new);
|
||||
}
|
||||
|
||||
public void createFromConference(Conference newConference) {
|
||||
List<Timeline> timelines = timelineService.findAll();
|
||||
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
|
||||
|
||||
for (Deadline deadline : newConference.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() + "' cтатьи '" + newPaper.getTitle() + "'");
|
||||
// newEvent.setRecipients(new ArrayList(newPaper.getAuthors()));
|
||||
// newEvent.setConference(newConference);
|
||||
eventRepository.save(newEvent);
|
||||
|
||||
timeline.getEvents().add(newEvent);
|
||||
timelineService.save(timeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
src/main/resources/db/changelog-20190426_000000-schema.xml
Normal file
13
src/main/resources/db/changelog-20190426_000000-schema.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
<changeSet author="vova" id="20190426_000000-1">
|
||||
<addColumn tableName="event">
|
||||
<column name="conference_id" type="integer"></column>
|
||||
</addColumn>
|
||||
<addForeignKeyConstraint baseTableName="event" baseColumnNames="conference_id"
|
||||
constraintName="fk_event_conference_id" referencedTableName="conference"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -34,4 +34,5 @@
|
||||
<include file="db/changelog-20190421_000000-schema.xml"/>
|
||||
<include file="db/changelog-20190422_000000-schema.xml"/>
|
||||
<include file="db/changelog-20190424_000000-schema.xml"/>
|
||||
<include file="db/changelog-20190426_000000-schema.xml"/>
|
||||
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user