Skip to content

Commit

Permalink
Use standard SortOrder instead of SortDirection in Channels REST API
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma authored and Coduz committed Jul 29, 2021
1 parent e26ef2c commit f9dc165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.kapua.app.api.core.model.ScopeId;
import org.eclipse.kapua.app.api.core.model.StorableEntityId;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.query.SortOrder;
import org.eclipse.kapua.service.KapuaService;
import org.eclipse.kapua.service.datastore.ChannelInfoFactory;
import org.eclipse.kapua.service.datastore.ChannelInfoRegistryService;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class DataChannels extends AbstractKapuaResource {
* @param clientId The client id to filter results.
* @param name The channel name to filter results. It allows '#' wildcard in last channel level
* @param sortParam The name of the parameter that will be used as a sorting key
* @param sortDir The sort direction. Can be DESC (default), ASC. Case-insensitive.
* @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive.
* @param offset The result set offset.
* @param limit The result set limit.
* @return The {@link ChannelInfoListResult} of all the channelInfos associated to the current selected scope.
Expand All @@ -75,7 +76,7 @@ public ChannelInfoListResult simpleQuery(@PathParam("scopeId") ScopeId scopeId,
@QueryParam("clientId") String clientId,
@QueryParam("name") String name,
@QueryParam("sortParam") String sortParam,
@QueryParam("sortDir") @DefaultValue("DESC") SortDirection sortDir,
@QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir,
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("50") int limit)
throws KapuaException {
Expand All @@ -95,7 +96,8 @@ public ChannelInfoListResult simpleQuery(@PathParam("scopeId") ScopeId scopeId,
query.setOffset(offset);
query.setLimit(limit);
if (!Strings.isNullOrEmpty(sortParam)) {
query.setSortFields(Collections.singletonList(SortField.of(sortParam, sortDir)));
SortDirection storableSortDirection = sortDir == SortOrder.DESCENDING ? SortDirection.DESC : SortDirection.ASC;
query.setSortFields(Collections.singletonList(SortField.of(sortParam, storableSortDirection)));
}
return query(scopeId, query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ paths:
in: query
schema:
type: string
- description: The sort direction. Can be ascending or descending (default).
- description: The sort direction. Can be ascending (default) or descending.
name: sortDir
in: query
schema:
type: string
enum:
- ASC
- DESC
default: DESC
- ASCENDING
- DESCENDING
default: ASCENDING
- $ref: '../openapi.yaml#/components/parameters/limit'
- $ref: '../openapi.yaml#/components/parameters/offset'
responses:
Expand Down

0 comments on commit f9dc165

Please sign in to comment.