Instantiate Collections to ArrayList
This commit is contained in:
parent
fd9b742026
commit
f639e25392
@ -3,7 +3,6 @@ package dst.ass1.jpa.model.impl;
|
|||||||
import dst.ass1.jpa.model.*;
|
import dst.ass1.jpa.model.*;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ public class Driver extends PlatformUser implements IDriver {
|
|||||||
private IVehicle vehicle;
|
private IVehicle vehicle;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Employment.class)
|
@OneToMany(targetEntity = Employment.class)
|
||||||
private Collection<IEmployment> employments;
|
private Collection<IEmployment> employments = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<IEmployment> getEmployments() {
|
public Collection<IEmployment> getEmployments() {
|
||||||
|
|||||||
@ -14,8 +14,11 @@ import static dst.ass1.jpa.util.Constants.T_ORGANIZATION;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Employment implements IEmployment {
|
public class Employment implements IEmployment {
|
||||||
@EmbeddedId @Target(EmploymentKey.class) private IEmploymentKey id;
|
@EmbeddedId @Target(EmploymentKey.class)
|
||||||
|
private IEmploymentKey id;
|
||||||
|
|
||||||
private Date since;
|
private Date since;
|
||||||
|
|
||||||
private Boolean active;
|
private Boolean active;
|
||||||
|
|
||||||
@MapsId(T_ORGANIZATION)
|
@MapsId(T_ORGANIZATION)
|
||||||
|
|||||||
@ -4,16 +4,20 @@ import dst.ass1.jpa.model.ILocation;
|
|||||||
import dst.ass1.jpa.model.ITrip;
|
import dst.ass1.jpa.model.ITrip;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Location implements ILocation {
|
public class Location implements ILocation {
|
||||||
@Id @GeneratedValue private Long id;
|
@Id @GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Long locationId;
|
private Long locationId;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = Trip.class)
|
@ManyToMany(targetEntity = Trip.class)
|
||||||
private Collection<ITrip> trips;
|
private Collection<ITrip> trips = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|||||||
@ -7,9 +7,13 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Match implements IMatch {
|
public class Match implements IMatch {
|
||||||
@Id @GeneratedValue private Long id;
|
@Id @GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private Date date;
|
private Date date;
|
||||||
@Embedded private IMoney fare;
|
|
||||||
|
@Embedded
|
||||||
|
private IMoney fare;
|
||||||
|
|
||||||
@OneToOne(targetEntity = Trip.class)
|
@OneToOne(targetEntity = Trip.class)
|
||||||
private ITrip trip;
|
private ITrip trip;
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import dst.ass1.jpa.model.*;
|
|||||||
* Creates new instances of your model implementations.
|
* Creates new instances of your model implementations.
|
||||||
*/
|
*/
|
||||||
public class ModelFactory implements IModelFactory {
|
public class ModelFactory implements IModelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IModelFactory createModelFactory() {
|
public IModelFactory createModelFactory() {
|
||||||
return new ModelFactory();
|
return new ModelFactory();
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import java.math.BigDecimal;
|
|||||||
@Embeddable
|
@Embeddable
|
||||||
public class Money implements IMoney {
|
public class Money implements IMoney {
|
||||||
private String currency;
|
private String currency;
|
||||||
|
|
||||||
private BigDecimal value;
|
private BigDecimal value;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,13 +5,16 @@ import dst.ass1.jpa.model.IOrganization;
|
|||||||
import dst.ass1.jpa.model.IVehicle;
|
import dst.ass1.jpa.model.IVehicle;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static dst.ass1.jpa.util.Constants.*;
|
import static dst.ass1.jpa.util.Constants.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Organization implements IOrganization {
|
public class Organization implements IOrganization {
|
||||||
@Id @GeneratedValue private Long id;
|
@Id @GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = Organization.class)
|
@ManyToMany(targetEntity = Organization.class)
|
||||||
@ -20,16 +23,16 @@ public class Organization implements IOrganization {
|
|||||||
joinColumns = @JoinColumn(name = I_ORGANIZATION_PART_OF),
|
joinColumns = @JoinColumn(name = I_ORGANIZATION_PART_OF),
|
||||||
inverseJoinColumns = @JoinColumn(name = I_ORGANIZATION_PARTS)
|
inverseJoinColumns = @JoinColumn(name = I_ORGANIZATION_PARTS)
|
||||||
)
|
)
|
||||||
private Collection<IOrganization> parts;
|
private Collection<IOrganization> parts = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(mappedBy = "parts", targetEntity = Organization.class)
|
@ManyToMany(mappedBy = "parts", targetEntity = Organization.class)
|
||||||
private Collection<IOrganization> partOf;
|
private Collection<IOrganization> partOf = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany(targetEntity = Vehicle.class)
|
@ManyToMany(targetEntity = Vehicle.class)
|
||||||
private Collection<IVehicle> vehicles;
|
private Collection<IVehicle> vehicles = new ArrayList<>();
|
||||||
|
|
||||||
@OneToMany(targetEntity = Employment.class)
|
@OneToMany(targetEntity = Employment.class)
|
||||||
private Collection<IEmployment> employments;
|
private Collection<IEmployment> employments = new ArrayList<>();
|
||||||
|
|
||||||
public Organization() {
|
public Organization() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,22 @@ import dst.ass1.jpa.model.IPreferences;
|
|||||||
import dst.ass1.jpa.model.IRider;
|
import dst.ass1.jpa.model.IRider;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static dst.ass1.jpa.util.Constants.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Preferences implements IPreferences {
|
public class Preferences implements IPreferences {
|
||||||
@Id
|
@Id @GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
@ElementCollection
|
|
||||||
private Map<String, String> data;
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@ElementCollection(fetch = FetchType.LAZY)
|
||||||
@MapsId
|
@OrderColumn
|
||||||
|
@JoinTable(name = J_PREFERENCES_DATA)
|
||||||
|
private Map<String, String> data = new HashMap<>();
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = Rider.class, fetch = FetchType.LAZY)
|
||||||
private IRider rider;
|
private IRider rider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import dst.ass1.jpa.model.ITrip;
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
import static dst.ass1.jpa.util.Constants.M_RIDER_ACCOUNT;
|
import static dst.ass1.jpa.util.Constants.M_RIDER_ACCOUNT;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dst.ass1.jpa.model.impl;
|
|||||||
import dst.ass1.jpa.model.*;
|
import dst.ass1.jpa.model.*;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -10,11 +11,19 @@ import static dst.ass1.jpa.util.Constants.*;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Trip implements ITrip {
|
public class Trip implements ITrip {
|
||||||
@Id @GeneratedValue private Long id;
|
@Id @GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private Date created;
|
private Date created;
|
||||||
|
|
||||||
private Date updated;
|
private Date updated;
|
||||||
|
|
||||||
private TripState state;
|
private TripState state;
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = Location.class, optional = false)
|
||||||
private ILocation pickup;
|
private ILocation pickup;
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = Location.class, optional = false)
|
||||||
private ILocation destination;
|
private ILocation destination;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = Location.class)
|
@ManyToMany(targetEntity = Location.class)
|
||||||
@ -23,10 +32,15 @@ public class Trip implements ITrip {
|
|||||||
joinColumns = @JoinColumn(name = I_TRIP),
|
joinColumns = @JoinColumn(name = I_TRIP),
|
||||||
inverseJoinColumns = @JoinColumn(name = I_LOCATION)
|
inverseJoinColumns = @JoinColumn(name = I_LOCATION)
|
||||||
)
|
)
|
||||||
private Collection<ILocation> stops;
|
private Collection<ILocation> stops = new ArrayList<>();
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = TripInfo.class)
|
||||||
private ITripInfo tripInfo;
|
private ITripInfo tripInfo;
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = Match.class)
|
||||||
private IMatch match;
|
private IMatch match;
|
||||||
|
|
||||||
|
@OneToOne(targetEntity = Rider.class)
|
||||||
private IRider rider;
|
private IRider rider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,21 +4,23 @@ import dst.ass1.jpa.model.IMoney;
|
|||||||
import dst.ass1.jpa.model.ITrip;
|
import dst.ass1.jpa.model.ITrip;
|
||||||
import dst.ass1.jpa.model.ITripInfo;
|
import dst.ass1.jpa.model.ITripInfo;
|
||||||
|
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.OneToOne;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class TripInfo implements ITripInfo {
|
public class TripInfo implements ITripInfo {
|
||||||
@Id
|
@Id @GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Date completed;
|
private Date completed;
|
||||||
|
|
||||||
private Double distance;
|
private Double distance;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
private IMoney total;
|
private IMoney total;
|
||||||
|
|
||||||
private Integer driverRating;
|
private Integer driverRating;
|
||||||
|
|
||||||
private Integer riderRating;
|
private Integer riderRating;
|
||||||
|
|
||||||
@OneToOne(targetEntity = Trip.class)
|
@OneToOne(targetEntity = Trip.class)
|
||||||
|
|||||||
@ -10,17 +10,22 @@ import java.util.Collection;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Vehicle implements IVehicle {
|
public class Vehicle implements IVehicle {
|
||||||
@Id
|
@Id @GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(unique = true)
|
@Column(unique = true)
|
||||||
private String license;
|
private String license;
|
||||||
|
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Driver.class)
|
@OneToMany(targetEntity = Driver.class)
|
||||||
private Collection<IDriver> driver;
|
private Collection<IDriver> driver;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Match.class)
|
@OneToMany(targetEntity = Match.class)
|
||||||
private Collection<IMatch> match;
|
private Collection<IMatch> match;
|
||||||
|
|
||||||
@ManyToMany(mappedBy = "vehicles", targetEntity = Organization.class)
|
@ManyToMany(mappedBy = "vehicles", targetEntity = Organization.class)
|
||||||
private Collection<IOrganization> organization;
|
private Collection<IOrganization> organization;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user