Introduce soft deleted list option for soft deletable entities (#3093)
* Introduce soft deleted list option for soft deletable entities Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * fix verify build Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * fix typo in license Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Add sorting option on deleted field Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * add missing import in tests Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Rename SoftDeletedFilter to SoftDeletedMode and its values Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Introduce MgmtSoftDeletedMode on api layer Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * remove unused imports Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Integrate the enum on API layer Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Fix OpenApi spec Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * address some comments Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * Get rid of count(SoftDeletedMode) at all Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * remove formatter for enum - stop supporting lowercase values in API Signed-off-by: strailov <Stanislav.Trailov@bosch.io> --------- Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
This commit is contained in:
committed by
GitHub
parent
95680962cc
commit
f44b6268b0
@@ -50,7 +50,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Management service for {@link DistributionSet}s.
|
||||
*/
|
||||
public interface DistributionSetManagement<T extends DistributionSet>
|
||||
extends RepositoryManagement<T, DistributionSetManagement.Create, DistributionSetManagement.Update>, MetadataSupport<String> {
|
||||
extends SoftDeletableRepositoryManagement<T, DistributionSetManagement.Create, DistributionSetManagement.Update>, MetadataSupport<String> {
|
||||
|
||||
@Override
|
||||
default String permissionGroup() {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Management service for {@link DistributionSetType}s.
|
||||
*/
|
||||
public interface DistributionSetTypeManagement<T extends DistributionSetType>
|
||||
extends RepositoryManagement<T, DistributionSetTypeManagement.Create, DistributionSetTypeManagement.Update> {
|
||||
extends SoftDeletableRepositoryManagement<T, DistributionSetTypeManagement.Create, DistributionSetTypeManagement.Update> {
|
||||
|
||||
@Override
|
||||
default String permissionGroup() {
|
||||
|
||||
@@ -164,6 +164,16 @@ public interface RolloutManagement extends PermissionSupport {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<Rollout> findAll(boolean deleted, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts filtered by their soft-deleted state.
|
||||
*
|
||||
* @param softDeletedMode the filter defining which rollouts to return based on their soft-deleted status
|
||||
* @param pageable the page request to sort and limit the result
|
||||
* @return a page of found rollouts
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<Rollout> findAll(SoftDeletedMode softDeletedMode, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout.
|
||||
*
|
||||
@@ -188,6 +198,20 @@ public interface RolloutManagement extends PermissionSupport {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<Rollout> findByRsql(@NotNull String rsql, boolean deleted, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts matching the given RSQL filter, filtered by their soft-deleted state.
|
||||
*
|
||||
* @param rsql the specification to filter rollouts
|
||||
* @param softDeletedMode the filter defining which rollouts to return based on their soft-deleted status
|
||||
* @param pageable the page request to sort and limit the result
|
||||
* @return a page of found rollouts
|
||||
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given
|
||||
* {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<Rollout> findByRsql(@NotNull String rsql, SoftDeletedMode softDeletedMode, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Finds rollouts by given text in name or description.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.eclipse.hawkbit.auth.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Extension of {@link RepositoryManagement} for entities that support soft deletion,
|
||||
* providing query methods that allow filtering by soft-deleted state.
|
||||
*
|
||||
* @param <T> type of the {@link BaseEntity}
|
||||
* @param <C> type of the create request
|
||||
* @param <U> type of the update request
|
||||
*/
|
||||
public interface SoftDeletableRepositoryManagement<T extends BaseEntity, C, U extends Identifiable<Long>>
|
||||
extends RepositoryManagement<T, C, U> {
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Page} of all {@link BaseEntity}s filtered by their soft-deleted state.
|
||||
*
|
||||
* @param softDeletedMode the filter defining which entities to return based on their soft-deleted status
|
||||
* @param pageable the page request to sort and limit the result
|
||||
* @return a page of found entities matching the given soft-deleted filter
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<T> findAll(@NotNull SoftDeletedMode softDeletedMode, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Page} of {@link BaseEntity}s matching the given RSQL filter,
|
||||
* filtered by their soft-deleted state.
|
||||
*
|
||||
* @param rsql filter definition in RSQL syntax
|
||||
* @param softDeletedMode the filter defining which entities to return based on their soft-deleted status
|
||||
* @param pageable the page request to sort and limit the result
|
||||
* @return a page of found entities matching both the RSQL filter and the soft-deleted filter
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
Page<T> findByRsql(@NotNull String rsql, @NotNull SoftDeletedMode softDeletedMode, @NotNull Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
public enum SoftDeletedMode {
|
||||
ONLY_SOFT_DELETED,
|
||||
EXCLUDE_SOFT_DELETED,
|
||||
INCLUDE_SOFT_DELETED
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Service for managing {@link SoftwareModule}s.
|
||||
*/
|
||||
public interface SoftwareModuleManagement<T extends SoftwareModule>
|
||||
extends RepositoryManagement<T, SoftwareModuleManagement.Create, SoftwareModuleManagement.Update>, MetadataSupport<MetadataValue> {
|
||||
extends SoftDeletableRepositoryManagement<T, SoftwareModuleManagement.Create, SoftwareModuleManagement.Update>, MetadataSupport<MetadataValue> {
|
||||
|
||||
@Override
|
||||
default String permissionGroup() {
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Service for managing {@link SoftwareModuleType}s.
|
||||
*/
|
||||
public interface SoftwareModuleTypeManagement<T extends SoftwareModuleType>
|
||||
extends RepositoryManagement<T, SoftwareModuleTypeManagement.Create, SoftwareModuleTypeManagement.Update> {
|
||||
extends SoftDeletableRepositoryManagement<T, SoftwareModuleTypeManagement.Create, SoftwareModuleTypeManagement.Update> {
|
||||
|
||||
@Override
|
||||
default String permissionGroup() {
|
||||
|
||||
Reference in New Issue
Block a user