View Javadoc
1   package net.sumaris.core.dao.data;
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.technical.SortDirection;
26  import net.sumaris.core.dao.technical.jpa.SumarisJpaRepository;
27  import net.sumaris.core.model.data.IRootDataEntity;
28  import net.sumaris.core.vo.data.DataFetchOptions;
29  import net.sumaris.core.vo.data.IRootDataVO;
30  import net.sumaris.core.vo.filter.IRootDataFilter;
31  import org.springframework.data.domain.Example;
32  import org.springframework.data.domain.Page;
33  import org.springframework.data.domain.Pageable;
34  import org.springframework.data.jpa.domain.Specification;
35  import org.springframework.data.jpa.repository.Lock;
36  import org.springframework.data.repository.NoRepositoryBean;
37  import org.springframework.lang.Nullable;
38  
39  import javax.persistence.LockModeType;
40  import java.util.List;
41  
42  @NoRepositoryBean
43  public interface RootDataRepository<
44          T extends IRootDataEntity<ID>,
45          ID extends Integer,
46          V extends IRootDataVO<ID>,
47          F extends IRootDataFilter
48          >
49          extends SumarisJpaRepository<T, Integer> {
50  
51      List<V> findAll(@Nullable F filter);
52  
53      Page<V> findAll(@Nullable F filter, Pageable pageable);
54  
55      List<V> findAll(@Nullable F filter, @Nullable DataFetchOptions fetchOptions);
56  
57      Page<V> findAll(@Nullable F filter, Pageable pageable, @Nullable DataFetchOptions fetchOptions);
58  
59      Page<V> findAll(int offset, int size, String sortAttribute, SortDirection sortDirection, DataFetchOptions fetchOptions);
60  
61      Page<V> findAll(F filter, int offset, int size, String sortAttribute,
62                      SortDirection sortDirection, DataFetchOptions fetchOptions);
63  
64      List<V> findAllAsVO(@Nullable Specification<T> spec);
65      Page<V> findAllAsVO(@Nullable Specification<T> spec, Pageable pageable);
66      List<V> findAllAsVO(@Nullable Specification<T> spec, DataFetchOptions fetchOptions);
67      Page<V> findAllAsVO(@Nullable Specification<T> spec, Pageable pageable, DataFetchOptions fetchOption);
68  
69      long count(F filter);
70  
71      V get(int id);
72  
73      V get(int id, DataFetchOptions fetchOptions);
74  
75      @Lock(LockModeType.PESSIMISTIC_WRITE)
76      V save(V vo);
77  
78      Specification<T> toSpecification(@Nullable F filter);
79  
80      V control(V vo);
81  
82      V validate(V vo);
83  
84      V unvalidate(V vo);
85  
86  //    V toVO(E entity);
87  //
88  //    void toEntity(V source, E target, boolean copyIfNull);
89  //
90  //    V createVO();
91  //
92  //    Class<V> getVOClass();
93  }