Cleanup messed up actionstatus sorting. We used sort param but had

hardcoded sorting in the reposirory. I added also reportAt based
sorting.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-03-03 18:54:50 +01:00
parent 19fe7e5a46
commit e7173aa846
8 changed files with 77 additions and 80 deletions

View File

@@ -50,13 +50,6 @@ public interface ActionStatusRepository
*/
Page<ActionStatus> findByAction(Pageable pageReq, Action action);
/**
* @param pageReq
* @param action
* @return
*/
Page<ActionStatus> findByActionOrderByIdDesc(Pageable pageReq, Action action);
/**
* Finds all status updates for the defined action and target order by
* {@link ActionStatus#getId()} desc including
@@ -71,6 +64,6 @@ public interface ActionStatusRepository
* @return Page with found targets
*/
@EntityGraph(value = "ActionStatus.withMessages", type = EntityGraphType.LOAD)
Page<ActionStatus> getByActionOrderByIdDesc(Pageable pageReq, Action action);
Page<ActionStatus> getByAction(Pageable pageReq, Action action);
}

View File

@@ -925,7 +925,7 @@ public class DeploymentManagement {
/**
* retrieves all the {@link ActionStatus} entries of the given
* {@link Action} and {@link Target} in the order latest first.
* {@link Action} and {@link Target}.
*
* @param pageReq
* pagination parameter
@@ -937,12 +937,12 @@ public class DeploymentManagement {
* @return the corresponding {@link Page} of {@link ActionStatus}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
public Page<ActionStatus> findActionStatusMessagesByActionInDescOrder(final Pageable pageReq, final Action action,
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final Action action,
final boolean withMessages) {
if (withMessages) {
return actionStatusRepository.getByActionOrderByIdDesc(pageReq, action);
return actionStatusRepository.getByAction(pageReq, action);
} else {
return actionStatusRepository.findByActionOrderByIdDesc(pageReq, action);
return actionStatusRepository.findByAction(pageReq, action);
}
}

View File

@@ -70,8 +70,8 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
.isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusMessagesByActionInDescOrder(pageReq, savedAction, false)
.getNumberOfElements()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction, false).getNumberOfElements())
.isEqualTo(3);
}
@Test