@Test public void testGet() { LOG.info( "\n===NoteDaoTest.testGet===\n" ); Note note = ESSuiteTest.noteDao.get( ESSuiteTest.COMMIT_ID_1, 1 ); assertEquals( ESSuiteTest.NOTE, note.getText() ); }
public Note get( String commitId, int runNumber ) { BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery() .must( termQuery( "commitId", commitId.toLowerCase() ) ) .must( termQuery( "runNumber", runNumber ) ); SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( queryBuilder ) .execute() .actionGet(); SearchHit hits[] = response.getHits().getHits(); if ( hits.length == 0 ) { return null; } Map<String, Object> json = hits[ 0 ].getSource(); return new Note( Util.getString( json, "moduleId" ), Util.getInt( json, "runNumber" ), Util.getString( json, "text" ) ); }
NoteDao extends Dao { public Note get( String commitId, int runNumber ) { BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery() .must( termQuery( "commitId", commitId.toLowerCase() ) ) .must( termQuery( "runNumber", runNumber ) ); SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( queryBuilder ) .execute() .actionGet(); SearchHit hits[] = response.getHits().getHits(); if ( hits.length == 0 ) { return null; } Map<String, Object> json = hits[ 0 ].getSource(); return new Note( Util.getString( json, "moduleId" ), Util.getInt( json, "runNumber" ), Util.getString( json, "text" ) ); } }
NoteDao extends Dao { public Note get( String commitId, int runNumber ) { BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery() .must( termQuery( "commitId", commitId.toLowerCase() ) ) .must( termQuery( "runNumber", runNumber ) ); SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( queryBuilder ) .execute() .actionGet(); SearchHit hits[] = response.getHits().getHits(); if ( hits.length == 0 ) { return null; } Map<String, Object> json = hits[ 0 ].getSource(); return new Note( Util.getString( json, "moduleId" ), Util.getInt( json, "runNumber" ), Util.getString( json, "text" ) ); } @Inject  NoteDao( IElasticSearchClient elasticSearchClient ); }
NoteDao extends Dao { public Note get( String commitId, int runNumber ) { BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery() .must( termQuery( "commitId", commitId.toLowerCase() ) ) .must( termQuery( "runNumber", runNumber ) ); SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( queryBuilder ) .execute() .actionGet(); SearchHit hits[] = response.getHits().getHits(); if ( hits.length == 0 ) { return null; } Map<String, Object> json = hits[ 0 ].getSource(); return new Note( Util.getString( json, "moduleId" ), Util.getInt( json, "runNumber" ), Util.getString( json, "text" ) ); } @Inject  NoteDao( IElasticSearchClient elasticSearchClient ); boolean save( Note note ); Note get( String commitId, int runNumber ); }
NoteDao extends Dao { public Note get( String commitId, int runNumber ) { BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery() .must( termQuery( "commitId", commitId.toLowerCase() ) ) .must( termQuery( "runNumber", runNumber ) ); SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( queryBuilder ) .execute() .actionGet(); SearchHit hits[] = response.getHits().getHits(); if ( hits.length == 0 ) { return null; } Map<String, Object> json = hits[ 0 ].getSource(); return new Note( Util.getString( json, "moduleId" ), Util.getInt( json, "runNumber" ), Util.getString( json, "text" ) ); } @Inject  NoteDao( IElasticSearchClient elasticSearchClient ); boolean save( Note note ); Note get( String commitId, int runNumber ); static final String DAO_INDEX_KEY; static final String DAO_TYPE_KEY; }