From c00390a17b89bf35b13ca7d5f33438f0062c4442 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 17 Jan 2019 01:01:26 +0400 Subject: [PATCH] filter dashboard papers --- .../java/ru/ulstu/paper/controller/PaperController.java | 2 +- src/main/java/ru/ulstu/paper/service/PaperService.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index 8969a06..6f475bf 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -49,7 +49,7 @@ public class PaperController { @GetMapping("/dashboard") public void getDashboard(ModelMap modelMap) { - modelMap.put("papers", paperService.findAllDto()); + modelMap.put("papers", paperService.findAllActive()); } @GetMapping("/paper") diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 74e4fb5..9df8be2 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -24,7 +24,9 @@ import java.util.stream.Collectors; import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; import static ru.ulstu.paper.model.Paper.PaperStatus.ATTENTION; +import static ru.ulstu.paper.model.Paper.PaperStatus.COMPLETED; import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT; +import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED; import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION; @Service @@ -59,6 +61,13 @@ public class PaperService { return papers; } + public List findAllActive() { + return findAllDto() + .stream() + .filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED) + .collect(Collectors.toList()); + } + public PaperDto findOneDto(Integer id) { return new PaperDto(paperRepository.findOne(id)); }