org.apache.usergrid.persistence.Query类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中org.apache.usergrid.persistence.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query

Query介绍

暂无

代码示例

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public ServiceResults putItemsByQuery( ServiceContext context, Query query ) throws Exception {
  3. checkPermissionsForCollection( context );
  4. if ( context.moreParameters() ) {
  5. return getItemsByQuery( context, query );
  6. }
  7. query = new Query( query );
  8. query.setResultsLevel( Level.ALL_PROPERTIES );
  9. query.setLimit( 1000 );
  10. if ( !query.isReversedSet() ) {
  11. query.setReversed( isCollectionReversed( context ) );
  12. }
  13. Results r = em.searchCollection( context.getOwner(), context.getCollectionName(), query );
  14. if ( r.isEmpty() ) {
  15. throw new ServiceResourceNotFoundException( context );
  16. }
  17. updateEntities( context, r );
  18. return new ServiceResults( this, context, Type.COLLECTION, r, null, null );
  19. }

代码示例来源:origin: apache/usergrid

  1. q = Query.fromQL( decode( ql ) );
  2. q = newQueryIfNull( q );
  3. q.setEntityType( type );
  4. q = newQueryIfNull( q );
  5. q.setConnectionType( connection );
  6. q = newQueryIfNull( q );
  7. q.setPermissions( permissions );
  8. q = newQueryIfNull( q );
  9. q.setStartResult( start );
  10. q = newQueryIfNull( q );
  11. q.setCursor( cursor );
  12. q = newQueryIfNull( q );
  13. q.setLimit( limit );
  14. q = newQueryIfNull( q );
  15. q.setStartTime( startTime );
  16. q = newQueryIfNull( q );
  17. q.setFinishTime( finishTime );
  18. q = newQueryIfNull( q );
  19. q.setResolution( resolution );

代码示例来源:origin: apache/usergrid

  1. query.setLimit(Query.MAX_LIMIT); // always fetch our MAX limit to reduce # of IO hops
  2. if (query.getCollection() != null) {
  3. query.setQl("select *");
  4. ref.getType(), query.getCollection());
  5. query.setLimit(Query.MAX_LIMIT);
  6. query.setResultsLevel(Query.Level.IDS);
  7. Query devicesQuery = new Query();
  8. devicesQuery.setCollection("devices");
  9. devicesQuery.setResultsLevel(Query.Level.CORE_PROPERTIES);
  10. return entityManager.searchCollection(ref, devicesQuery.getCollection(), devicesQuery);
  11. return entityManager.searchCollection(ref, query.getCollection(), query);
  12. ref.getType(), query.getCollection());
  13. query.setQl("select *"); // make sure this results in graph traversal
  14. return entityManager.searchTargetEntities(ref, query);

代码示例来源:origin: apache/usergrid

  1. /**
  2. * Create a query instance from the QL. If the string is null, return an empty query
  3. * @param ql
  4. * @return
  5. */
  6. public static Query fromQLNullSafe(final String ql){
  7. final Query query = fromQL(ql);
  8. if(query != null){
  9. return query;
  10. }
  11. return new Query();
  12. }

代码示例来源:origin: apache/usergrid

  1. public static Query fromQL( String ql ) throws QueryParseException {
  2. if ( StringUtils.isEmpty(ql) ) {
  3. return null;
  4. }
  5. Query query = new Query( );
  6. query.setQl( ql );
  7. return query;
  8. }
  9. public static Query all( ){

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public Results getTargetEntities( String connectionType, String connectedEntityType, Level level )
  3. throws Exception {
  4. //until this is refactored properly, we will delegate to a search by query
  5. Results raw = null;
  6. Preconditions.checkNotNull( connectionType, "connectionType cannot be null" );
  7. Query query = new Query();
  8. query.setConnectionType( connectionType );
  9. query.setEntityType( connectedEntityType );
  10. query.setResultsLevel( level );
  11. return searchTargetEntities( query );
  12. }

代码示例来源:origin: apache/usergrid

  1. Query query = Query.fromQL( queryString );
  2. query.setLimit( PAGE_SIZE );
  3. query.setCursor( results.getCursor() );

代码示例来源:origin: apache/usergrid

  1. @Override
  2. public Results getFileImports(final UUID applicationId, final UUID importId,
  3. @Nullable final String ql, @Nullable final String cursor) {
  4. Preconditions.checkNotNull(applicationId, "applicationId must be specified");
  5. Preconditions.checkNotNull(importId, "importId must be specified");
  6. try {
  7. final EntityManager rootEm = emf.getEntityManager(emf.getManagementAppId());
  8. final Import importEntity = getImport(applicationId, importId);
  9. Query query = Query.fromQLNullSafe(ql);
  10. query.setCursor(cursor);
  11. query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
  12. query.setResultsLevel(Level.ALL_PROPERTIES);
  13. //set our entity type
  14. query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class));
  15. return rootEm.searchTargetEntities(importEntity, query);
  16. } catch (Exception e) {
  17. throw new RuntimeException("Unable to get import entity", e);
  18. }
  19. }

代码示例来源:origin: apache/usergrid

  1. query = new Query();
  2. query.setCollection( collectionName );
  3. query.setEntityType( collection.getType() );
  4. final Query toExecute = adjustQuery( query );
  5. final Optional<String> queryString = query.isGraphSearch()? Optional.<String>absent(): query.getQl();
  6. final Id ownerId = headEntity.asId();
  7. final boolean analyzeOnly = query.getAnalyzeOnly();
  8. final boolean returnQuery = query.getReturnQuery();
  9. if(query.getLevel() == Level.IDS ){
  10. return new IdQueryExecutor( toExecute.getCursor() ) {
  11. @Override
  12. protected Observable<ResultsPage<Id>> buildNewResultsPage(
  13. return new EntityQueryExecutor( toExecute.getCursor() ) {
  14. @Override
  15. protected Observable<ResultsPage<org.apache.usergrid.persistence.model.entity.Entity>> buildNewResultsPage(

代码示例来源:origin: apache/usergrid

  1. private int getConnectionCount(final Import importRoot) {
  2. try {
  3. EntityManager rootEM = emf.getEntityManager(emf.getManagementAppId());
  4. Query query = Query.fromQL("select *");
  5. query.setEntityType("file_import");
  6. query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
  7. query.setLimit(MAX_FILE_IMPORTS);
  8. // TODO, this won't work with more than 100 files
  9. Results entities = rootEM.searchTargetEntities(importRoot, query);
  10. return entities.size();
  11. // see ImportConnectsTest()
  12. // Results entities = rootEM.getTargetEntities(
  13. // importRoot, "includes", null, Level.ALL_PROPERTIES );
  14. // PagingResultsIterator itr = new PagingResultsIterator( entities );
  15. // int count = 0;
  16. // while ( itr.hasNext() ) {
  17. // itr.next();
  18. // count++;
  19. // }
  20. // return count;
  21. } catch (Exception e) {
  22. logger.error("application doesn't exist within the current context");
  23. throw new RuntimeException(e);
  24. }
  25. }

代码示例来源:origin: apache/usergrid

  1. query = new Query();
  2. query = Query.fromQL( ( String ) config.get( "query" ) );
  3. query.setLimit( MAX_ENTITY_FETCH );
  4. query.setResultsLevel( Level.ALL_PROPERTIES );
  5. query.setCollection( collectionName );

代码示例来源:origin: apache/usergrid

  1. if ( !query.hasQueryPredicates() && ( query.getEntityType() != null ) && query
  2. .containsNameOrEmailIdentifiersOnly() ) {
  3. String name = query.getSingleNameOrEmailIdentifier();
  4. String nameProperty = Schema.getDefaultSchema().aliasProperty( query.getEntityType() );
  5. if ( nameProperty == null ) {
  6. nameProperty = "name";
  7. Entity entity = em.getUniqueEntityFromAlias( query.getEntityType(), name, false);
  8. if ( entity == null ) {
  9. return null;
  10. int count = query.getLimit();
  11. Level level = Level.REFS;
  12. query.setLimit( query.getLimit( count ) );
  13. query.setResultsLevel( level );
  14. query.setConnecting(true);
  15. if ( query.hasQueryPredicates() ) {
  16. if (logger.isTraceEnabled()) {
  17. logger.trace("Attempted query of backwards connections");

代码示例来源:origin: apache/usergrid

  1. for (PathToken pathToken : pathTokens) {
  2. String collection = pathToken.getCollection();
  3. Query query = new Query();
  4. if(pathToken.getQl() != null){
  5. query.setQl(pathToken.getQl());
  6. query.setQl("select * where username ='"+pathToken.getIdentifier().getName()+"'");
  7. }else{
  8. query.addIdentifier(pathToken.getIdentifier());
  9. query.setLimit(100);
  10. query.setCollection(collection);
  11. final Query usersQuery = new Query();
  12. usersQuery.setQl("select *");
  13. usersQuery.setCollection("users");
  14. usersQuery.setLimit(100);
  15. final Query devicesQuery = new Query();
  16. devicesQuery.setQl("select *");
  17. devicesQuery.setCollection("devices");
  18. devicesQuery.setLimit(100);
  19. final Query devicesQuery = new Query();
  20. devicesQuery.setQl("select *");
  21. devicesQuery.setCollection("devices");
  22. devicesQuery.setLimit(100);

代码示例来源:origin: apache/usergrid

  1. /**
  2. * Create a query from a property equals
  3. * @param propertyName
  4. * @param value
  5. * @return
  6. */
  7. public static Query fromEquals(final String propertyName, final String value){
  8. return fromQL( propertyName + " = '" + value + "'" );
  9. }

代码示例来源:origin: apache/usergrid

  1. Query query = new Query();
  2. query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class));
  3. query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION);
  4. query.setLimit(MAX_FILE_IMPORTS);

代码示例来源:origin: apache/usergrid

  1. long now = System.currentTimeMillis();
  2. notifierHashMap = new HashMap<>();
  3. Query query = new Query();
  4. query.setCollection("notifiers");
  5. query.setLimit(100);
  6. PathQuery<Notifier> pathQuery = new PathQuery<>(
  7. new SimpleEntityRef(em.getApplicationRef()),

代码示例来源:origin: apache/usergrid

  1. Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 13" );
  2. userQuery.setCollection( "users" );
  3. userQuery.setLimit( pageSize );
  4. int expectedUserQuerySize = 12;
  5. Query deviceQuery = Query.fromQL( "select * where index >= 2 " );
  6. deviceQuery.setCollection( "devices" );
  7. deviceQuery.setLimit( pageSize );
  8. int expectedDeviceQuerySize = 3;

代码示例来源:origin: apache/usergrid

  1. public static Query fromUUID( UUID uuid ) {
  2. Query q = new Query();
  3. q.addIdentifier( Identifier.fromUUID( uuid ) );
  4. return q;
  5. }

代码示例来源:origin: apache/usergrid

  1. query = new Query();
  2. query.setConnectionType( cType );
  3. query.setEntityType( eType );
  4. if ( id != null ) {
  5. query.addIdentifier( Identifier.fromUUID( id ) );
  6. query.addIdentifier( Identifier.from( name ) );

代码示例来源:origin: apache/usergrid

  1. Query query = new Query();
  2. query.setLimit( 50 );
  3. query = new Query();
  4. assertEquals( query.getLimit(), r.size() );
  5. query = new Query();
  6. query.setCursor( r.getCursor() );

相关文章