本文整理了Java中org.apache.usergrid.persistence.Query.setReversed
方法的一些代码示例,展示了Query.setReversed
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setReversed
方法的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query
方法名:setReversed
暂无
代码示例来源:origin: apache/usergrid
public Query withReversed( boolean reversed ) {
setReversed( reversed );
return this;
}
代码示例来源:origin: apache/usergrid
@Override
public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
boolean reversed ) throws Exception {
final String ql;
if (startResult != null ) {
// UUID timestamp is a different measure than 'created' field on entities
Calendar uuidEpoch = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
uuidEpoch.clear();
uuidEpoch.set(1582, 9, 15, 0, 0, 0); // 9 = October
long epochMillis = uuidEpoch.getTime().getTime();
long time = (startResult.timestamp() / 10000L) + epochMillis;
if ( !reversed ) {
ql = "select * where created > " + time;
} else {
ql = "select * where created < " + time;
}
} else {
ql = "select *";
}
Query query = Query.fromQL( ql );
if(query == null ){
throw new RuntimeException("Unable to get data for collection: "+collectionName);
}
query.setLimit( count );
query.setReversed( reversed );
return searchCollection( collectionName, query );
}
代码示例来源:origin: apache/usergrid
q.setReversed( reversed );
代码示例来源:origin: apache/usergrid
@Test
public void emptyQueryReverse() throws Exception {
logger.debug( "emptyQueryReverse" );
EntityManager em = app.getEntityManager();
assertNotNull( em );
String firstName = "firstName" + UUIDUtils.newTimeUUID();
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "username", "edanuff" );
properties.put( "email", "ed@anuff.com" );
properties.put( "firstname", firstName );
Entity user = em.create( "user", properties );
assertNotNull( user );
properties = new LinkedHashMap<String, Object>();
properties.put( "username", "djacobs" );
properties.put( "email", "djacobs@gmail.com" );
Entity user2 = em.create( "user", properties );
assertNotNull( user2 );
app.waitForQueueDrainAndRefreshIndex();
// EntityRef
Query query = new Query();
query.setReversed( true );
Results r = em.searchCollection( em.getApplicationRef(), "users", query );
assertEquals( 2, r.size() );
Entity returned = r.getEntities().get( 0 );
assertEquals( user2.getUuid(), returned.getUuid() );
returned = r.getEntities().get( 1 );
assertEquals( user.getUuid(), returned.getUuid() );
}
代码示例来源:origin: apache/usergrid
@Override
public ServiceResults putItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( context.moreParameters() ) {
return getItemsByQuery( context, query );
}
query = new Query( query );
query.setResultsLevel( Level.ALL_PROPERTIES );
query.setLimit( 1000 );
if ( !query.isReversedSet() ) {
query.setReversed( isCollectionReversed( context ) );
}
Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
if ( r.isEmpty() ) {
throw new ServiceResourceNotFoundException( context );
}
updateEntities( context, r );
return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
}
代码示例来源:origin: apache/usergrid
@Override
public ServiceResults deleteItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( context.moreParameters() ) {
return getItemsByQuery( context, query );
}
query = new Query( query );
query.setResultsLevel( Level.ALL_PROPERTIES );
query.setLimit( query.getLimit() );
if ( !query.isReversedSet() ) {
query.setReversed( isCollectionReversed( context ) );
}
Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
importEntities( context, r );
for ( Entity entity : r ) {
prepareToDelete( context, entity );
}
for ( Entity entity : r ) {
em.removeFromCollection( context.getOwner(), context.getCollectionName(), entity );
}
return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
}
代码示例来源:origin: apache/usergrid
query.setReversed( isCollectionReversed( context ) );
内容来源于网络,如有侵权,请联系作者删除!