Skip to content

Commit

Permalink
Default sorting for Datastore 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 committed Jul 30, 2019
1 parent 69c4a42 commit 8e760ef
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
*******************************************************************************/
package org.eclipse.kapua.service.datastore.internal.model.query;

import java.util.Collections;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.datastore.internal.AbstractStorableQuery;
import org.eclipse.kapua.service.datastore.internal.mediator.ChannelInfoField;
import org.eclipse.kapua.service.datastore.internal.schema.ChannelInfoSchema;
import org.eclipse.kapua.service.datastore.model.ChannelInfo;
import org.eclipse.kapua.service.datastore.model.query.ChannelInfoQuery;
import org.eclipse.kapua.service.datastore.model.query.SortDirection;
import org.eclipse.kapua.service.datastore.model.query.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

/**
Expand All @@ -35,6 +40,7 @@ public class ChannelInfoQueryImpl extends AbstractStorableQuery<ChannelInfo> imp
*/
public ChannelInfoQueryImpl(KapuaId scopeId) {
super(scopeId);
setSortFields(Collections.singletonList(SortField.of(SortDirection.ASC, ChannelInfoSchema.CHANNEL_NAME)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
*******************************************************************************/
package org.eclipse.kapua.service.datastore.internal.model.query;

import java.util.Collections;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.datastore.internal.AbstractStorableQuery;
import org.eclipse.kapua.service.datastore.internal.mediator.ClientInfoField;
import org.eclipse.kapua.service.datastore.internal.schema.ClientInfoSchema;
import org.eclipse.kapua.service.datastore.model.ClientInfo;
import org.eclipse.kapua.service.datastore.model.query.ClientInfoQuery;
import org.eclipse.kapua.service.datastore.model.query.SortDirection;
import org.eclipse.kapua.service.datastore.model.query.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

/**
Expand All @@ -34,6 +39,7 @@ public class ClientInfoQueryImpl extends AbstractStorableQuery<ClientInfo> imple
*/
public ClientInfoQueryImpl(KapuaId scopeId) {
super(scopeId);
setSortFields(Collections.singletonList(SortField.of(SortDirection.ASC, ClientInfoSchema.CLIENT_ID)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
*******************************************************************************/
package org.eclipse.kapua.service.datastore.internal.model.query;

import java.util.Collections;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.datastore.internal.AbstractStorableQuery;
import org.eclipse.kapua.service.datastore.internal.mediator.MessageField;
import org.eclipse.kapua.service.datastore.internal.schema.MessageSchema;
import org.eclipse.kapua.service.datastore.model.DatastoreMessage;
import org.eclipse.kapua.service.datastore.model.query.MessageQuery;
import org.eclipse.kapua.service.datastore.model.query.SortDirection;
import org.eclipse.kapua.service.datastore.model.query.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

/**
Expand All @@ -36,6 +40,7 @@ public class MessageQueryImpl extends AbstractStorableQuery<DatastoreMessage> im
*/
public MessageQueryImpl(KapuaId scopeId) {
super(scopeId);
setSortFields(Collections.singletonList(SortField.of(SortDirection.DESC, MessageSchema.MESSAGE_TIMESTAMP)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
*******************************************************************************/
package org.eclipse.kapua.service.datastore.internal.model.query;

import java.util.Collections;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.datastore.internal.AbstractStorableQuery;
import org.eclipse.kapua.service.datastore.internal.mediator.MetricInfoField;
import org.eclipse.kapua.service.datastore.internal.schema.MetricInfoSchema;
import org.eclipse.kapua.service.datastore.model.MetricInfo;
import org.eclipse.kapua.service.datastore.model.query.MetricInfoQuery;
import org.eclipse.kapua.service.datastore.model.query.SortDirection;
import org.eclipse.kapua.service.datastore.model.query.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

/**
Expand All @@ -34,6 +39,7 @@ public class MetricInfoQueryImpl extends AbstractStorableQuery<MetricInfo> imple
*/
public MetricInfoQueryImpl(KapuaId scopeId) {
super(scopeId);
setSortFields(Collections.singletonList(SortField.of(SortDirection.ASC, MetricInfoSchema.METRIC_MTR_NAME)));
}

@Override
Expand Down

0 comments on commit 8e760ef

Please sign in to comment.