Merge branch 'dev' of gitlab.com:romanov73/ng-tracker into 101-projecgt-timeline
This commit is contained in:
commit
1224cc7a23
@ -232,10 +232,8 @@ public class GrantService extends BaseService {
|
||||
|
||||
private boolean checkSameDeadline(GrantDto grantDto, Integer id) {
|
||||
Date date = grantDto.getDeadlines().get(0).getDate(); //дата с сайта киас
|
||||
if (deadlineService.findByGrantIdAndDate(id, date).compareTo(date) == 0) { //если есть такая строка с датой
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Date foundGrantDate = deadlineService.findByGrantIdAndDate(id, date);
|
||||
return foundGrantDate != null && foundGrantDate.compareTo(date) == 0;
|
||||
}
|
||||
|
||||
public List<User> getGrantAuthors(GrantDto grantDto) {
|
||||
|
@ -19,6 +19,8 @@ import ru.ulstu.user.model.UserDto;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -105,9 +107,13 @@ public class EventService {
|
||||
}
|
||||
|
||||
public void createFromPaper(Paper newPaper) {
|
||||
createFromPaper(newPaper, Collections.emptyList());
|
||||
}
|
||||
|
||||
public void createFromPaper(Paper newPaper, List<Event> events) {
|
||||
List<Timeline> timelines = timelineService.findAll();
|
||||
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
|
||||
|
||||
timeline.getEvents().removeAll(events);
|
||||
for (Deadline deadline : newPaper.getDeadlines()
|
||||
.stream()
|
||||
.filter(d -> d.getDate().after(new Date()) || DateUtils.isSameDay(d.getDate(), new Date()))
|
||||
@ -121,17 +127,15 @@ public class EventService {
|
||||
newEvent.setDescription("Дедлайн '" + deadline.getDescription() + "' cтатьи '" + newPaper.getTitle() + "'");
|
||||
newEvent.setRecipients(new ArrayList(newPaper.getAuthors()));
|
||||
newEvent.setPaper(newPaper);
|
||||
eventRepository.save(newEvent);
|
||||
|
||||
timeline.getEvents().add(newEvent);
|
||||
timelineService.save(timeline);
|
||||
timeline.getEvents().add(eventRepository.save(newEvent));
|
||||
}
|
||||
timelineService.save(timeline);
|
||||
}
|
||||
|
||||
public void updatePaperDeadlines(Paper paper) {
|
||||
eventRepository.delete(eventRepository.findAllByPaper(paper));
|
||||
|
||||
createFromPaper(paper);
|
||||
List<Event> foundEvents = eventRepository.findAllByPaper(paper);
|
||||
eventRepository.delete(foundEvents);
|
||||
createFromPaper(paper, foundEvents);
|
||||
}
|
||||
|
||||
public List<Event> findByCurrentDate() {
|
||||
|
Loading…
Reference in New Issue
Block a user