1 package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import com.google.common.collect.ImmutableMap;
28 import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
29 import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
30 import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
31 import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
32 import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
33 import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
34 import fr.ifremer.tutti.persistence.entities.referential.Species;
35 import fr.ifremer.tutti.service.catches.multipost.MultiPostImportResult;
36 import fr.ifremer.tutti.type.WeightUnit;
37 import fr.ifremer.tutti.ui.swing.TuttiUIContext;
38 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
39 import fr.ifremer.tutti.ui.swing.util.computable.ComputableData;
40
41 import java.io.File;
42 import java.util.Collections;
43 import java.util.List;
44 import java.util.Map;
45
46 import static org.nuiton.i18n.I18n.n;
47
48
49
50
51
52
53 public class BenthosBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport {
54
55 protected static final Map<String, String> CATCHES_UI_MODEL_PROPERTIES_MAPPING =
56 ImmutableMap.<String, String>builder()
57 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, PROPERTY_TOTAL_COMPUTED_WEIGHT)
58 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, PROPERTY_TOTAL_SORTED_WEIGHT)
59 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, PROPERTY_TOTAL_UNSORTED_COMPUTED_WEIGHT)
60 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, PROPERTY_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT)
61 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, PROPERTY_TOTAL_INERT_WEIGHT)
62 .put(EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, PROPERTY_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT)
63 .build();
64
65 public BenthosBatchUISupportImpl(TuttiUIContext context, EditCatchesUIModel catchesUIModel, WeightUnit weightUnit) {
66 super(context, catchesUIModel, CATCHES_UI_MODEL_PROPERTIES_MAPPING, weightUnit);
67 }
68
69 @Override
70 public BatchContainer<SpeciesBatch> getRootSpeciesBatch(Integer batchId) {
71 return getPersistenceService().getRootBenthosBatch(batchId, true);
72 }
73
74 @Override
75 public String getTitle() {
76 return n("tutti.label.tab.benthos");
77 }
78
79 @Override
80 public boolean canPupitriImport() {
81 return false;
82 }
83
84 @Override
85 public boolean canPsionImport() {
86 return false;
87 }
88
89 @Override
90 public boolean canBigfinImport() {
91 return false;
92 }
93
94 @Override
95 public Float getTotalComputedWeight() {
96 return catchesUIModel.getBenthosTotalComputedWeight();
97 }
98
99 @Override
100 public void setTotalComputedWeight(Float totalComputedWeight) {
101 catchesUIModel.setBenthosTotalComputedWeight(totalComputedWeight);
102 }
103
104 @Override
105 public ComputableData<Float> getTotalSortedComputedOrNotWeight() {
106 return catchesUIModel.getBenthosTotalSortedComputedOrNotWeight();
107 }
108
109 @Override
110 public Float getTotalSortedWeight() {
111 return catchesUIModel.getBenthosTotalSortedWeight();
112 }
113
114 @Override
115 public void setTotalSortedWeight(Float totalSortedWeight) {
116 catchesUIModel.setBenthosTotalSortedWeight(totalSortedWeight);
117 }
118
119 @Override
120 public Float getTotalSortedComputedWeight() {
121 return catchesUIModel.getBenthosTotalSortedComputedWeight();
122 }
123
124 @Override
125 public void setTotalSortedComputedWeight(Float totalSortedComputedWeight) {
126 catchesUIModel.setBenthosTotalSortedComputedWeight(totalSortedComputedWeight);
127 }
128
129 @Override
130 public Float getTotalUnsortedComputedWeight() {
131 return catchesUIModel.getBenthosTotalUnsortedComputedWeight();
132 }
133
134 @Override
135 public void setTotalUnsortedComputedWeight(Float totalUnsortedComputedWeight) {
136 catchesUIModel.setBenthosTotalUnsortedComputedWeight(totalUnsortedComputedWeight);
137 }
138
139 @Override
140 public Float getTotalSampleSortedComputedWeight() {
141 return catchesUIModel.getBenthosTotalSampleSortedComputedWeight();
142 }
143
144 @Override
145 public void setTotalSampleSortedComputedWeight(Float totalSampleSortedComputedWeight) {
146 catchesUIModel.setBenthosTotalSampleSortedComputedWeight(totalSampleSortedComputedWeight);
147 }
148
149 @Override
150 public ComputableData<Float> getTotalInertComputedOrNotWeight() {
151 return catchesUIModel.getBenthosTotalInertComputedOrNotWeight();
152 }
153
154 @Override
155 public Float getTotalInertWeight() {
156 return catchesUIModel.getBenthosTotalInertWeight();
157 }
158
159 @Override
160 public void setTotalInertWeight(Float totalInertWeight) {
161 catchesUIModel.setBenthosTotalInertWeight(totalInertWeight);
162 }
163
164 @Override
165 public Float getTotalInertComputedWeight() {
166 return catchesUIModel.getBenthosTotalInertComputedWeight();
167 }
168
169 @Override
170 public void setTotalInertComputedWeight(Float totalInertComputedWeight) {
171 catchesUIModel.setBenthosTotalInertComputedWeight(totalInertComputedWeight);
172 }
173
174 @Override
175 public ComputableData<Float> getTotalLivingNotItemizedComputedOrNotWeight() {
176 return catchesUIModel.getBenthosTotalLivingNotItemizedComputedOrNotWeight();
177 }
178
179 @Override
180 public Float getTotalLivingNotItemizedWeight() {
181 return catchesUIModel.getBenthosTotalLivingNotItemizedWeight();
182 }
183
184 @Override
185 public void setTotalLivingNotItemizedWeight(Float totalLivingNotItemizedWeight) {
186 catchesUIModel.setBenthosTotalLivingNotItemizedWeight(totalLivingNotItemizedWeight);
187 }
188
189 @Override
190 public Float getTotalLivingNotItemizedComputedWeight() {
191 return catchesUIModel.getBenthosTotalLivingNotItemizedComputedWeight();
192 }
193
194 @Override
195 public void setTotalLivingNotItemizedComputedWeight(Float totalLivingNotItemizedComputedWeight) {
196 catchesUIModel.setBenthosTotalLivingNotItemizedComputedWeight(totalLivingNotItemizedComputedWeight);
197 }
198
199 @Override
200 public Integer getDistinctSortedSpeciesCount() {
201 return catchesUIModel.getBenthosDistinctSortedSpeciesCount();
202 }
203
204 @Override
205 public void setDistinctSortedSpeciesCount(Integer distinctSortedSpeciesCount) {
206 catchesUIModel.setBenthosDistinctSortedSpeciesCount(distinctSortedSpeciesCount);
207 }
208
209 @Override
210 public Integer getDistinctUnsortedSpeciesCount() {
211 return catchesUIModel.getBenthosDistinctUnsortedSpeciesCount();
212 }
213
214 @Override
215 public void setDistinctUnsortedSpeciesCount(Integer distinctUnsortedSpeciesCount) {
216 catchesUIModel.setBenthosDistinctUnsortedSpeciesCount(distinctUnsortedSpeciesCount);
217 }
218
219 @Override
220 public Map<String, Object> importMultiPost(File file, FishingOperation operation, boolean importFrequencies, boolean importIndivudalObservations) {
221 return context.getMultiPostImportService().importBenthos(file, operation, importFrequencies, importIndivudalObservations);
222 }
223
224 @Override
225 public MultiPostImportResult importMultiPost(File file, FishingOperation operation, SpeciesBatch speciesBatch, boolean importFrequencies, boolean importIndivudalObservations) {
226 return context.getMultiPostImportService().importBenthosBatch(file, operation, speciesBatch, importFrequencies, importIndivudalObservations);
227 }
228
229 @Override
230 public void exportMultiPost(File file, FishingOperation operation, boolean importFrequencies, boolean importIndivudalObservations) {
231 context.getMultiPostExportService().exportBenthos(file, operation, importFrequencies, importIndivudalObservations);
232 }
233
234 @Override
235 public void exportMultiPost(File file, FishingOperation operation, SpeciesBatch speciesBatch, boolean importFrequencies, boolean importIndivudalObservations) {
236 context.getMultiPostExportService().exportBatch(file, operation, speciesBatch, importFrequencies, importIndivudalObservations);
237 }
238
239 @Override
240 public SpeciesBatch createBatch(SpeciesBatch speciesBatch, Integer parentBatchId) {
241 return getPersistenceService().createBenthosBatch(speciesBatch, parentBatchId, true);
242 }
243
244 @Override
245 public SpeciesBatch saveBatch(SpeciesBatch speciesBatch) {
246 return getPersistenceService().saveBenthosBatch(speciesBatch);
247 }
248
249 @Override
250 public List<SpeciesBatchFrequency> saveBatchFrequencies(Integer speciesBatchId, List<SpeciesBatchFrequency> frequency) {
251 return getPersistenceService().saveBenthosBatchFrequency(speciesBatchId, frequency);
252 }
253
254 @Override
255 public List<Species> getReferentSpeciesWithSurveyCode(boolean restrictToProtocol) {
256 return context.getDataContext().getReferentBenthosWithSurveyCode(restrictToProtocol);
257 }
258
259 @Override
260 public List<Species> getReferentOtherSpeciesWithSurveyCode(boolean restrictToProtocol) {
261 return context.getDataContext().getReferentSpeciesWithSurveyCode(restrictToProtocol);
262 }
263
264 @Override
265 public List<SpeciesProtocol> getSpeciesFromProtocol() {
266 List<SpeciesProtocol> result;
267 TuttiProtocol p = context.getDataContext().getProtocol();
268 if (p != null) {
269 result = p.getBenthos();
270 } else {
271 result = Collections.EMPTY_LIST;
272 }
273 return result;
274 }
275
276 @Override
277 public void deleteSpeciesSubBatch(Integer speciesBatchId) {
278 getPersistenceService().deleteBenthosSubBatch(speciesBatchId);
279 }
280
281 @Override
282 public void deleteSpeciesBatch(Integer speciesBatchId) {
283 getPersistenceService().deleteBenthosBatch(speciesBatchId);
284 }
285
286 }