[6a3a178] | 1 | package finki.diplomska.tripplanner.models;
|
---|
| 2 |
|
---|
| 3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
[59329aa] | 4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
[6a3a178] | 5 | import lombok.AllArgsConstructor;
|
---|
| 6 | import lombok.Getter;
|
---|
| 7 | import lombok.NoArgsConstructor;
|
---|
| 8 | import lombok.Setter;
|
---|
| 9 | import net.minidev.json.annotate.JsonIgnore;
|
---|
| 10 |
|
---|
| 11 | import javax.persistence.*;
|
---|
| 12 | import java.util.List;
|
---|
| 13 |
|
---|
| 14 | @Entity
|
---|
| 15 | @Table(name = "locations")
|
---|
| 16 | @AllArgsConstructor
|
---|
| 17 | @Getter
|
---|
| 18 | @Setter
|
---|
| 19 | public class Location {
|
---|
| 20 | @Id
|
---|
| 21 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
| 22 | @Column(name = "id_location")
|
---|
| 23 | private Long id;
|
---|
| 24 |
|
---|
| 25 | @Column(name = "location_name")
|
---|
| 26 | private String name;
|
---|
| 27 |
|
---|
| 28 | @Column(name = "location_description")
|
---|
| 29 | private String description;
|
---|
| 30 |
|
---|
| 31 | private String address;
|
---|
| 32 |
|
---|
| 33 | private String priority;
|
---|
| 34 |
|
---|
| 35 | private int duration;
|
---|
| 36 |
|
---|
[bdd6491] | 37 | private String trivia;
|
---|
| 38 |
|
---|
[6a3a178] | 39 | @Lob
|
---|
| 40 | @JsonIgnore
|
---|
| 41 | private byte[] photo;
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | @ManyToMany
|
---|
| 45 | @JoinTable(
|
---|
| 46 | name = "recommended_companion",
|
---|
| 47 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
| 48 | inverseJoinColumns = @JoinColumn(name = "id_companion"))
|
---|
| 49 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 50 | private List<Companion> companionList;
|
---|
| 51 |
|
---|
| 52 | @ManyToOne
|
---|
| 53 | @JsonBackReference
|
---|
| 54 | @JoinColumn(name = "id_region", nullable = false)
|
---|
| 55 | private Region region;
|
---|
| 56 |
|
---|
| 57 | @ManyToOne
|
---|
| 58 | @JsonBackReference
|
---|
| 59 | @JoinColumn(name = "id_city", nullable = true)
|
---|
| 60 | private City city;
|
---|
| 61 |
|
---|
| 62 | @ManyToMany(mappedBy = "locationList")
|
---|
| 63 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 64 | private List<Planner> plannerList;
|
---|
| 65 |
|
---|
[6fe77af] | 66 | @ManyToOne
|
---|
| 67 | @JsonBackReference
|
---|
| 68 | @JoinColumn(name = "id_user")
|
---|
| 69 | private User user;
|
---|
[6a3a178] | 70 |
|
---|
| 71 | @ManyToMany
|
---|
| 72 | @JoinTable(
|
---|
| 73 | name = "locations_belong",
|
---|
| 74 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
| 75 | inverseJoinColumns = @JoinColumn(name = "id_category"))
|
---|
| 76 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 77 | private List<Category> categoryList;
|
---|
| 78 |
|
---|
[59329aa] | 79 | @OneToMany(mappedBy = "location", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
---|
| 80 | @JsonManagedReference
|
---|
| 81 | private List<Images> imagesList;
|
---|
| 82 |
|
---|
[6fe77af] | 83 | public Location(String name, String description, String address, String priority, int duration, String trivia, byte[] photo, Region region, City city, User user) {
|
---|
| 84 | this.name = name;
|
---|
| 85 | this.description = description;
|
---|
| 86 | this.address = address;
|
---|
| 87 | this.priority = priority;
|
---|
| 88 | this.duration = duration;
|
---|
| 89 | this.trivia = trivia;
|
---|
| 90 | this.photo = photo;
|
---|
| 91 | this.region = region;
|
---|
| 92 | this.city = city;
|
---|
| 93 | this.user = user;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | public Location() {
|
---|
| 97 | }
|
---|
[6a3a178] | 98 | }
|
---|