From 118797258a22e21d568a72c62a23b1ff39f8478c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Mon, 7 Oct 2024 15:57:02 +0200 Subject: [PATCH] PMT-16: Add Validation for Time Range to Project Entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- src/main/java/de/hmmh/pmt/db/Project.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hmmh/pmt/db/Project.java b/src/main/java/de/hmmh/pmt/db/Project.java index 9c9891f..c66731a 100644 --- a/src/main/java/de/hmmh/pmt/db/Project.java +++ b/src/main/java/de/hmmh/pmt/db/Project.java @@ -19,7 +19,7 @@ import java.time.LocalDateTime; @Table(name = "project") public class Project { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotBlank @@ -43,5 +43,10 @@ public class Project { private LocalDateTime plannedEnd; private LocalDateTime realEnd; // Cant be named just "end" because it's and SQL Keyword + + + public boolean isValid() { + return plannedEnd.isAfter(start) && (realEnd == null || realEnd.isAfter(start)); + } }