PMT-16: Update Manual Validation Method of Projects to Include the builtin.
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
parent
0d359c4d0b
commit
125f174b3b
1 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
package de.hmmh.pmt.db;
|
package de.hmmh.pmt.db;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.Validation;
|
||||||
|
import jakarta.validation.Validator;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
@ -10,6 +13,7 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -46,7 +50,13 @@ public class Project {
|
||||||
|
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return plannedEnd.isAfter(start) && (realEnd == null || realEnd.isAfter(start));
|
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||||
|
Set<ConstraintViolation<Project>> violations = validator.validate(this);
|
||||||
|
|
||||||
|
return violations.isEmpty() &&
|
||||||
|
plannedEnd.isAfter(start) &&
|
||||||
|
(realEnd == null || realEnd.isAfter(start));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue