Reformat Implementations

This commit is contained in:
Tobias Eidelpes 2021-04-02 16:54:50 +02:00
parent 37b60c4eeb
commit a0b099cbc3
6 changed files with 39 additions and 44 deletions

View File

@ -4,86 +4,87 @@ import dst.ass1.jpa.model.*;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@Entity @Entity
public class Driver implements IDriver { public class Driver implements IDriver {
@Id @Id @GeneratedValue private Long id;
private Long id;
private String name; private String name;
@NotNull @NotNull private String tel;
private String tel;
private Double avgRating; private Double avgRating;
@OneToMany @OneToMany(targetEntity = Match.class)
private Collection<IMatch> matches; private Collection<IMatch> matches = new ArrayList<>();
@ManyToOne
@ManyToOne(targetEntity = Vehicle.class)
private IVehicle vehicle; private IVehicle vehicle;
@ManyToMany
private Collection<IOrganization> organizations; @OneToMany(targetEntity = Employment.class)
private Collection<IEmployment> employments;
@Override @Override
public Collection<IEmployment> getEmployments() { public Collection<IEmployment> getEmployments() {
return null; return employments;
} }
@Override @Override
public void setEmployments(Collection<IEmployment> employments) { public void setEmployments(Collection<IEmployment> employments) {
this.employments = employments;
} }
@Override @Override
public void addEmployment(IEmployment employment) { public void addEmployment(IEmployment employment) {
this.employments.add(employment);
} }
@Override @Override
public IVehicle getVehicle() { public IVehicle getVehicle() {
return null; return vehicle;
} }
@Override @Override
public void setVehicle(IVehicle vehicle) { public void setVehicle(IVehicle vehicle) {
this.vehicle = vehicle;
} }
@Override @Override
public Long getId() { public Long getId() {
return null; return id;
} }
@Override @Override
public void setId(Long id) { public void setId(Long id) {
this.id = id;
} }
@Override @Override
public String getName() { public String getName() {
return null; return name;
} }
@Override @Override
public void setName(String name) { public void setName(String name) {
this.name = name;
} }
@Override @Override
public String getTel() { public String getTel() {
return null; return tel;
} }
@Override @Override
public void setTel(String tel) { public void setTel(String tel) {
this.tel = tel;
} }
@Override @Override
public Double getAvgRating() { public Double getAvgRating() {
return null; return avgRating;
} }
@Override @Override
public void setAvgRating(Double avgRating) { public void setAvgRating(Double avgRating) {
this.avgRating = avgRating;
} }
} }

View File

@ -3,19 +3,16 @@ package dst.ass1.jpa.model.impl;
import dst.ass1.jpa.model.ILocation; import dst.ass1.jpa.model.ILocation;
import dst.ass1.jpa.model.ITrip; import dst.ass1.jpa.model.ITrip;
import javax.persistence.Entity; import javax.persistence.*;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import java.util.Collection; import java.util.Collection;
@Entity @Entity
public class Location implements ILocation { public class Location implements ILocation {
@Id @Id @GeneratedValue private Long id;
private Long id;
private String name; private String name;
private Long locationId; private Long locationId;
@ManyToMany(mappedBy = "stops") @ManyToMany(targetEntity = Trip.class)
private Collection<ITrip> trips; private Collection<ITrip> trips;
@Override @Override

View File

@ -7,17 +7,17 @@ import java.util.Date;
@Entity @Entity
public class Match implements IMatch { public class Match implements IMatch {
@Id @Id @GeneratedValue private Long id;
private Long id;
private Date date; private Date date;
@Embedded @Embedded private IMoney fare;
private IMoney fare;
@OneToOne @OneToOne(targetEntity = Trip.class)
private ITrip trip; private ITrip trip;
@ManyToOne
@ManyToOne(targetEntity = Vehicle.class)
private IVehicle vehicle; private IVehicle vehicle;
@ManyToOne
@ManyToOne(targetEntity = Driver.class)
private IDriver driver; private IDriver driver;
@Override @Override

View File

@ -2,16 +2,13 @@ package dst.ass1.jpa.model.impl;
import dst.ass1.jpa.model.*; import dst.ass1.jpa.model.*;
import javax.persistence.Entity; import javax.persistence.*;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@Entity @Entity
public class Trip implements ITrip { public class Trip implements ITrip {
@Id @Id @GeneratedValue private Long id;
private Long id;
private Date created; private Date created;
private Date updated; private Date updated;
private TripState state; private TripState state;

View File

@ -21,7 +21,7 @@ public class TripInfo implements ITripInfo {
private Integer driverRating; private Integer driverRating;
private Integer riderRating; private Integer riderRating;
@OneToOne @OneToOne(targetEntity = Trip.class)
private ITrip trip; private ITrip trip;
@Override @Override

View File

@ -17,11 +17,11 @@ public class Vehicle implements IVehicle {
private String color; private String color;
private String type; private String type;
@OneToMany @OneToMany(targetEntity = Driver.class)
private Collection<IDriver> driver; private Collection<IDriver> driver;
@OneToMany @OneToMany(targetEntity = Match.class)
private Collection<IMatch> match; private Collection<IMatch> match;
@ManyToMany @ManyToMany(mappedBy = "vehicles", targetEntity = Organization.class)
private Collection<IOrganization> organization; private Collection<IOrganization> organization;
@Override @Override