Skip to content

Commit 9a0b7e7

Browse files
authored
Merge pull request #929 from terrestris/layerbyname
feat(repository): introduce search for layers by `layerName` parameter
2 parents 37eb29d + c0b157f commit 9a0b7e7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

shogun-lib/src/main/java/de/terrestris/shogun/lib/repository/LayerRepository.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,26 @@
1717
package de.terrestris.shogun.lib.repository;
1818

1919
import de.terrestris.shogun.lib.model.Layer;
20+
import java.util.List;
21+
import java.util.Optional;
2022
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
23+
import org.springframework.data.jpa.repository.Query;
24+
import org.springframework.data.repository.query.Param;
2125
import org.springframework.stereotype.Repository;
2226

2327
@Repository
24-
public interface LayerRepository extends BaseCrudRepository<Layer, Long>, JpaSpecificationExecutor<Layer> { }
28+
public interface LayerRepository extends BaseCrudRepository<Layer, Long>, JpaSpecificationExecutor<Layer> {
29+
30+
@Query(
31+
value = "SELECT * FROM shogun.layers WHERE source_config ->> 'layerNames' = :layerName LIMIT 1",
32+
nativeQuery = true
33+
)
34+
Optional<Layer> findFirstByLayerName(@Param("layerName") String layerName);
35+
36+
@Query(
37+
value = "SELECT * FROM shogun.layers WHERE source_config ->> 'layerNames' = :layerName",
38+
nativeQuery = true
39+
)
40+
List<Layer> findByLayerName(@Param("layerName") String layerName);
41+
42+
}

0 commit comments

Comments
 (0)