View Javadoc
1   package net.sumaris.core.model.technical.extraction;
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.data.IWithRecorderDepartmentEntity;
30  import net.sumaris.core.model.data.IWithRecorderPersonEntity;
31  import net.sumaris.core.model.referential.IItemReferentialEntity;
32  import net.sumaris.core.model.referential.Status;
33  import org.hibernate.annotations.Cascade;
34  
35  import javax.persistence.*;
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  @Data
41  @FieldNameConstants
42  @Entity
43  @Cacheable
44  @Table(name = "extraction_product")
45  public class ExtractionProduct implements IItemReferentialEntity,
46          IWithRecorderPersonEntity<Integer, Person>,
47          IWithRecorderDepartmentEntity<Integer, Department> {
48  
49      @Id
50      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EXTRACTION_PRODUCT_SEQ")
51      @SequenceGenerator(name = "EXTRACTION_PRODUCT_SEQ", sequenceName="EXTRACTION_PRODUCT_SEQ")
52      private Integer id;
53  
54      @ManyToOne(fetch = FetchType.LAZY)
55      @JoinColumn(name = "status_fk", nullable = false)
56      private Status status;
57  
58      @Column(name = "creation_date", nullable = false)
59      @Temporal(TemporalType.TIMESTAMP)
60      private Date creationDate;
61  
62      @Column(name = "update_date")
63      @Temporal(TemporalType.TIMESTAMP)
64      private Date updateDate;
65  
66      @Column(nullable = false, length = LENGTH_LABEL)
67      private String label;
68  
69      @Column(nullable = false, length = LENGTH_NAME)
70      private String name;
71  
72      private String description;
73  
74      @Column(length = LENGTH_COMMENTS)
75      private String comments;
76  
77      @Column(name = "is_spatial")
78      private Boolean isSpatial;
79  
80      @ManyToOne(fetch = FetchType.LAZY)
81      @JoinColumn(name = "recorder_person_fk")
82      private Person recorderPerson;
83  
84      @ManyToOne(fetch = FetchType.LAZY)
85      @JoinColumn(name = "recorder_department_fk", nullable = false)
86      private Department recorderDepartment;
87  
88      @ManyToOne(fetch = FetchType.LAZY)
89      @JoinColumn(name = "parent_extraction_product_fk")
90      private ExtractionProduct parent;
91  
92      @OneToMany(fetch = FetchType.EAGER, targetEntity = ExtractionProductStrata.class, mappedBy = ExtractionProductStrata.Fields.PRODUCT)
93      @Cascade(org.hibernate.annotations.CascadeType.DELETE)
94      private List<ExtractionProductStrata> stratum;
95  
96      @OneToMany(fetch = FetchType.LAZY, targetEntity = ExtractionProductTable.class, mappedBy = ExtractionProductTable.Fields.PRODUCT)
97      @Cascade(org.hibernate.annotations.CascadeType.DELETE)
98      private List<ExtractionProductTable> tables = new ArrayList<>();
99  
100 }