1 package net.sumaris.core.model.data;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import lombok.Data;
26 import lombok.ToString;
27 import lombok.experimental.FieldNameConstants;
28 import net.sumaris.core.model.administration.programStrategy.Program;
29 import net.sumaris.core.model.administration.user.Department;
30 import net.sumaris.core.model.administration.user.Person;
31 import net.sumaris.core.model.referential.QualityFlag;
32 import net.sumaris.core.model.referential.Status;
33 import net.sumaris.core.model.referential.VesselType;
34 import org.hibernate.annotations.Cascade;
35
36 import javax.persistence.*;
37 import java.util.ArrayList;
38 import java.util.Date;
39 import java.util.List;
40
41 @Data
42 @FieldNameConstants
43 @Entity
44 @Table(name = "vessel")
45
46
47
48 public class Vessel implements IRootDataEntity<Integer> {
49
50 @Id
51 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "VESSEL_SEQ")
52 @SequenceGenerator(name = "VESSEL_SEQ", sequenceName="VESSEL_SEQ")
53 private Integer id;
54
55 @Column(name = "creation_date", nullable = false)
56 @Temporal(TemporalType.TIMESTAMP)
57 private Date creationDate;
58
59 @Column(name = "update_date")
60 @Temporal(TemporalType.TIMESTAMP)
61 private Date updateDate;
62
63 @ManyToOne(fetch = FetchType.LAZY)
64 @JoinColumn(name = "recorder_person_fk")
65 private Person recorderPerson;
66
67 @ManyToOne(fetch = FetchType.LAZY)
68 @JoinColumn(name = "recorder_department_fk", nullable = false)
69 private Department recorderDepartment;
70
71 @Column(length = LENGTH_COMMENTS)
72 private String comments;
73
74 @Column(name="control_date")
75 @Temporal(TemporalType.TIMESTAMP)
76 private Date controlDate;
77
78 @Column(name="validation_date")
79 @Temporal(TemporalType.TIMESTAMP)
80 private Date validationDate;
81
82 @Column(name="qualification_date")
83 @Temporal(TemporalType.TIMESTAMP)
84 private Date qualificationDate;
85
86 @Column(name="qualification_comments", length = LENGTH_COMMENTS)
87 private String qualificationComments;
88
89 @ManyToOne(fetch = FetchType.LAZY, targetEntity = QualityFlag.class)
90 @JoinColumn(name = "quality_flag_fk", nullable = false)
91 private QualityFlag qualityFlag;
92
93 @ManyToOne(fetch = FetchType.LAZY, targetEntity = VesselType.class)
94 @JoinColumn(name="vessel_type_fk", nullable = false)
95 private VesselType vesselType;
96
97 @ManyToOne(fetch = FetchType.LAZY)
98 @JoinColumn(name = "status_fk", nullable = false)
99 private Status status;
100
101 @ManyToOne(fetch = FetchType.LAZY, targetEntity = Program.class)
102 @JoinColumn(name = "program_fk", nullable = false)
103 private Program program;
104
105 @OneToMany(fetch = FetchType.LAZY, targetEntity = VesselFeatures.class, mappedBy = VesselFeatures.Fields.VESSEL)
106 @Cascade(org.hibernate.annotations.CascadeType.DELETE)
107 @ToString.Exclude
108 private List<VesselFeatures> vesselFeatures = new ArrayList<>();
109
110 @OneToMany(fetch = FetchType.LAZY, targetEntity = VesselRegistrationPeriod.class, mappedBy = VesselRegistrationPeriod.Fields.VESSEL)
111 @Cascade(org.hibernate.annotations.CascadeType.DELETE)
112 @ToString.Exclude
113 private List<VesselRegistrationPeriod> vesselRegistrationPeriods = new ArrayList<>();
114
115 @OneToMany(fetch = FetchType.LAZY, targetEntity = VesselOwnerPeriod.class, mappedBy = VesselOwnerPeriod.Fields.VESSEL)
116 @Cascade(org.hibernate.annotations.CascadeType.DELETE)
117 @ToString.Exclude
118 private List<VesselOwnerPeriod> vesselOwnerPeriods = new ArrayList<>();
119
120 }