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