@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 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); } }
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); } }
/** * (non-Javadoc) @see org.apache.usergrid.persistence.query.SingleOrderByMaxLimitCollection * .ConnectionHelper#getResults * (org.apache.usergrid.persistence.Query) */ @Override public Results getResults( Query query ) throws Exception { query.setConnectionType( CONNECTION ); // don't set it on purpose query.setEntityType( null ); return app.getEntityManager().searchTargetEntities(rootEntity, query); } }
query.setEntityType(Schema.getDefaultSchema().getEntityType(FileImport.class)); query.setConnectionType(IMPORT_FILE_INCLUDES_CONNECTION); query.setLimit(MAX_FILE_IMPORTS);
@Override public Results getResults( Query query ) throws Exception { app.waitForQueueDrainAndRefreshIndex(); query.setConnectionType( CONNECTION ); query.setEntityType( "test" ); return app.getEntityManager().searchTargetEntities(rootEntity, query); } }
q.setEntityType( type );
private int getConnectionCountViaSearch( final Import importRoot ) { try { EntityManager emMgmtApp = setup.getEmf() .getEntityManager(setup.getEmf().getManagementAppId() ); Query query = Query.fromQL("select *"); query.setEntityType("file_import"); query.setConnectionType("includes"); query.setLimit(10000); Results entities = emMgmtApp.searchTargetEntities(importRoot, query); return entities.size(); // 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.setEntityType( collection.getType() ); final Query toExecute = adjustQuery( query ); final Optional<String> queryString = query.isGraphSearch()? Optional.<String>absent(): query.getQl();
query.setEntityType( "user" );
query.setEntityType( eType ); if ( id != null ) { query.addIdentifier( Identifier.fromUUID( id ) );
query.setConnectionType( "likes" ); query.setEntityType( "user" );