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.programStrategy.Program;
28  import net.sumaris.core.model.administration.user.Department;
29  import net.sumaris.core.model.administration.user.Person;
30  import net.sumaris.core.model.referential.QualityFlag;
31  import net.sumaris.core.model.referential.SaleType;
32  import net.sumaris.core.model.referential.pmfm.Matrix;
33  import net.sumaris.core.model.referential.taxon.TaxonGroup;
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 = "product")
45  public class Product implements IRootDataEntity<Integer> {
46  
47      @Id
48      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PRODUCT_SEQ")
49      @SequenceGenerator(name = "PRODUCT_SEQ", sequenceName="PRODUCT_SEQ")
50      private Integer id;
51  
52      @Column(length = 40, nullable = false)
53      private String label;
54  
55      @Column(name = "rank_order", nullable = false)
56      private Integer rankOrder;
57  
58      @Column(name = "individual_count")
59      private Integer individualCount;
60  
61      @ManyToOne(fetch = FetchType.LAZY)
62      @JoinColumn(name = "taxon_group_fk")
63      private TaxonGroup taxonGroup;
64  
65      @ManyToOne(fetch = FetchType.LAZY)
66      @JoinColumn(name = "matrix_fk", nullable = false)
67      private Matrix matrix;
68  
69      @Column(length = LENGTH_COMMENTS)
70      private String comments;
71  
72      /* -- Quality insurance -- */
73  
74      @Column(name = "creation_date", nullable = false)
75      @Temporal(TemporalType.TIMESTAMP)
76      private Date creationDate;
77  
78      @Column(name = "update_date")
79      @Temporal(TemporalType.TIMESTAMP)
80      private Date updateDate;
81  
82      @ManyToOne(fetch = FetchType.LAZY)
83      @JoinColumn(name = "recorder_department_fk", nullable = false)
84      private Department recorderDepartment;
85  
86      @ManyToOne(fetch = FetchType.LAZY)
87      @JoinColumn(name = "recorder_person_fk")
88      private Person recorderPerson;
89  
90      @Column(name="control_date")
91      @Temporal(TemporalType.TIMESTAMP)
92      private Date controlDate;
93  
94      @Column(name="validation_date")
95      @Temporal(TemporalType.TIMESTAMP)
96      private Date validationDate;
97  
98      @Column(name="qualification_date")
99      @Temporal(TemporalType.TIMESTAMP)
100     private Date qualificationDate;
101 
102     @Column(name="qualification_comments", length = LENGTH_COMMENTS)
103     private String qualificationComments;
104 
105     @ManyToOne(fetch = FetchType.LAZY, targetEntity = QualityFlag.class)
106     @JoinColumn(name = "quality_flag_fk", nullable = false)
107     private QualityFlag qualityFlag;
108 
109     @ManyToOne(fetch = FetchType.LAZY, targetEntity = Program.class)
110     @JoinColumn(name = "program_fk", nullable = false)
111     private Program program;
112 
113     @ManyToOne(fetch = FetchType.LAZY, targetEntity = SaleType.class)
114     @JoinColumn(name = "sale_type_fk")
115     private SaleType saleType;
116 
117     /* -- measurements -- */
118 
119     @OneToMany(fetch = FetchType.LAZY, targetEntity = ProductSortingMeasurement.class, mappedBy = ProductSortingMeasurement.Fields.PRODUCT)
120     @Cascade(org.hibernate.annotations.CascadeType.DELETE)
121     private List<ProductSortingMeasurement> sortingMeasurements = new ArrayList<>();
122 
123     @OneToMany(fetch = FetchType.LAZY, targetEntity = ProductQuantificationMeasurement.class, mappedBy = ProductQuantificationMeasurement.Fields.PRODUCT)
124     @Cascade(org.hibernate.annotations.CascadeType.DELETE)
125     private List<ProductQuantificationMeasurement> quantificationMeasurements = new ArrayList<>();
126 
127     /* -- Parent link -- */
128 
129     @ManyToOne(fetch = FetchType.LAZY)
130     @JoinColumn(name = "operation_fk", nullable = false)
131     private Operation operation;
132 
133     @ManyToOne(fetch = FetchType.LAZY)
134     @JoinColumn(name = "sale_fk")
135     private Sale sale;
136 
137     @ManyToOne(fetch = FetchType.LAZY)
138     @JoinColumn(name = "landing_fk")
139     private Landing landing;
140 
141     @ManyToOne(fetch = FetchType.LAZY)
142     @JoinColumn(name = "batch_fk")
143     private Batch batch;
144 }