source: trip-planner/src/main/java/finki/diplomska/tripplanner/models/Location.java

Last change on this file was 6fe77af, checked in by Ema <ema_spirova@…>, 3 years ago

add location feature

  • Property mode set to 100644
File size: 2.6 KB
Line 
1package finki.diplomska.tripplanner.models;
2
3import com.fasterxml.jackson.annotation.JsonBackReference;
4import com.fasterxml.jackson.annotation.JsonManagedReference;
5import lombok.AllArgsConstructor;
6import lombok.Getter;
7import lombok.NoArgsConstructor;
8import lombok.Setter;
9import net.minidev.json.annotate.JsonIgnore;
10
11import javax.persistence.*;
12import java.util.List;
13
14@Entity
15@Table(name = "locations")
16@AllArgsConstructor
17@Getter
18@Setter
19public 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
37 private String trivia;
38
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
66 @ManyToOne
67 @JsonBackReference
68 @JoinColumn(name = "id_user")
69 private User user;
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
79 @OneToMany(mappedBy = "location", cascade = CascadeType.REMOVE, orphanRemoval = true)
80 @JsonManagedReference
81 private List<Images> imagesList;
82
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 }
98}
Note: See TracBrowser for help on using the repository browser.