|
|
@ -8,7 +8,9 @@ import ru.ulstu.paper.model.PaperDto;
|
|
|
|
import ru.ulstu.paper.repository.PaperRepository;
|
|
|
|
import ru.ulstu.paper.repository.PaperRepository;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
|
|
|
|
|
|
|
@ -25,7 +27,17 @@ public class PaperService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<PaperDto> findAll() {
|
|
|
|
public List<PaperDto> findAll() {
|
|
|
|
return convert(paperRepository.findAll(), PaperDto::new);
|
|
|
|
List<Paper> allPapers = paperRepository.findAll();
|
|
|
|
|
|
|
|
allPapers = allPapers.stream().sorted((paper1, paper2) -> {
|
|
|
|
|
|
|
|
int statusCompareResult =
|
|
|
|
|
|
|
|
Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus()))
|
|
|
|
|
|
|
|
.compareTo(Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus())));
|
|
|
|
|
|
|
|
if (statusCompareResult != 0) {
|
|
|
|
|
|
|
|
return statusCompareResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return paper1.getTitle().compareTo(paper2.getTitle());
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
return convert(allPapers, PaperDto::new);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|