2019-04-02 10:53:09 +04:00
|
|
|
package ru.ulstu.conference.service;
|
|
|
|
|
2019-04-04 17:58:22 +04:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2019-04-02 10:53:09 +04:00
|
|
|
import org.springframework.stereotype.Service;
|
2019-04-04 17:58:22 +04:00
|
|
|
import ru.ulstu.conference.model.Conference;
|
|
|
|
import ru.ulstu.conference.model.ConferenceDto;
|
2019-04-02 10:53:09 +04:00
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
|
2019-04-04 17:58:22 +04:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
|
2019-04-02 10:53:09 +04:00
|
|
|
@Service
|
|
|
|
public class ConferenceService {
|
2019-04-04 17:58:22 +04:00
|
|
|
private final static int MAX_DISPLAY_SIZE = 40;
|
|
|
|
|
2019-04-02 10:53:09 +04:00
|
|
|
private final ConferenceRepository conferenceRepository;
|
|
|
|
private final DeadlineService deadlineService;
|
|
|
|
|
|
|
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
|
|
|
DeadlineService deadlineService) {
|
|
|
|
this.conferenceRepository = conferenceRepository;
|
|
|
|
this.deadlineService = deadlineService;
|
|
|
|
}
|
2019-04-04 17:58:22 +04:00
|
|
|
|
|
|
|
public List<Conference> findAll() {
|
|
|
|
return conferenceRepository.findAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ConferenceDto> findAllDto() {
|
|
|
|
List<ConferenceDto> conferences = convert(findAll(), ConferenceDto::new);
|
|
|
|
conferences.forEach(conferenceDto -> conferenceDto.setTitle(StringUtils.abbreviate(conferenceDto.getTitle(), MAX_DISPLAY_SIZE)));
|
|
|
|
return conferences;
|
|
|
|
}
|
|
|
|
|
|
|
|
// private List<Paper> sortPapers(List<Conference> conferences) {
|
|
|
|
// return conferences.stream().sorted((paper1, paper2) -> {
|
|
|
|
// int statusCompareResult =
|
|
|
|
// Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus()))
|
|
|
|
// .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus()));
|
|
|
|
// if (statusCompareResult != 0) {
|
|
|
|
// return statusCompareResult;
|
|
|
|
// }
|
|
|
|
// return paper1.getTitle().compareTo(paper2.getTitle());
|
|
|
|
// }).collect(toList());
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
2019-04-02 10:53:09 +04:00
|
|
|
}
|