Modeling first attempt for DB
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user