1 package net.sumaris.core.dao.technical.extraction;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import net.sumaris.core.dao.cache.CacheNames;
26 import net.sumaris.core.vo.technical.extraction.ExtractionProductColumnVO;
27 import net.sumaris.core.vo.technical.extraction.ExtractionProductFilterVO;
28 import net.sumaris.core.vo.technical.extraction.ExtractionProductVO;
29 import net.sumaris.core.vo.technical.extraction.ProductFetchOptions;
30 import org.springframework.cache.annotation.CacheEvict;
31 import org.springframework.cache.annotation.CachePut;
32 import org.springframework.cache.annotation.Cacheable;
33 import org.springframework.cache.annotation.Caching;
34
35 import java.util.List;
36 import java.util.Optional;
37
38
39
40
41 public interface ExtractionProductDao {
42
43
44 @Cacheable(cacheNames = CacheNames.PRODUCTS_BY_FILTER)
45 List<ExtractionProductVO> findByFilter(ExtractionProductFilterVO filter, ProductFetchOptions fetchOptions);
46
47 default List<ExtractionProductVO> findByFilter() {
48 return findByFilter(null, null);
49 }
50
51 @Cacheable(cacheNames = CacheNames.PRODUCT_BY_LABEL, key = "#label")
52 ExtractionProductVO getByLabel(String label, ProductFetchOptions fetchOptions);
53
54 default ExtractionProductVO getByLabel(String label) {
55 return getByLabel(label, null);
56 }
57
58
59 Optional<ExtractionProductVO> get(int id, ProductFetchOptions fetchOptions);
60
61 default Optional<ExtractionProductVO> get(int id) {
62 return get(id, null);
63 }
64
65 List<ExtractionProductColumnVO> getColumnsByIdAndTableLabel(int id, String tableLabel);
66
67 @Caching(
68 evict = {
69 @CacheEvict(cacheNames = CacheNames.PRODUCT_BY_LABEL, key = "#source.label", condition = "#source != null && #source.id != null"),
70 @CacheEvict(cacheNames = CacheNames.PRODUCTS, allEntries = true),
71 @CacheEvict(cacheNames = CacheNames.PRODUCTS_BY_FILTER, allEntries = true),
72 },
73 put = {
74 @CachePut(cacheNames= CacheNames.PRODUCT_BY_LABEL, key="#source.label", condition = "#source != null && #source.label != null")
75 }
76 )
77 ExtractionProductVO/../../../net/sumaris/core/vo/technical/extraction/ExtractionProductVO.html#ExtractionProductVO">ExtractionProductVO save(ExtractionProductVO source);
78
79 @Caching(evict = {
80 @CacheEvict(cacheNames = CacheNames.PRODUCT_BY_LABEL, allEntries = true),
81 @CacheEvict(cacheNames = CacheNames.PRODUCTS, allEntries = true),
82 @CacheEvict(cacheNames = CacheNames.PRODUCTS_BY_FILTER, allEntries = true)
83 })
84 void delete(int id);
85
86 }