View Javadoc
1   package net.sumaris.core.model.data;
2   
3   /*-
4    * #%L
5    * SUMARiS:: Core
6    * %%
7    * Copyright (C) 2018 SUMARiS Consortium
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import lombok.Data;
26  import lombok.experimental.FieldNameConstants;
27  import net.sumaris.core.model.administration.user.Department;
28  import net.sumaris.core.model.administration.user.Person;
29  import net.sumaris.core.model.referential.QualityFlag;
30  
31  import javax.persistence.*;
32  import java.util.Date;
33  import java.util.Objects;
34  
35  @Data
36  @FieldNameConstants
37  @Entity
38  @Table(name="image_attachment")
39  public class ImageAttachment implements IDataEntity<Integer>,
40          IWithRecorderPersonEntity<Integer, Person>,
41          IWithRecorderDepartmentEntity<Integer, Department> {
42  
43      @Id
44      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "IMAGE_ATTACHMENT_SEQ")
45      @SequenceGenerator(name = "IMAGE_ATTACHMENT_SEQ", sequenceName="IMAGE_ATTACHMENT_SEQ")
46      private Integer id;
47  
48      @Column(name = "creation_date", nullable = false)
49      @Temporal(TemporalType.TIMESTAMP)
50      private Date creationDate;
51  
52      @Column(name = "update_date")
53      @Temporal(TemporalType.TIMESTAMP)
54      private Date updateDate;
55  
56      @ManyToOne(fetch = FetchType.LAZY)
57      @JoinColumn(name = "recorder_person_fk")
58      private Person recorderPerson;
59  
60      @ManyToOne(fetch = FetchType.LAZY)
61      @JoinColumn(name = "recorder_department_fk", nullable = false)
62      private Department recorderDepartment;
63  
64      @Column(length = LENGTH_COMMENTS)
65      private String comments;
66  
67      @Column()
68      private String path;
69  
70      @Column(name="control_date")
71      @Temporal(TemporalType.TIMESTAMP)
72      private Date controlDate;
73  
74      @Column(name="validation_date")
75      @Temporal(TemporalType.TIMESTAMP)
76      private Date validationDate;
77  
78      @Column(name="qualification_date")
79      @Temporal(TemporalType.TIMESTAMP)
80      private Date qualificationDate;
81  
82      @Column(name="qualification_comments", length = LENGTH_COMMENTS)
83      private String qualificationComments;
84  
85      @ManyToOne(fetch = FetchType.LAZY, targetEntity = QualityFlag.class)
86      @JoinColumn(name = "quality_flag_fk", nullable = false)
87      private QualityFlag qualityFlag;
88  
89      @Column(name = "date_time")
90      private Date dateTime;
91  
92      @Column(name = "content_type", nullable = false, length = 100)
93      private String contentType;
94  
95      @Lob
96      @Column(length=20971520, nullable = false)
97      private String content;
98  
99      public int hashCode() {
100         return Objects.hash(id);
101     }
102 
103     public boolean equals(Object other) {
104         if (this == other) return true;
105         if ( !(other instanceof ImageAttachment) ) return false;
106 
107         final ImageAttachment./../../net/sumaris/core/model/data/ImageAttachment.html#ImageAttachment">ImageAttachment bean = (ImageAttachment) other;
108 
109         if ( !Objects.equals(bean.getId(), getId() ) ) return false;
110 
111         return true;
112     }
113 }