View Javadoc
1   package net.sumaris.core.model.administration.programStrategy;
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 com.google.common.collect.Sets;
26  import lombok.Data;
27  import lombok.experimental.FieldNameConstants;
28  import net.sumaris.core.dao.technical.model.IEntity;
29  import net.sumaris.core.model.referential.gear.Gear;
30  import net.sumaris.core.model.referential.pmfm.Pmfm;
31  import net.sumaris.core.model.referential.taxon.ReferenceTaxon;
32  import net.sumaris.core.model.referential.taxon.TaxonGroup;
33  
34  import javax.persistence.*;
35  import java.util.Set;
36  
37  @Data
38  @FieldNameConstants
39  @Entity
40  @Table(name = "pmfm_strategy")
41  public class PmfmStrategy implements IEntity<Integer> {
42  
43      @Id
44      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "PMFM_STRATEGY_SEQ")
45      @SequenceGenerator(name = "PMFM_STRATEGY_SEQ", sequenceName="PMFM_STRATEGY_SEQ")
46      private Integer id;
47  
48      @Column(name = "acquisition_number", nullable = false)
49      private Integer acquisitionNumber;
50  
51      @Column(name = "is_mandatory", nullable = false)
52      private Boolean isMandatory;
53  
54      @Column(name = "min_value")
55      private Double minValue;
56  
57      @Column(name = "max_value")
58      private Double maxValue;
59  
60      @Column(name = "default_value")
61      private Double defaultValue;
62  
63      @ManyToOne(fetch = FetchType.LAZY)
64      @JoinColumn(name = "pmfm_fk", nullable = false)
65      private Pmfm pmfm;
66  
67      @Column(name = "rank_order", nullable = false)
68      private Integer rankOrder;
69  
70      @ManyToOne(fetch = FetchType.LAZY)
71      @JoinColumn(name = "strategy_fk", nullable = false)
72      private Strategy strategy;
73  
74      @ManyToOne(fetch = FetchType.LAZY)
75      @JoinColumn(name = "acquisition_level_fk", nullable = false)
76      private AcquisitionLevel acquisitionLevel;
77  
78      @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
79      @JoinTable(name = "pmfm_strategy2gear", joinColumns = {
80              @JoinColumn(name = "pmfm_strategy_fk", nullable = false, updatable = false) },
81              inverseJoinColumns = {
82                      @JoinColumn(name = "gear_fk", nullable = false, updatable = false) })
83      private Set<Gear> gears = Sets.newHashSet();
84  
85      @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
86      @JoinTable(name = "pmfm_strategy2taxon_group", joinColumns = {
87              @JoinColumn(name = "pmfm_strategy_fk", nullable = false, updatable = false) },
88              inverseJoinColumns = {
89                      @JoinColumn(name = "taxon_group_fk", nullable = false, updatable = false) })
90      private Set<TaxonGroup> taxonGroups = Sets.newHashSet();
91  
92      @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
93      @JoinTable(name = "pmfm_strategy2reference_taxon", joinColumns = {
94              @JoinColumn(name = "pmfm_strategy_fk", nullable = false, updatable = false) },
95              inverseJoinColumns = {
96                      @JoinColumn(name = "reference_taxon_fk", nullable = false, updatable = false) })
97      private Set<ReferenceTaxon> referenceTaxons = Sets.newHashSet();
98  }