Added comments and changed default sorting for actions.
This commit is contained in:
@@ -21,38 +21,47 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
/**
|
/**
|
||||||
* {@link ActionStatus} repository.
|
* {@link ActionStatus} repository.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface ActionStatusRepository
|
public interface ActionStatusRepository
|
||||||
extends BaseEntityRepository<ActionStatus, Long>, JpaSpecificationExecutor<ActionStatus> {
|
extends BaseEntityRepository<ActionStatus, Long>, JpaSpecificationExecutor<ActionStatus> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param target
|
* Counts {@link ActionStatus} entries of given {@link Action} in
|
||||||
|
* repository.
|
||||||
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* @return
|
* to count status entries
|
||||||
|
* @return number of actions in repository
|
||||||
*/
|
*/
|
||||||
Long countByAction(Action action);
|
Long countByAction(Action action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Counts {@link ActionStatus} entries of given {@link Action} with given
|
||||||
|
* {@link Status} in repository.
|
||||||
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* @param retrieved
|
* to count status entries
|
||||||
* @return
|
* @param status
|
||||||
|
* to filter for
|
||||||
|
* @return number of actions in repository
|
||||||
*/
|
*/
|
||||||
Long countByActionAndStatus(Action action, Status retrieved);
|
Long countByActionAndStatus(Action action, Status status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Retrieves all {@link ActionStatus} entries from repository of given
|
||||||
|
* {@link Action}.
|
||||||
|
*
|
||||||
* @param pageReq
|
* @param pageReq
|
||||||
|
* parameters
|
||||||
* @param action
|
* @param action
|
||||||
* @return
|
* of the status entries
|
||||||
|
* @return pages list of {@link ActionStatus} entries
|
||||||
*/
|
*/
|
||||||
Page<ActionStatus> findByAction(Pageable pageReq, Action action);
|
Page<ActionStatus> findByAction(Pageable pageReq, Action action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all status updates for the defined action and target order by
|
* Finds all status updates for the defined action and target including
|
||||||
* {@link ActionStatus#getId()} desc including
|
|
||||||
* {@link ActionStatus#getMessages()}.
|
* {@link ActionStatus#getMessages()}.
|
||||||
*
|
*
|
||||||
* @param pageReq
|
* @param pageReq
|
||||||
|
|||||||
@@ -23,11 +23,6 @@ import org.springframework.data.domain.Sort.Direction;
|
|||||||
/**
|
/**
|
||||||
* Utility class for for paged body generation.
|
* Utility class for for paged body generation.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class PagingUtility {
|
public final class PagingUtility {
|
||||||
/*
|
/*
|
||||||
@@ -90,8 +85,9 @@ public final class PagingUtility {
|
|||||||
if (sortParam != null) {
|
if (sortParam != null) {
|
||||||
sorting = new Sort(SortUtility.parse(ActionFields.class, sortParam));
|
sorting = new Sort(SortUtility.parse(ActionFields.class, sortParam));
|
||||||
} else {
|
} else {
|
||||||
// default sort
|
// default sort is DESC in case of action to match behavior
|
||||||
sorting = new Sort(Direction.ASC, ActionFields.ID.getFieldName());
|
// of management UI (last entry on top)
|
||||||
|
sorting = new Sort(Direction.DESC, ActionFields.ID.getFieldName());
|
||||||
}
|
}
|
||||||
return sorting;
|
return sorting;
|
||||||
}
|
}
|
||||||
@@ -101,7 +97,8 @@ public final class PagingUtility {
|
|||||||
if (sortParam != null) {
|
if (sortParam != null) {
|
||||||
sorting = new Sort(SortUtility.parse(ActionStatusFields.class, sortParam));
|
sorting = new Sort(SortUtility.parse(ActionStatusFields.class, sortParam));
|
||||||
} else {
|
} else {
|
||||||
// default sort
|
// default sort is DESC in case of action status to match behavior
|
||||||
|
// of management UI (last entry on top)
|
||||||
sorting = new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName());
|
sorting = new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName());
|
||||||
}
|
}
|
||||||
return sorting;
|
return sorting;
|
||||||
|
|||||||
@@ -833,7 +833,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
|
|||||||
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
||||||
|
|
||||||
mvc.perform(get(
|
mvc.perform(get(
|
||||||
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS))
|
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
|
||||||
|
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue())))
|
.andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue())))
|
||||||
.andExpect(jsonPath("content.[1].type", equalTo("update")))
|
.andExpect(jsonPath("content.[1].type", equalTo("update")))
|
||||||
@@ -960,7 +961,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
|
|||||||
// page 1: one entry
|
// page 1: one entry
|
||||||
mvc.perform(get(
|
mvc.perform(get(
|
||||||
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
|
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
|
||||||
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)))
|
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
|
||||||
|
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue())))
|
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue())))
|
||||||
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
|
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
|
||||||
@@ -976,7 +978,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
|
|||||||
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
|
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
|
||||||
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
|
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
|
||||||
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
|
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
|
||||||
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)))
|
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
|
||||||
|
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(1).getId().intValue())))
|
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(1).getId().intValue())))
|
||||||
.andExpect(jsonPath("content.[0].type", equalTo("update")))
|
.andExpect(jsonPath("content.[0].type", equalTo("update")))
|
||||||
|
|||||||
Reference in New Issue
Block a user