PMT-16: Add Validation for Time Range to Project Entity

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-10-07 15:57:02 +02:00
parent e14c0f2c36
commit f64932a637
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C

View file

@ -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));
}
}