Fix editing application periods

Instead of clearing an attached entity's persistent set, remove the things we want to remove and add the things that are missing.
This commit is contained in:
Andreas Svanberg 2025-02-20 16:01:19 +01:00
parent 0d5bdd69ed
commit 1e109e2de8

@ -176,10 +176,12 @@ public class ApplicationPeriod extends DomainObject {
return Collections.unmodifiableSet(answerSet);
}
public void setProjectTypes(Iterable<ProjectType> projectTypes) {
this.projectTypes.clear();
public void setProjectTypes(Set<ProjectType> projectTypes) {
this.projectTypes.removeIf(appt -> !projectTypes.contains(appt.getProjectType()));
for (ProjectType pt : projectTypes) {
this.projectTypes.add(new ApplicationPeriodProjectType(this, pt));
if (this.projectTypes.stream().noneMatch(appt -> appt.getProjectType().equals(pt))) {
addProjectType(pt);
}
}
}