@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 ); }
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 );
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);
@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 ); }
@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); } }
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(
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); } }
query = new Query(); query = Query.fromQL( ( String ) config.get( "query" ) ); query.setLimit( MAX_ENTITY_FETCH ); query.setResultsLevel( Level.ALL_PROPERTIES ); query.setCollection( collectionName );
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");
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);
/** * 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 + "'" ); }
Query query = new Query(); query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class)); query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION); query.setLimit(MAX_FILE_IMPORTS);
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()),
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;
public static Query fromUUID( UUID uuid ) { Query q = new Query(); q.addIdentifier( Identifier.fromUUID( uuid ) ); return q; }
query = new Query(); query.setConnectionType( cType ); query.setEntityType( eType ); if ( id != null ) { query.addIdentifier( Identifier.fromUUID( id ) ); query.addIdentifier( Identifier.from( name ) );