From c17591bf10b9177a6bf47b0089142804ad97e20d Mon Sep 17 00:00:00 2001
From: Anton Romanov
Date: Tue, 8 Jan 2019 19:55:27 +0000
Subject: [PATCH 1/3] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7cea15a..b324350 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# NG-Tracker
+# ![NG](http://193.110.3.124:8080/favicon.ico) NG-Tracker
Информационная система для автоматизации деятельности научной группы.
From 779bc3eafc4f306bbf6ed04e6fd458e4ea772738 Mon Sep 17 00:00:00 2001
From: Anton Romanov
Date: Thu, 17 Jan 2019 00:57:34 +0400
Subject: [PATCH 2/3] fix failed conditions
---
src/main/java/ru/ulstu/paper/model/Paper.java | 9 +++++++++
src/main/java/ru/ulstu/paper/service/PaperService.java | 5 ++---
.../mail_templates/paperFailedNotification.html | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java
index ed55e98..c09fd28 100644
--- a/src/main/java/ru/ulstu/paper/model/Paper.java
+++ b/src/main/java/ru/ulstu/paper/model/Paper.java
@@ -169,4 +169,13 @@ public class Paper extends BaseEntity implements UserContainer {
.filter(d -> d.getDate().after(new Date()))
.findFirst();
}
+
+ public boolean lastDeadlineFailed() {
+ return !deadlines
+ .stream()
+ .filter(deadline -> deadline.getDate() != null)
+ .filter(d -> d.getDate().after(new Date()))
+ .findAny()
+ .isPresent();
+ }
}
diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java
index affbf0e..74e4fb5 100644
--- a/src/main/java/ru/ulstu/paper/service/PaperService.java
+++ b/src/main/java/ru/ulstu/paper/service/PaperService.java
@@ -166,11 +166,10 @@ public class PaperService {
public void closeFailedPapers() {
List papers = paperRepository.findAll()
.stream()
- .filter(paper -> paper.getNextDeadline().isPresent()
+ .filter(paper -> paper.lastDeadlineFailed()
&& (paper.getStatus() == ON_PREPARATION
|| paper.getStatus() == DRAFT
- || paper.getStatus() == ATTENTION)
- && paper.getNextDeadline().get().getDate().before(new Date()))
+ || paper.getStatus() == ATTENTION))
.collect(Collectors.toList());
papers.forEach(paper -> {
Paper.PaperStatus oldStatus = paper.getStatus();
diff --git a/src/main/resources/mail_templates/paperFailedNotification.html b/src/main/resources/mail_templates/paperFailedNotification.html
index cacc7e9..3eb1399 100644
--- a/src/main/resources/mail_templates/paperFailedNotification.html
+++ b/src/main/resources/mail_templates/paperFailedNotification.html
@@ -11,7 +11,7 @@
Статья "Title" провалена.
- Предыдущий статус - "oldStatus".
+ Предыдущий статус - "oldStatus".
Regards,
From c00390a17b89bf35b13ca7d5f33438f0062c4442 Mon Sep 17 00:00:00 2001
From: Anton Romanov
Date: Thu, 17 Jan 2019 01:01:26 +0400
Subject: [PATCH 3/3] 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));
}