Skip to content

Commit

Permalink
Remove unused DistributionSetManagement#findByDistributionSetFilterOr…
Browse files Browse the repository at this point in the history
…derByLinkedTarget (#2141)

Signed-off-by: Avgustin Marinov <[email protected]>
  • Loading branch information
avgustinmm authored Dec 11, 2024
1 parent bae3281 commit d8c8e80
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,28 +279,6 @@ Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(@NotNull Pa
Slice<DistributionSet> findByDistributionSetFilter(@NotNull Pageable pageable,
@NotNull DistributionSetFilter distributionSetFilter);

/**
* Method retrieves all {@link DistributionSet}s from the repository in the
* following order:
* <p>
* 1) {@link DistributionSet}s which have the given {@link Target} as
* {@link TargetInfo#getInstalledDistributionSet()}
* <p>
* 2) {@link DistributionSet}s which have the given {@link Target} as
* {@link Target#getAssignedDistributionSet()}
* <p>
* 3) {@link DistributionSet}s which have no connection to the given
* {@link Target} ordered by ID of the DistributionSet.
*
* @param pageable the page request to page the result set *
* @param distributionSetFilter has details of filters to be applied.
* @param assignedOrInstalled the id of the Target to be ordered by
* @return {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<DistributionSet> findByDistributionSetFilterOrderByLinkedTarget(@NotNull Pageable pageable,
@NotNull DistributionSetFilter distributionSetFilter, @NotEmpty String assignedOrInstalled);

/**
* Counts all {@link DistributionSet}s in repository based on given filter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.SystemManagement;
Expand Down Expand Up @@ -83,7 +82,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.retry.annotation.Backoff;
Expand Down Expand Up @@ -409,7 +407,7 @@ public Optional<DistributionSet> getByAction(final long actionId) {
throw new InsufficientPermissionException("Target not accessible (or not found)!");
}
return distributionSetRepository
.findOne(DistributionSetSpecification.byId(action.getDistributionSet().getId()))
.findOne(DistributionSetSpecification.byIdFetch(action.getDistributionSet().getId()))
.orElseThrow(() ->
new InsufficientPermissionException("DistributionSet not accessible (or not found)!"));
})
Expand Down Expand Up @@ -518,25 +516,9 @@ public Slice<DistributionSet> findByDistributionSetFilter(final Pageable pageabl
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageable, specList);
}

@Override
public Slice<DistributionSet> findByDistributionSetFilterOrderByLinkedTarget(final Pageable pageable,
final DistributionSetFilter distributionSetFilter, final String assignedOrInstalled) {
// remove default sort from pageable to not overwrite sorted spec
final OffsetBasedPageRequest unsortedPage = new OffsetBasedPageRequest(pageable.getOffset(),
pageable.getPageSize(), Sort.unsorted());

final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
distributionSetFilter);
specList.add(DistributionSetSpecification.orderedByLinkedTarget(assignedOrInstalled, pageable.getSort()));

return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, unsortedPage, specList);
}

@Override
public long countByDistributionSetFilter(@NotNull final DistributionSetFilter distributionSetFilter) {
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
distributionSetFilter);

final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(distributionSetFilter);
return JpaManagementHelper.countBySpec(distributionSetRepository, specList);
}

Expand Down Expand Up @@ -791,7 +773,7 @@ private List<DistributionSet> updateTag(
distributionSetRepository.findById(dsIds.iterator().next())
.map(List::of)
.orElseGet(Collections::emptyList) :
distributionSetRepository.findAll(DistributionSetSpecification.byIds(dsIds));
distributionSetRepository.findAll(DistributionSetSpecification.byIdsFetch(dsIds));
if (allDs.size() < dsIds.size()) {
throw new EntityNotFoundException(DistributionSet.class, notFound(dsIds, allDs));
}
Expand Down Expand Up @@ -898,7 +880,7 @@ private <T> T updateTag(
final BiFunction<List<JpaDistributionSet>, DistributionSetTag, T> updater) {
final List<JpaDistributionSet> allDs = dsIds.size() == 1 ?
distributionSetRepository.findById(dsIds.iterator().next()).map(List::of).orElseGet(Collections::emptyList) :
distributionSetRepository.findAll(DistributionSetSpecification.byIds(dsIds));
distributionSetRepository.findAll(DistributionSetSpecification.byIdsFetch(dsIds));
if (allDs.size() < dsIds.size()) {
throw new EntityNotFoundException(DistributionSet.class, dsIds, allDs.stream().map(DistributionSet::getId).toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
Long countAutoAssignmentsForDistributionSet(@Param("dsId") Long dsId);

/**
* Finds {@link DistributionSet}s where given {@link SoftwareModule} is
* assigned.
* Finds {@link DistributionSet}s where given {@link SoftwareModule} is assigned.
* <p/>
* No access control applied.
*
Expand All @@ -77,8 +76,7 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
Long countByModulesId(Long moduleId);

/**
* Finds {@link DistributionSet}s based on given ID that are assigned yet to
* an {@link Action}, i.e. in use.
* Finds {@link DistributionSet}s based on given ID that are assigned yet to an {@link Action}, i.e. in use.
* <p/>
* No access control applied.
*
Expand All @@ -89,8 +87,7 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Collection<Long> ids);

/**
* Finds {@link DistributionSet}s based on given ID that are assigned yet to
* an {@link Rollout}, i.e. in use.
* Finds {@link DistributionSet}s based on given ID that are assigned yet to an {@link Rollout}, i.e. in use.
* <p/>
* No access control applied.
*
Expand All @@ -111,10 +108,8 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
long countByTypeId(Long typeId);

/**
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
* reasons (this is a "delete everything" query after all) we add the tenant
* manually to query even if this will by done by {@link EntityManager}
* anyhow. The DB should take care of optimizing this away.
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety reasons (this is a "delete everything" query after all) we add
* the tenant manually to query even if this will by done by {@link EntityManager} anyhow. The DB should take care of optimizing this away.
*
* @param tenant to delete data from
*/
Expand Down
Loading

0 comments on commit d8c8e80

Please sign in to comment.