source: Git/src/main/java/com/wediscussmovies/project/model/Person.java@ c02189f

main
Last change on this file since c02189f was c02189f, checked in by Petar Partaloski <ppartaloski@…>, 2 years ago

Added new core functionalities, fixed bugs and improved visual clarity

  • Property mode set to 100644
File size: 2.3 KB
Line 
1package com.wediscussmovies.project.model;
2
3import com.wediscussmovies.project.model.relation.MovieActors;
4import com.wediscussmovies.project.model.relation.PersonRates;
5import lombok.Data;
6
7import javax.persistence.*;
8import javax.swing.text.DateFormatter;
9import java.sql.Date;
10import java.time.LocalDate;
11import java.time.format.DateTimeFormatter;
12import java.util.Collection;
13
14@Entity
15@Table(name = "persons", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
16@Data
17public class Person {
18
19 /*
20 ni fale tabela za person koj zanrovi gi ima - ako e potrebno
21 */
22
23 @GeneratedValue(strategy = GenerationType.IDENTITY)
24 @Id
25 @Column(name = "person_id")
26 private int personId;
27 @Basic
28 @Column(name = "name")
29 private String name;
30 @Basic
31 @Column(name = "surname")
32 private String surname;
33 @Basic
34 @Column(name = "type")
35 private Character type;
36 @Basic
37 @Column(name = "date_of_birth")
38 private Date dateOfBirth;
39 @Basic
40 @Column(name = "image_url")
41 private String imageUrl;
42 @Basic
43 @Column(name = "description")
44 private String description;
45 @OneToMany(mappedBy = "person")
46 private Collection<Discussion> discussions;
47 @OneToMany(mappedBy = "person")
48 private Collection<MovieActors> movieActors;
49 @OneToMany(mappedBy = "director")
50 private Collection<Movie> movies;
51 @OneToMany(mappedBy = "person")
52 private Collection<PersonRates> personRates;
53
54
55
56 public Person() {
57
58 }
59
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) return true;
64 if (o == null || getClass() != o.getClass()) return false;
65
66 Person that = (Person) o;
67
68 return personId == that.getPersonId();
69 }
70
71 @Override
72 public int hashCode() {
73
74 return personId * 31;
75 }
76
77
78 public String getDateFormatted(){
79 String dob = dateOfBirth.toString();
80 String [] parts = dob.split("-");
81 return parts[2]+"/"+parts[1]+"/"+parts[0];
82 }
83
84
85 public Person(String name, String surname, Character type, Date dateOfBirth, String imageUrl, String description) {
86 this.name = name;
87 this.surname = surname;
88 this.type = type;
89 this.dateOfBirth = dateOfBirth;
90 this.imageUrl = imageUrl;
91 this.description = description;
92 }
93
94}
Note: See TracBrowser for help on using the repository browser.