public Query withCursor( String cursor ) { setCursor( cursor ); return this; }
@Override public Results getImports(final UUID applicationId, @Nullable final String ql, @Nullable final String cursor) { Preconditions.checkNotNull(applicationId, "applicationId must be specified"); try { final EntityManager rootEm = emf.getEntityManager(emf.getManagementAppId()); final Entity appInfo = getApplicationInfoEntity(rootEm, applicationId); Query query = Query.fromQLNullSafe(ql); query.setCursor(cursor); //set our entity type query.setEntityType(Schema.getDefaultSchema().getEntityType(Import.class)); return rootEm.searchCollection(appInfo, APP_IMPORT_CONNECTION, query); } catch (Exception e) { throw new RuntimeException("Unable to get import entity", e); } }
@Override public Results getFailedImportEntities(final UUID applicationId, final UUID importId, final UUID fileImportId, @Nullable final String ql, @Nullable final String cursor) { Preconditions.checkNotNull(applicationId, "applicationId must be specified"); Preconditions.checkNotNull(importId, "importId must be specified"); Preconditions.checkNotNull(fileImportId, "fileImportId must be specified"); try { final EntityManager rootEm = emf.getEntityManager(emf.getManagementAppId()); final FileImport importEntity = getFileImport(applicationId, importId, fileImportId); Query query = Query.fromQLNullSafe(ql); query.setCursor(cursor); query.setConnectionType(FileImportTracker.ERRORS_CONNECTION_NAME); query.setResultsLevel(Level.ALL_PROPERTIES); //set our entity type query.setEntityType(Schema.getDefaultSchema().getEntityType(FailedImportEntity.class)); return rootEm.searchTargetEntities(importEntity, query); } catch (Exception e) { throw new RuntimeException("Unable to get import entity", e); } }
@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.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor( results.getCursor() );
query.setCursor(r.getCursor());
query.setCursor( r.getCursor() );
query.setCursor( r.getCursor() );
query.setCursor( r.getCursor() );
private int countEntities( EntityManager em, String collectionName, int expectedEntities) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { count += results.size(); if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } assertEquals( "Did not get expected entities", expectedEntities, count ); return count; }
private int countEntities( EntityManager em, String collectionName, int expectedEntities) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { count += results.size(); if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } assertEquals( "Did not get expected entities", expectedEntities, count ); return count; }
query.setCursor(results.getCursor());
private int readData( EntityManager em, String collectionName, int expectedEntities, int expectedConnections ) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { for ( Entity e : results.getEntities() ) { assertEquals( 2000, e.getProperty( "key2" ) ); Results catResults = em.searchTargetEntities( e, Query.fromQL( "select *" ).setConnectionType( "herds" ) ); assertEquals( expectedConnections, catResults.size() ); if ( count % 100 == 0 ) { logger.info( "read {} entities", count ); } count++; } if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } return count; }
query.setCursor(result.getCursor()); result = app.testRequest(ServiceAction.GET,1,"users","conn-user1","connecting","likes",query); String enityName2 = result.getEntity().getProperty("email").toString(); query.setCursor(result.getCursor()); result = app.testRequest(ServiceAction.GET,0,"users","conn-user1","connecting","likes",query);