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

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

pre final presentation

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package finki.diplomska.tripplanner.models;
2
3import com.fasterxml.jackson.annotation.JsonIgnore;
4import lombok.*;
5
6import javax.persistence.*;
7import java.util.List;
8
9@Entity
10@Data
11@Table(name = "planners")
12@AllArgsConstructor
13@Getter
14@Setter
15public class Planner {
16
17 @Id
18 @GeneratedValue(strategy = GenerationType.IDENTITY)
19 @Column(name = "id_planner")
20 private Long id;
21
22 @Column(name = "planner_name")
23 private String name;
24
25 @Column(name = "planner_description")
26 private String description;
27
28 @ManyToMany()
29 @JoinTable(
30 name = "planners_contain",
31 joinColumns = @JoinColumn(name = "id_planner"),
32 inverseJoinColumns = @JoinColumn(name = "id_location"))
33 private List<Location> locationList;
34
35 @ManyToOne(fetch = FetchType.EAGER)
36 private User user;
37
38 public Planner(){
39 }
40
41 public Planner(String name, String description, List<Location> locationList, User user){
42 this.name = name;
43 this.description = description;
44 this.locationList = locationList;
45 this.user = user;
46 }
47
48 public static synchronized Planner createNewPlanner(String plandesc, String planname, List<Location> locationList){
49 Planner planner = new Planner();
50 planner.description = plandesc;
51 planner.name = planname;
52 planner.locationList = locationList;
53 return planner;
54 }
55
56}
Note: See TracBrowser for help on using the repository browser.