1 package fr.ifremer.tutti.persistence.service;
2
3 /*
4 * #%L
5 * Tutti :: Persistence
6 * %%
7 * Copyright (C) 2012 - 2014 Ifremer
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 fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
26 import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
27 import java.util.Map;
28 import org.springframework.transaction.annotation.Transactional;
29
30 @Transactional(readOnly = true)
31 public interface CatchBatchPersistenceService extends TuttiPersistenceServiceImplementor {
32
33 //------------------------------------------------------------------------//
34 //-- CatchBatch methods --//
35 //------------------------------------------------------------------------//
36
37 /**
38 * @param operationId id of the fishing operation
39 * @return {@code true} if there is a catchBatch for the given fishing
40 * operation, {@code false} otherwise.
41 * @since 2.2
42 */
43 boolean isFishingOperationWithCatchBatch(Integer operationId);
44
45 /**
46 * Get the catchBatch from the fishing Operation id.
47 *
48 * @param fishingOperationId id of the fishing operation
49 * @return found catchBatch
50 */
51 CatchBatch getCatchBatchFromFishingOperation(Integer fishingOperationId);
52
53 /**
54 * Create the given CatchBatch and return it.
55 *
56 * @param bean catchBatch to create
57 * @return created catchBatch
58 */
59 @Transactional(readOnly = false)
60 CatchBatch createCatchBatch(CatchBatch bean);
61
62 /**
63 * Save the given catchBatch and return it.
64 *
65 * @param bean batch to save
66 * @return the saved catchBatch
67 */
68 @Transactional(readOnly = false)
69 CatchBatch saveCatchBatch(CatchBatch bean);
70
71 /**
72 * Delete catch batch for the given fishing Operation id (will then delete
73 * in cascade all sorting batchs + individual observation batchs).
74 *
75 * @param fishingOperationId id of the fishing operation
76 * @since 2.2
77 */
78 @Transactional(readOnly = false)
79 void deleteCatchBatch(Integer fishingOperationId);
80
81 /**
82 * Recompute all the sampleRatio and sampleRatioText for the catch batch
83 * and all his children batches for the given fishing operation id.
84 *
85 * @param fishingOperationId id of the fihsing operation
86 * @since 3.5
87 */
88 @Transactional(readOnly = false)
89 void recomputeCatchBatchSampleRatios(Integer fishingOperationId);
90
91 /**
92 * Search batch with same taxon in previous operation in same fishing trip
93 *
94 * @param operationId
95 * @param taxonId
96 * @return map with key: operationName and batchId
97 */
98 Map getPrevOperationNameAndBatchId(int operationId, int taxonId);
99
100 /**
101 * Search batch with same taxon in previous operation in same fishing trip
102 *
103 * @param operationId
104 * @param taxonId
105 * @return map with key: operationName and batchId
106 */
107 Map getNextOperationNameAndBatchId(int operationId, int taxonId);
108 }