1
2
3
4
5
6
7 package org.tailormap.api.repository;
8
9 import java.util.List;
10 import java.util.Optional;
11 import org.springframework.data.jpa.repository.JpaRepository;
12 import org.springframework.data.jpa.repository.Query;
13 import org.springframework.data.repository.query.Param;
14 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
15 import org.springframework.lang.NonNull;
16 import org.springframework.security.access.prepost.PreAuthorize;
17 import org.tailormap.api.persistence.TMFeatureSource;
18 import org.tailormap.api.security.annotation.PreAuthorizeAdmin;
19
20 @PreAuthorizeAdmin
21 @RepositoryRestResource(
22 path = "feature-sources",
23 collectionResourceRel = "feature-sources",
24 itemResourceRel = "feature-source")
25 public interface FeatureSourceRepository extends JpaRepository<TMFeatureSource, Long> {
26 TMFeatureSource findByUrl(String url);
27
28 @Override
29 @PreAuthorize(value = "permitAll()")
30 @NonNull
31 Optional<TMFeatureSource> findById(@NonNull Long id);
32
33 @PreAuthorize(value = "permitAll()")
34 List<TMFeatureSource> findByLinkedServiceId(String id);
35
36 @NonNull
37 @PreAuthorize("permitAll()")
38 @Query("from TMFeatureSource fs where id in :ids")
39 List<TMFeatureSource> findByIds(@Param("ids") List<Long> ids);
40
41
42
43
44
45
46
47
48
49
50 @NonNull
51 @PreAuthorize("permitAll()")
52 @Query("from TMFeatureSource fs where id not in :ids")
53 List<TMFeatureSource> getAllExcludingIds(@Param("ids") List<Long> ids);
54
55
56
57
58
59
60
61
62 @PreAuthorize(value = "permitAll()")
63 Optional<TMFeatureSource> getByTitle(String title);
64 }