View Javadoc
1   package net.sumaris.core.dao.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 net.sumaris.core.dao.cache.CacheNames;
26  import net.sumaris.core.dao.technical.SortDirection;
27  import net.sumaris.core.model.administration.programStrategy.Program;
28  import net.sumaris.core.vo.administration.programStrategy.ProgramFetchOptions;
29  import net.sumaris.core.vo.administration.programStrategy.ProgramVO;
30  import net.sumaris.core.vo.administration.user.PersonVO;
31  import net.sumaris.core.vo.filter.ProgramFilterVO;
32  import net.sumaris.core.vo.referential.ReferentialVO;
33  import net.sumaris.core.vo.referential.TaxonGroupVO;
34  import org.springframework.cache.annotation.CacheEvict;
35  import org.springframework.cache.annotation.CachePut;
36  import org.springframework.cache.annotation.Cacheable;
37  import org.springframework.cache.annotation.Caching;
38  import org.springframework.transaction.annotation.Transactional;
39  
40  import java.util.List;
41  
42  public interface ProgramDao {
43  
44      List<ProgramVO> getAll();
45  
46      List<ProgramVO> findByFilter(ProgramFilterVO filter, int offset, int size, String sortAttribute, SortDirection sortDirection);
47  
48      @Cacheable(cacheNames = CacheNames.PROGRAM_BY_ID)
49      ProgramVO get(int id);
50  
51      @Cacheable(cacheNames = CacheNames.PROGRAM_BY_LABEL)
52      ProgramVO getByLabel(String label);
53  
54      ProgramVO toProgramVO(Program source);
55  
56      ProgramVO toProgramVO(Program source, ProgramFetchOptions fetchOptions);
57  
58      @Caching(
59              evict = {
60                      @CacheEvict(cacheNames = CacheNames.PROGRAM_BY_ID, key = "#source.id", condition = "#source.id != null"),
61                      @CacheEvict(cacheNames = CacheNames.PROGRAM_BY_LABEL, key = "#source.label", condition = "#source.id != null"),
62              },
63              put = {
64                      @CachePut(cacheNames= CacheNames.PROGRAM_BY_ID, key="#source.id", condition = " #source.id != null"),
65                      @CachePut(cacheNames= CacheNames.PROGRAM_BY_LABEL, key="#source.label", condition = "#source.id != null")
66              }
67      )
68      ProgramVO="../../../../../../net/sumaris/core/vo/administration/programStrategy/ProgramVO.html#ProgramVO">ProgramVO save(ProgramVO source);
69  
70      @Caching(
71              evict = {
72                      @CacheEvict(cacheNames = CacheNames.PROGRAM_BY_LABEL, key = "#id", condition = "#source.id != null"),
73                      @CacheEvict(cacheNames = CacheNames.PROGRAM_BY_ID, allEntries = true)
74              }
75      )
76      void delete(int id);
77  
78      List<TaxonGroupVO> getTaxonGroups(int programId);
79  
80      List<ReferentialVO> getGears(int programId);
81  }