View Javadoc
1   /*
2    * Copyright (C) 2023 B3Partners B.V.
3    *
4    * SPDX-License-Identifier: MIT
5    */
6   package org.tailormap.api.repository;
7   
8   import java.util.Optional;
9   import org.springframework.data.jpa.repository.JpaRepository;
10  import org.springframework.data.rest.core.annotation.RepositoryRestResource;
11  import org.springframework.security.access.prepost.PreAuthorize;
12  import org.tailormap.api.persistence.TMFeatureSource;
13  import org.tailormap.api.persistence.TMFeatureType;
14  
15  @RepositoryRestResource(
16      path = "feature-types",
17      collectionResourceRel = "feature-types",
18      itemResourceRel = "feature-type")
19  public interface FeatureTypeRepository extends JpaRepository<TMFeatureType, Long> {
20  
21    /**
22     * Get a feature type by name and feature source. This is a non-deterministic operation since the
23     * combination of name and feature source is not unique. Useful for testing.
24     *
25     * @param name The name of the feature type
26     * @param featureSource The feature source of the feature type
27     * @return The feature type
28     */
29    @PreAuthorize("permitAll()")
30    Optional<TMFeatureType> getTMFeatureTypeByNameAndFeatureSource(
31        String name, TMFeatureSource featureSource);
32  }