View Javadoc
1   package fr.ifremer.tutti.persistence.service.referential;
2   
3   /*
4    * #%L
5    * Tutti :: Persistence
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2014 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.TuttiPersistenceServiceImplementor;
28  import fr.ifremer.tutti.persistence.entities.referential.Gear;
29  import org.springframework.cache.annotation.CacheEvict;
30  import org.springframework.cache.annotation.Cacheable;
31  import org.springframework.transaction.annotation.Transactional;
32  
33  import java.util.Collection;
34  import java.util.List;
35  
36  /**
37   * Created on 11/3/14.
38   *
39   * @author Tony Chemit - chemit@codelutin.com
40   * @since 3.8
41   */
42  @Transactional(readOnly = true)
43  public interface GearPersistenceService extends TuttiPersistenceServiceImplementor {
44  
45      List<Gear> getAllScientificGear();
46  
47      List<Gear> getAllFishingGear();
48  
49      @Cacheable(value = "gearsWithObsoletes")
50      List<Gear> getAllGearWithObsoletes();
51  
52      Gear getGear(Integer gearId);
53  
54      /**
55       * Check if the temporary gear with the given {@code id} is used.
56       *
57       * @param id id of the gear to remove
58       * @return {@code true} if gear is temporary
59       * @since 3.8
60       */
61      boolean isTemporaryGearUsed(Integer id);
62  
63      /**
64       * Add given temporary gears.
65       *
66       * @param gears gears to add
67       * @return added gears
68       * @since 3.14
69       */
70      @Transactional(readOnly = false)
71      @CacheEvict(value = {"gears", "gearsWithObsoletes"}, allEntries = true)
72      List<Gear> addTemporaryGears(List<Gear> gears);
73  
74      /**
75       * Update given temporary gears.
76       *
77       * @param gears gears to update
78       * @return updated gears
79       * @since 3.14
80       */
81      @Transactional(readOnly = false)
82      @CacheEvict(value = {"gears", "gearsWithObsoletes"}, allEntries = true)
83      List<Gear> updateTemporaryGears(List<Gear> gears);
84  
85      /**
86       * Link temporary gears. (Means get existing references using gears natural ids).
87       *
88       * @param gears gears to link
89       * @return linked gears
90       * @since 3.14
91       */
92      List<Gear> linkTemporaryGears(List<Gear> gears);
93  
94      /**
95       * Replace the {@code source} gear by
96       * the {@code target} one in all data.
97       *
98       * @param source the source gear to replace
99       * @param target the target gear to use
100      * @param delete flag to delete the temporary vessel after replacement
101      * @since 3.6
102      */
103     @Transactional(readOnly = false)
104     @CacheEvict(value = {"fr.ifremer.adagio.core.dao.data.batch.CatchBatchCache", "gears", "gearsWithObsoletes"}, allEntries = true)
105     void replaceGear(Gear source, Gear target, boolean delete);
106 
107     /**
108      * Delete the temporary gear with the given {@code id}.
109      *
110      * @param id id of the gear to remove
111      * @since 3.8
112      */
113     @Transactional(readOnly = false)
114     @CacheEvict(value = {"gears", "gearsWithObsoletes"}, allEntries = true)
115     void deleteTemporaryGear(Integer id);
116 
117     /**
118      * Delete the temporary gears with the given {@code idss}.
119      *
120      * @param ids ids of the gears to remove
121      * @since 3.8
122      */
123     @Transactional(readOnly = false)
124     @CacheEvict(value = {"gears", "gearsWithObsoletes"}, allEntries = true)
125     void deleteTemporaryGears(Collection<Integer> ids);
126 
127 }