Skip to content

Commit

Permalink
Default sorting for Datastore queries
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 31, 2019
1 parent eb94973 commit b6ed956
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Expand Up @@ -157,8 +157,6 @@ public void onAfterMessageStore(MessageInfo messageInfo,
channelInfo.setFirstMessageId(message.getDatastoreId());
channelInfo.setFirstMessageOn(message.getTimestamp());
channelInfo.setId(new StorableIdImpl(ChannelInfoField.getOrDeriveId(null, channelInfo)));
clientInfo.setFirstMessageId(message.getDatastoreId());
clientInfo.setFirstMessageOn(message.getTimestamp());
channelInfoStoreFacade.upstore(channelInfo);

KapuaPayload payload = message.getPayload();
Expand Down
Expand Up @@ -11,11 +11,15 @@
*******************************************************************************/
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.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

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

@Override
Expand Down
Expand Up @@ -11,11 +11,15 @@
*******************************************************************************/
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.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

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

@Override
Expand Down
Expand Up @@ -11,12 +11,15 @@
*******************************************************************************/
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.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

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

@Override
Expand Down
Expand Up @@ -11,11 +11,15 @@
*******************************************************************************/
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.SortField;
import org.eclipse.kapua.service.datastore.model.query.StorableFetchStyle;

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

@Override
Expand Down

0 comments on commit b6ed956

Please sign in to comment.