View Javadoc
1   package net.sumaris.core.model.administration.user;
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.data.ImageAttachment;
28  import net.sumaris.core.model.referential.IItemReferentialEntity;
29  import net.sumaris.core.model.referential.Status;
30  import net.sumaris.core.model.referential.location.Location;
31  
32  import javax.persistence.*;
33  import java.util.Date;
34  import java.util.Objects;
35  
36  @Data
37  @FieldNameConstants
38  @Entity
39  @Table(name = "department")
40  @Cacheable
41  public class Department implements IItemReferentialEntity {
42  
43      @Id
44      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "DEPARTMENT_SEQ")
45      @SequenceGenerator(name = "DEPARTMENT_SEQ", sequenceName="DEPARTMENT_SEQ")
46      private Integer id;
47  
48      @ManyToOne(fetch = FetchType.LAZY)
49      @JoinColumn(name = "status_fk", nullable = false)
50      private Status status;
51  
52      @Column(name = "creation_date", nullable = false)
53      @Temporal(TemporalType.TIMESTAMP)
54      private Date creationDate;
55  
56      @Column(name = "update_date")
57      @Temporal(TemporalType.TIMESTAMP)
58      private Date updateDate;
59  
60      @Column(nullable = false, length = LENGTH_LABEL)
61      private String label;
62  
63      @Column(nullable = false, length = LENGTH_NAME)
64      private String name;
65  
66      @Column(name = "site_url")
67      private String siteUrl;
68  
69      @ManyToOne(fetch = FetchType.LAZY)
70      @JoinColumn(name = "logo_fk")
71      private ImageAttachment logo;
72  
73      private String description;
74  
75      @Column(length = LENGTH_COMMENTS)
76      private String comments;
77  
78      @ManyToOne(fetch = FetchType.EAGER, targetEntity = Location.class)
79      @JoinColumn(name = "location_fk")
80      private Location location;
81  
82      public String toString() {
83          return label;
84      }
85  
86      public int hashCode() {
87          return Objects.hash(label);
88      }
89  }