Add existsByInstalledOrAssignedDistributionSet (#1064)
Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io>
This commit is contained in:
committed by
GitHub
parent
2191db40d7
commit
8816396d18
@@ -646,6 +646,13 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
return targetRepository.countByInstalledDistributionSetId(distId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByInstalledOrAssignedDistributionSet(final long distId) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distId);
|
||||
|
||||
return targetRepository.existsByInstalledOrAssignedDistributionSet(distId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByTargetFilterQueryAndNonDS(final Pageable pageRequest, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
|
||||
@@ -208,6 +208,16 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
|
||||
*/
|
||||
Long countByInstalledDistributionSetId(Long distId);
|
||||
|
||||
/**
|
||||
* Checks if there is already a {@link Target} that has the given distribution set Id assigned or installed.
|
||||
*
|
||||
* @param distId
|
||||
* to check
|
||||
* @return <code>true</code> if a {@link Target} exists.
|
||||
*/
|
||||
@Query("SELECT CASE WHEN COUNT(t)>0 THEN 'true' ELSE 'false' END FROM JpaTarget t WHERE t.installedDistributionSet.id=:distId OR t.assignedDistributionSet.id=:distId")
|
||||
boolean existsByInstalledOrAssignedDistributionSet(@Param("distId") Long distId);
|
||||
|
||||
/**
|
||||
* Finds all {@link Target}s in the repository.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user