25
25
import org .apache .commons .logging .LogFactory ;
26
26
import org .springframework .beans .factory .annotation .Autowired ;
27
27
import org .springframework .stereotype .Component ;
28
+ import ubic .gemma .core .search .SearchException ;
28
29
import ubic .gemma .core .search .SearchResult ;
29
30
import ubic .gemma .core .search .SearchResultDisplayObject ;
30
31
import ubic .gemma .core .search .SearchService ;
43
44
import ubic .gemma .persistence .util .EntityUtils ;
44
45
45
46
import java .util .*;
47
+ import java .util .stream .Collectors ;
46
48
47
49
/**
48
50
* Handles searching for experiments and experiment sets
@@ -79,10 +81,10 @@ public ExpressionExperimentSearchServiceImpl( ExpressionExperimentSetService exp
79
81
}
80
82
81
83
@ Override
82
- public Collection <ExpressionExperimentValueObject > searchExpressionExperiments ( String query ) {
84
+ public Collection <ExpressionExperimentValueObject > searchExpressionExperiments ( String query ) throws SearchException {
83
85
84
86
SearchSettings settings = SearchSettings .expressionExperimentSearch ( query );
85
- List <SearchResult > experimentSearchResults = searchService .search ( settings ).get ( ExpressionExperiment .class );
87
+ List <SearchResult <?> > experimentSearchResults = searchService .search ( settings ).get ( ExpressionExperiment .class );
86
88
87
89
if ( experimentSearchResults == null || experimentSearchResults .isEmpty () ) {
88
90
ExpressionExperimentSearchServiceImpl .log .info ( "No experiments for search: " + query );
@@ -91,15 +93,16 @@ public Collection<ExpressionExperimentValueObject> searchExpressionExperiments(
91
93
92
94
ExpressionExperimentSearchServiceImpl .log
93
95
.info ( "Experiment search: " + query + ", " + experimentSearchResults .size () + " found" );
96
+ List <Long > eeIds = experimentSearchResults .stream ().map ( SearchResult ::getResultId ).collect ( Collectors .toList () );
94
97
Collection <ExpressionExperimentValueObject > experimentValueObjects = expressionExperimentService
95
- .loadValueObjectsByIds ( EntityUtils . getIds ( experimentSearchResults ) , true );
98
+ .loadValueObjectsByIds ( eeIds , true );
96
99
ExpressionExperimentSearchServiceImpl .log
97
100
.info ( "Experiment search: " + experimentValueObjects .size () + " value objects returned." );
98
101
return experimentValueObjects ;
99
102
}
100
103
101
104
@ Override
102
- public Collection <ExpressionExperimentValueObject > searchExpressionExperiments ( List <String > query ) {
105
+ public Collection <ExpressionExperimentValueObject > searchExpressionExperiments ( List <String > query ) throws SearchException {
103
106
104
107
Set <ExpressionExperimentValueObject > all = new HashSet <>();
105
108
Set <ExpressionExperimentValueObject > prev = null ;
@@ -119,7 +122,7 @@ public Collection<ExpressionExperimentValueObject> searchExpressionExperiments(
119
122
}
120
123
121
124
@ Override
122
- public List <SearchResultDisplayObject > searchExperimentsAndExperimentGroups ( String query , Long taxonId ) {
125
+ public List <SearchResultDisplayObject > searchExperimentsAndExperimentGroups ( String query , Long taxonId ) throws SearchException {
123
126
124
127
List <SearchResultDisplayObject > displayResults = new LinkedList <>();
125
128
@@ -129,7 +132,7 @@ public List<SearchResultDisplayObject> searchExperimentsAndExperimentGroups( Str
129
132
return this .searchExperimentsAndExperimentGroupBlankQuery ( taxonId );
130
133
}
131
134
132
- Map <Class <?>, List <SearchResult >> results = this .initialSearch ( query , taxonId );
135
+ Map <Class <?>, List <SearchResult <?> >> results = this .initialSearch ( query , taxonId );
133
136
134
137
List <SearchResultDisplayObject > experimentSets = this .getExpressionExperimentSetResults ( results );
135
138
List <SearchResultDisplayObject > experiments = this .getExpressionExperimentResults ( results );
@@ -250,9 +253,9 @@ public List<SearchResultDisplayObject> getAllTaxonExperimentGroup( Long taxonId
250
253
}
251
254
252
255
private List <SearchResultDisplayObject > getExpressionExperimentResults (
253
- Map <Class <?>, List <SearchResult >> results ) {
256
+ Map <Class <?>, List <SearchResult <?> >> results ) {
254
257
// get all expressionExperiment results and convert result object into a value object
255
- List <SearchResult > srEEs = results .get ( ExpressionExperiment .class );
258
+ List <SearchResult <?> > srEEs = results .get ( ExpressionExperiment .class );
256
259
if ( srEEs == null ) {
257
260
srEEs = new ArrayList <>();
258
261
}
@@ -271,7 +274,7 @@ private List<SearchResultDisplayObject> getExpressionExperimentResults(
271
274
}
272
275
273
276
private List <SearchResultDisplayObject > getExpressionExperimentSetResults (
274
- Map <Class <?>, List <SearchResult >> results ) {
277
+ Map <Class <?>, List <SearchResult <?> >> results ) {
275
278
List <SearchResultDisplayObject > experimentSets = new ArrayList <>();
276
279
277
280
if ( results .get ( ExpressionExperimentSet .class ) != null ) {
@@ -291,7 +294,7 @@ private List<SearchResultDisplayObject> getExpressionExperimentSetResults(
291
294
return experimentSets ;
292
295
}
293
296
294
- private Map <Class <?>, List <SearchResult >> initialSearch ( String query , Long taxonId ) {
297
+ private Map <Class <?>, List <SearchResult <?>>> initialSearch ( String query , Long taxonId ) throws SearchException {
295
298
SearchSettings settings = SearchSettings .builder ()
296
299
.query ( query )
297
300
.resultType ( ExpressionExperiment .class )
0 commit comments