Refactor management api style (#2445)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-06-10 17:09:03 +03:00
committed by GitHub
parent 85ef8652fc
commit 2992f5c211
88 changed files with 671 additions and 736 deletions

View File

@@ -200,9 +200,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<Target> targetsAssignedDS;
if (rsqlParam != null) {
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId, rsqlParam);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(distributionSetId, rsqlParam, pageable);
} else {
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(distributionSetId, pageable);
}
return ResponseEntity.ok(new PagedList<>(
@@ -218,9 +218,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<Target> targetsInstalledDS;
if (rsqlParam != null) {
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, distributionSetId, rsqlParam);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(distributionSetId, rsqlParam, pageable);
} else {
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(distributionSetId, pageable);
}
return ResponseEntity.ok(new PagedList<>(
@@ -233,7 +233,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
.findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam);
.findByAutoAssignDSAndRsql(distributionSetId, rsqlParam, pageable);
return ResponseEntity.ok(new PagedList<>(
MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent(), tenantConfigHelper.isConfirmationFlowEnabled(), false),

View File

@@ -94,13 +94,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final List<MgmtRolloutResponseBody> rest;
if (isFullMode) {
rollouts = rsqlParam == null
? rolloutManagement.findAllWithDetailedStatus(pageable, false)
: rolloutManagement.findByRsqlWithDetailedStatus(pageable, rsqlParam, false);
? rolloutManagement.findAllWithDetailedStatus(false, pageable)
: rolloutManagement.findByRsqlWithDetailedStatus(rsqlParam, false, pageable);
rest = MgmtRolloutMapper.toResponseRolloutWithDetails(rollouts.getContent());
} else {
rollouts = rsqlParam == null
? rolloutManagement.findAll(pageable, false)
: rolloutManagement.findByRsql(pageable, rsqlParam, false);
? rolloutManagement.findAll(false, pageable)
: rolloutManagement.findByRsql(rsqlParam, false, pageable);
rest = MgmtRolloutMapper.toResponseRollout(rollouts.getContent());
}
return ResponseEntity.ok(new PagedList<>(rest, rollouts.getTotalElements()));
@@ -256,7 +256,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
if (rsqlParam == null) {
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable);
} else {
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(groupId, rsqlParam, pageable);
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent(), tenantConfigHelper);
return ResponseEntity.ok(new PagedList<>(rest, rolloutGroupTargets.getTotalElements()));

View File

@@ -80,7 +80,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
final Slice<TargetFilterQuery> findTargetFiltersAll;
final long countTargetsAll;
if (rsqlParam != null) {
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(pageable, rsqlParam);
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(rsqlParam, pageable);
countTargetsAll = findFilterPage.getTotalElements();
findTargetFiltersAll = findFilterPage;
} else {

View File

@@ -118,7 +118,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Slice<Target> findTargetsAll;
final long countTargetsAll;
if (rsqlParam != null) {
findTargetsAll = targetManagement.findByRsql(pageable, rsqlParam);
findTargetsAll = targetManagement.findByRsql(rsqlParam, pageable);
countTargetsAll = targetManagement.countByRsql(rsqlParam);
} else {
findTargetsAll = targetManagement.findAll(pageable);
@@ -340,7 +340,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
return ResponseEntity.notFound().build();
}
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionStatusSortParam(sortParam));
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(pageable, action.getId());
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(action.getId(), pageable);
return ResponseEntity.ok(new PagedList<>(
MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement),

View File

@@ -70,7 +70,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
if (rsqlParam == null) {
findTargetsAll = this.tagManagement.findAll(pageable);
} else {
findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam);
findTargetsAll = this.tagManagement.findByRsql(rsqlParam, pageable);
}
final List<MgmtTag> rest = MgmtTagMapper.toResponse(findTargetsAll.getContent());
@@ -128,9 +128,9 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam));
final Page<Target> findTargetsAll;
if (rsqlParam == null) {
findTargetsAll = targetManagement.findByTag(pageable, targetTagId);
findTargetsAll = targetManagement.findByTag(targetTagId, pageable);
} else {
findTargetsAll = targetManagement.findByRsqlAndTag(pageable, rsqlParam, targetTagId);
findTargetsAll = targetManagement.findByRsqlAndTag(rsqlParam, targetTagId, pageable);
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent(), tenantConfigHelper);

View File

@@ -58,7 +58,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi {
final Slice<TargetType> findTargetTypesAll;
long countTargetTypesAll;
if (rsqlParam != null) {
findTargetTypesAll = targetTypeManagement.findByRsql(pageable, rsqlParam);
findTargetTypesAll = targetTypeManagement.findByRsql(rsqlParam, pageable);
countTargetTypesAll = ((Page<TargetType>) findTargetTypesAll).getTotalElements();
} else {
findTargetTypesAll = targetTypeManagement.findAll(pageable);

View File

@@ -206,7 +206,7 @@ public final class MgmtTargetMapper {
return actionStatus.stream()
.map(status -> toResponse(status,
deploymentManagement.findMessagesByActionStatusId(
PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
status.getId(), PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT))
.getContent()))
.toList();
}