Package africa.absa.inception.security
Interface TenantRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Tenant,,UUID> org.springframework.data.jpa.repository.JpaRepository<Tenant,,UUID> org.springframework.data.repository.PagingAndSortingRepository<Tenant,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<Tenant>,org.springframework.data.repository.Repository<Tenant,UUID>
public interface TenantRepository
extends org.springframework.data.jpa.repository.JpaRepository<Tenant,UUID>
The TenantRepository interface declares the repository for the Tenant domain type.
- Author:
- Marcus Portmann
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddUserDirectoryToTenant(UUID tenantId, UUID userDirectoryId) Add the user directory to the tenant.voiddeleteById(UUID tenantId) Delete the tenant.booleanexistsByNameIgnoreCase(String name) Check whether the tenant with the specified name exists.org.springframework.data.domain.Page<Tenant>findAll(org.springframework.data.domain.Pageable pageable) Retrieve the tenants.findAllByUserDirectoryId(UUID userDirectoryId) Retrieve the tenants for the user directory.org.springframework.data.domain.Page<Tenant>findFiltered(String filter, org.springframework.data.domain.Pageable pageable) Retrieve the filtered tenants.getNameById(UUID tenantId) Retrieve the name of the tenant.getUserDirectoryIdsById(UUID tenantId) Retrieve the IDs for the user directories for the tenant.voidremoveUserDirectoryFromTenant(UUID tenantId, UUID userDirectoryId) Remove the user directory from the tenantbooleanuserDirectoryToTenantMappingExists(UUID tenantId, UUID userDirectoryId) Check whether the user directory to tenant mapping exists.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findOne
-
Method Details
-
addUserDirectoryToTenant
@Modifying @Query(value="insert into security.user_directory_to_tenant_map(tenant_id, user_directory_id) values (:tenantId, :userDirectoryId)", nativeQuery=true) void addUserDirectoryToTenant(@Param("tenantId") UUID tenantId, @Param("userDirectoryId") UUID userDirectoryId) Add the user directory to the tenant.- Parameters:
tenantId- the ID for the tenantuserDirectoryId- the ID for the user directory
-
deleteById
@Modifying @Query("delete from Tenant u where u.id = :tenantId") void deleteById(@Param("tenantId") UUID tenantId) Delete the tenant. -
existsByNameIgnoreCase
Check whether the tenant with the specified name exists.- Parameters:
name- the name of the tenant- Returns:
- true if a tenant with the specified name exists or false otherwise
-
findAll
org.springframework.data.domain.Page<Tenant> findAll(org.springframework.data.domain.Pageable pageable) Retrieve the tenants. -
findAllByUserDirectoryId
@Query("select o from Tenant o join o.userDirectories as ud where ud.id = :userDirectoryId") List<Tenant> findAllByUserDirectoryId(@Param("userDirectoryId") UUID userDirectoryId) Retrieve the tenants for the user directory.- Parameters:
userDirectoryId- the ID for the user directory- Returns:
- the tenants for the user directory
-
findFiltered
@Query("select t from Tenant t where (lower(t.name) like lower(:filter))") org.springframework.data.domain.Page<Tenant> findFiltered(String filter, org.springframework.data.domain.Pageable pageable) Retrieve the filtered tenants.- Parameters:
filter- the filter to apply to the tenantspageable- the pagination information- Returns:
- the filtered tenants
-
getNameById
@Query("select o.name from Tenant o where o.id = :tenantId") Optional<String> getNameById(@Param("tenantId") UUID tenantId) Retrieve the name of the tenant.- Parameters:
tenantId- the ID for the tenant- Returns:
- an Optional containing the name of the tenant or an empty Optional if the tenant could not be found
-
getUserDirectoryIdsById
@Query("select ud.id from UserDirectory ud join ud.tenants as o where o.id = :tenantId") List<UUID> getUserDirectoryIdsById(@Param("tenantId") UUID tenantId) Retrieve the IDs for the user directories for the tenant.- Parameters:
tenantId- the ID for the tenant- Returns:
- the IDs for the user directories for the tenant
-
removeUserDirectoryFromTenant
@Modifying @Query(value="delete from security.user_directory_to_tenant_map where tenant_id=:tenantId and user_directory_id = :userDirectoryId", nativeQuery=true) void removeUserDirectoryFromTenant(@Param("tenantId") UUID tenantId, @Param("userDirectoryId") UUID userDirectoryId) Remove the user directory from the tenant- Parameters:
tenantId- the ID for the tenantuserDirectoryId- the ID for the user directory
-
userDirectoryToTenantMappingExists
@Query(value="select (count(user_directory_id) > 0) from security.user_directory_to_tenant_map where tenant_id = :tenantId and user_directory_id = :userDirectoryId", nativeQuery=true) boolean userDirectoryToTenantMappingExists(@Param("tenantId") UUID tenantId, @Param("userDirectoryId") UUID userDirectoryId) Check whether the user directory to tenant mapping exists.- Parameters:
tenantId- the ID for the tenantuserDirectoryId- the ID for the user directory- Returns:
- true if the user directory to tenant mapping exists or false otherwise
-