Modeling first attempt for DB

This commit is contained in:
Matthias Engelien
2024-09-08 16:38:17 +02:00
parent a0cf2d1854
commit 6985e0ea87
8 changed files with 123 additions and 11 deletions

View File

@@ -2,8 +2,10 @@ package de.etecture.ga.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.springframework.data.annotation.Id;
import org.springframework.util.Assert;
import lombok.Data;
@@ -12,18 +14,35 @@ public class Garage {
@Id
private Long id;
private String name;
private List<Appointment> appointments;
private Set<GarageServices> garageServices;
public Garage addAppointment(Appointment appointment) {
if(this.appointments == null) {
if (this.appointments == null) {
this.appointments = new ArrayList<>();
}
this.appointments.add(appointment);
return this;
}
public void addService(MDService service) {
garageServices.add(createGarageService(service));
}
private GarageServices createGarageService(MDService service) {
Assert.notNull(service, "Service must not be null");
Assert.notNull(service.getId(), "Service id, must not be null");
GarageServices garageService = new GarageServices();
garageService.setMdService(service.getId());
return garageService;
}
}