forked from Luke-Sikina/picsure-search-refinement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchResultRowMapper.java
38 lines (28 loc) · 1.31 KB
/
SearchResultRowMapper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package edu.harvard.dbmi.avillach.dictionary.legacysearch;
import edu.harvard.dbmi.avillach.dictionary.concept.model.ConceptType;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.Result;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import java.sql.ResultSet;
import java.sql.SQLException;
@Component
public class SearchResultRowMapper implements RowMapper<SearchResult> {
private final MetadataResultSetUtil metadataResultSetUtil;
@Autowired
public SearchResultRowMapper(MetadataResultSetUtil metadataResultSetUtil) {
this.metadataResultSetUtil = metadataResultSetUtil;
}
@Override
public SearchResult mapRow(ResultSet rs, int rowNum) throws SQLException {
return mapSearchResults(rs);
}
private SearchResult mapSearchResults(ResultSet rs) throws SQLException {
Result result = switch (ConceptType.toConcept(rs.getString("conceptType"))) {
case Categorical -> this.metadataResultSetUtil.mapCategoricalMetadata(rs);
case Continuous -> this.metadataResultSetUtil.mapContinuousMetadata(rs);
};
return new SearchResult(result);
}
}