View Javadoc
1   package fr.ifremer.tutti.service.sampling;
2   
3   /*
4    * #%L
5    * Tutti :: Service
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2016 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import fr.ifremer.tutti.persistence.entities.protocol.CalcifiedPiecesSamplingDefinition;
28  import fr.ifremer.tutti.persistence.entities.protocol.Zone;
29  import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
30  import fr.ifremer.tutti.persistence.entities.referential.Species;
31  
32  import java.util.Objects;
33  
34  /**
35   * Définit le context d'une observation individuelles ou d'un prélèvement, i.e toutes les caractéristiques qui
36   * permettent de retrouver cette observation individuelle au niveau de l'algorithme de prélèvement.
37   *
38   * L'utilisation de cet objet sous-entend que l'observation individuelle liée rentre bien dans l'algorithme.
39   *
40   * Created on 18/04/16.
41   *
42   * @author Tony Chemit - chemit@codelutin.com
43   */
44  public class IndividualObservationSamplingContext {
45  
46      /**
47       * L'espèce de l'observation individuelle.
48       */
49      private final Species species;
50  
51      /**
52       * La classe de taille de l'observation individuelle.
53       */
54      private final Integer lengthStep;
55  
56      /**
57       * Le statut de maturité.
58       */
59      private final Boolean maturity;
60  
61      /**
62       * Le sexe observé.
63       */
64      private final CaracteristicQualitativeValue gender;
65  
66      /**
67       * La définition de l'algorithme de prélèvement de picèes calcifiées utilisée pour cette observation.
68       */
69      private final CalcifiedPiecesSamplingDefinition calcifiedPiecesSamplingDefinition;
70  
71      /**
72       * La zone où est effectuée l'observation individuelle.
73       */
74      private final Zone zone;
75  
76      /**
77       * La clef pour accéder au cache des compteurs (de niveau Campagne).
78       */
79      private final String cruiseSamplingKey;
80  
81      /**
82       * La clef pour accéder au cache des compteurs (de niveau Zone).
83       */
84      private final String zoneSamplingKey;
85  
86      /**
87       * La clef pour accéder au cache des compteurs (de niveau Opération de pêche).
88       */
89      private final String fishingOperationSamplingKey;
90  
91      public IndividualObservationSamplingContext(Species species,
92                                                  Integer lengthStep,
93                                                  Boolean maturity,
94                                                  CaracteristicQualitativeValue gender,
95                                                  CalcifiedPiecesSamplingDefinition calcifiedPiecesSamplingDefinition,
96                                                  Zone zone,
97                                                  String cruiseSamplingKey,
98                                                  String zoneSamplingKey,
99                                                  String fishingOperationSamplingKey) {
100         Objects.requireNonNull(species);
101         Objects.requireNonNull(calcifiedPiecesSamplingDefinition);
102         Objects.requireNonNull(zone);
103         Objects.requireNonNull(cruiseSamplingKey);
104         Objects.requireNonNull(zoneSamplingKey);
105         Objects.requireNonNull(fishingOperationSamplingKey);
106         this.species = species;
107         this.lengthStep = lengthStep;
108         this.maturity = maturity;
109         this.gender = gender;
110         this.calcifiedPiecesSamplingDefinition = calcifiedPiecesSamplingDefinition;
111         this.zone = zone;
112         this.cruiseSamplingKey = cruiseSamplingKey;
113         this.zoneSamplingKey = zoneSamplingKey;
114         this.fishingOperationSamplingKey = fishingOperationSamplingKey;
115     }
116 
117     public Species getSpecies() {
118         return species;
119     }
120 
121     public Integer getLengthStep() {
122         return lengthStep;
123     }
124 
125     public Boolean getMaturity() {
126         return maturity;
127     }
128 
129     public CaracteristicQualitativeValue getGender() {
130         return gender;
131     }
132 
133     public CalcifiedPiecesSamplingDefinition getCalcifiedPiecesSamplingDefinition() {
134         return calcifiedPiecesSamplingDefinition;
135     }
136 
137     public Zone getZone() {
138         return zone;
139     }
140 
141     public int getTotalSamplingRequiredInCruise() {
142         return calcifiedPiecesSamplingDefinition.getMaxByLenghtStep();
143     }
144 
145     public int getTotalSamplingRequiredInFishingOperation() {
146         return calcifiedPiecesSamplingDefinition.getOperationLimitation();
147     }
148 
149     public int getTotalSamplingRequiredInZone() {
150         return calcifiedPiecesSamplingDefinition.getZoneLimitation();
151     }
152 
153     public String getCruiseSamplingKey() {
154         return cruiseSamplingKey;
155     }
156 
157     public String getZoneSamplingKey() {
158         return zoneSamplingKey;
159     }
160 
161     public String getFishingOperationSamplingKey() {
162         return fishingOperationSamplingKey;
163     }
164 
165     public boolean withGender() {
166         return gender!=null;
167     }
168 
169     public boolean withMaturity() {
170         return maturity!=null;
171     }
172 }