本文整理了Java中org.apache.usergrid.persistence.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query
暂无
代码示例来源: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
q = Query.fromQL( decode( ql ) );
q = newQueryIfNull( q );
q.setEntityType( type );
q = newQueryIfNull( q );
q.setConnectionType( connection );
q = newQueryIfNull( q );
q.setPermissions( permissions );
q = newQueryIfNull( q );
q.setStartResult( start );
q = newQueryIfNull( q );
q.setCursor( cursor );
q = newQueryIfNull( q );
q.setLimit( limit );
q = newQueryIfNull( q );
q.setStartTime( startTime );
q = newQueryIfNull( q );
q.setFinishTime( finishTime );
q = newQueryIfNull( q );
q.setResolution( resolution );
代码示例来源:origin: apache/usergrid
query.setLimit(Query.MAX_LIMIT); // always fetch our MAX limit to reduce # of IO hops
if (query.getCollection() != null) {
query.setQl("select *");
ref.getType(), query.getCollection());
query.setLimit(Query.MAX_LIMIT);
query.setResultsLevel(Query.Level.IDS);
Query devicesQuery = new Query();
devicesQuery.setCollection("devices");
devicesQuery.setResultsLevel(Query.Level.CORE_PROPERTIES);
return entityManager.searchCollection(ref, devicesQuery.getCollection(), devicesQuery);
return entityManager.searchCollection(ref, query.getCollection(), query);
ref.getType(), query.getCollection());
query.setQl("select *"); // make sure this results in graph traversal
return entityManager.searchTargetEntities(ref, query);
代码示例来源:origin: apache/usergrid
/**
* Create a query instance from the QL. If the string is null, return an empty query
* @param ql
* @return
*/
public static Query fromQLNullSafe(final String ql){
final Query query = fromQL(ql);
if(query != null){
return query;
}
return new Query();
}
代码示例来源:origin: apache/usergrid
public static Query fromQL( String ql ) throws QueryParseException {
if ( StringUtils.isEmpty(ql) ) {
return null;
}
Query query = new Query( );
query.setQl( ql );
return query;
}
public static Query all( ){
代码示例来源:origin: apache/usergrid
@Override
public Results getTargetEntities( String connectionType, String connectedEntityType, Level level )
throws Exception {
//until this is refactored properly, we will delegate to a search by query
Results raw = null;
Preconditions.checkNotNull( connectionType, "connectionType cannot be null" );
Query query = new Query();
query.setConnectionType( connectionType );
query.setEntityType( connectedEntityType );
query.setResultsLevel( level );
return searchTargetEntities( query );
}
代码示例来源:origin: apache/usergrid
Query query = Query.fromQL( queryString );
query.setLimit( PAGE_SIZE );
query.setCursor( results.getCursor() );
代码示例来源:origin: apache/usergrid
@Override
public Results getFileImports(final UUID applicationId, final UUID importId,
@Nullable final String ql, @Nullable final String cursor) {
Preconditions.checkNotNull(applicationId, "applicationId must be specified");
Preconditions.checkNotNull(importId, "importId must be specified");
try {
final EntityManager rootEm = emf.getEntityManager(emf.getManagementAppId());
final Import importEntity = getImport(applicationId, importId);
Query query = Query.fromQLNullSafe(ql);
query.setCursor(cursor);
query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
query.setResultsLevel(Level.ALL_PROPERTIES);
//set our entity type
query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class));
return rootEm.searchTargetEntities(importEntity, query);
} catch (Exception e) {
throw new RuntimeException("Unable to get import entity", e);
}
}
代码示例来源:origin: apache/usergrid
query = new Query();
query.setCollection( collectionName );
query.setEntityType( collection.getType() );
final Query toExecute = adjustQuery( query );
final Optional<String> queryString = query.isGraphSearch()? Optional.<String>absent(): query.getQl();
final Id ownerId = headEntity.asId();
final boolean analyzeOnly = query.getAnalyzeOnly();
final boolean returnQuery = query.getReturnQuery();
if(query.getLevel() == Level.IDS ){
return new IdQueryExecutor( toExecute.getCursor() ) {
@Override
protected Observable<ResultsPage<Id>> buildNewResultsPage(
return new EntityQueryExecutor( toExecute.getCursor() ) {
@Override
protected Observable<ResultsPage<org.apache.usergrid.persistence.model.entity.Entity>> buildNewResultsPage(
代码示例来源:origin: apache/usergrid
private int getConnectionCount(final Import importRoot) {
try {
EntityManager rootEM = emf.getEntityManager(emf.getManagementAppId());
Query query = Query.fromQL("select *");
query.setEntityType("file_import");
query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
query.setLimit(MAX_FILE_IMPORTS);
// TODO, this won't work with more than 100 files
Results entities = rootEM.searchTargetEntities(importRoot, query);
return entities.size();
// see ImportConnectsTest()
// Results entities = rootEM.getTargetEntities(
// importRoot, "includes", null, Level.ALL_PROPERTIES );
// PagingResultsIterator itr = new PagingResultsIterator( entities );
// int count = 0;
// while ( itr.hasNext() ) {
// itr.next();
// count++;
// }
// return count;
} catch (Exception e) {
logger.error("application doesn't exist within the current context");
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/usergrid
query = new Query();
query = Query.fromQL( ( String ) config.get( "query" ) );
query.setLimit( MAX_ENTITY_FETCH );
query.setResultsLevel( Level.ALL_PROPERTIES );
query.setCollection( collectionName );
代码示例来源:origin: apache/usergrid
if ( !query.hasQueryPredicates() && ( query.getEntityType() != null ) && query
.containsNameOrEmailIdentifiersOnly() ) {
String name = query.getSingleNameOrEmailIdentifier();
String nameProperty = Schema.getDefaultSchema().aliasProperty( query.getEntityType() );
if ( nameProperty == null ) {
nameProperty = "name";
Entity entity = em.getUniqueEntityFromAlias( query.getEntityType(), name, false);
if ( entity == null ) {
return null;
int count = query.getLimit();
Level level = Level.REFS;
query.setLimit( query.getLimit( count ) );
query.setResultsLevel( level );
query.setConnecting(true);
if ( query.hasQueryPredicates() ) {
if (logger.isTraceEnabled()) {
logger.trace("Attempted query of backwards connections");
代码示例来源:origin: apache/usergrid
for (PathToken pathToken : pathTokens) {
String collection = pathToken.getCollection();
Query query = new Query();
if(pathToken.getQl() != null){
query.setQl(pathToken.getQl());
query.setQl("select * where username ='"+pathToken.getIdentifier().getName()+"'");
}else{
query.addIdentifier(pathToken.getIdentifier());
query.setLimit(100);
query.setCollection(collection);
final Query usersQuery = new Query();
usersQuery.setQl("select *");
usersQuery.setCollection("users");
usersQuery.setLimit(100);
final Query devicesQuery = new Query();
devicesQuery.setQl("select *");
devicesQuery.setCollection("devices");
devicesQuery.setLimit(100);
final Query devicesQuery = new Query();
devicesQuery.setQl("select *");
devicesQuery.setCollection("devices");
devicesQuery.setLimit(100);
代码示例来源:origin: apache/usergrid
/**
* Create a query from a property equals
* @param propertyName
* @param value
* @return
*/
public static Query fromEquals(final String propertyName, final String value){
return fromQL( propertyName + " = '" + value + "'" );
}
代码示例来源:origin: apache/usergrid
Query query = new Query();
query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class));
query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
query.setLimit(MAX_FILE_IMPORTS);
代码示例来源:origin: apache/usergrid
long now = System.currentTimeMillis();
notifierHashMap = new HashMap<>();
Query query = new Query();
query.setCollection("notifiers");
query.setLimit(100);
PathQuery<Notifier> pathQuery = new PathQuery<>(
new SimpleEntityRef(em.getApplicationRef()),
代码示例来源:origin: apache/usergrid
Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 13" );
userQuery.setCollection( "users" );
userQuery.setLimit( pageSize );
int expectedUserQuerySize = 12;
Query deviceQuery = Query.fromQL( "select * where index >= 2 " );
deviceQuery.setCollection( "devices" );
deviceQuery.setLimit( pageSize );
int expectedDeviceQuerySize = 3;
代码示例来源:origin: apache/usergrid
public static Query fromUUID( UUID uuid ) {
Query q = new Query();
q.addIdentifier( Identifier.fromUUID( uuid ) );
return q;
}
代码示例来源:origin: apache/usergrid
query = new Query();
query.setConnectionType( cType );
query.setEntityType( eType );
if ( id != null ) {
query.addIdentifier( Identifier.fromUUID( id ) );
query.addIdentifier( Identifier.from( name ) );
代码示例来源:origin: apache/usergrid
Query query = new Query();
query.setLimit( 50 );
query = new Query();
assertEquals( query.getLimit(), r.size() );
query = new Query();
query.setCursor( r.getCursor() );
内容来源于网络,如有侵权,请联系作者删除!