1
2
3
4
5
6 package org.tailormap.api.repository;
7
8 import java.util.List;
9 import java.util.Optional;
10 import java.util.UUID;
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.tailormap.api.persistence.SearchIndex;
17
18 @RepositoryRestResource(
19 path = "search-indexes",
20 collectionResourceRel = "search-indexes",
21 itemResourceRel = "search-index")
22 public interface SearchIndexRepository extends JpaRepository<SearchIndex, Long> {
23 List<SearchIndex> findByFeatureTypeId(Long featureTypeId);
24
25 Optional<SearchIndex> findByName(String name);
26
27 @NonNull
28 @Query(
29 value =
30 "select * from search_index si, lateral jsonb_path_query(si.schedule, ('$.uuid ? (@ == \"'||:uuidToFind||'\")')::jsonpath)",
31 nativeQuery = true)
32 List<SearchIndex> findByTaskScheduleUuid(@Param("uuidToFind") @NonNull UUID uuid);
33
34 List<SearchIndex> findSearchIndexById(Long id);
35 }