Skip to content

Commit

Permalink
Merge pull request #929 from terrestris/layerbyname
Browse files Browse the repository at this point in the history
feat(repository): introduce search for layers by `layerName` parameter
  • Loading branch information
ahennr authored Oct 9, 2024
2 parents 37eb29d + c0b157f commit 9a0b7e7
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,26 @@
package de.terrestris.shogun.lib.repository;

import de.terrestris.shogun.lib.model.Layer;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface LayerRepository extends BaseCrudRepository<Layer, Long>, JpaSpecificationExecutor<Layer> { }
public interface LayerRepository extends BaseCrudRepository<Layer, Long>, JpaSpecificationExecutor<Layer> {

@Query(
value = "SELECT * FROM shogun.layers WHERE source_config ->> 'layerNames' = :layerName LIMIT 1",
nativeQuery = true
)
Optional<Layer> findFirstByLayerName(@Param("layerName") String layerName);

@Query(
value = "SELECT * FROM shogun.layers WHERE source_config ->> 'layerNames' = :layerName",
nativeQuery = true
)
List<Layer> findByLayerName(@Param("layerName") String layerName);

}

0 comments on commit 9a0b7e7

Please sign in to comment.