use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.
the class ReleaseStatsDaoImpl method findReleaseInfoDataSources.
@Override
public List<ReleaseContentsDataSource> findReleaseInfoDataSources() {
Map<String, Object> params = new HashMap<>();
params.put("cvNames", ReleaseDataSources.getDistinctCvNamesExcept(ReleaseDataSources.PeptideAtlas));
List<ReleaseContentsDataSource> ds = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("release-contents"), params, new ReleaseInfoRowMapper(null));
ds.addAll(new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("release-contents-peptide-atlas"), params, new ReleaseInfoRowMapper(ReleaseDataSources.PeptideAtlas)));
ds.sort((ds1, ds2) -> ds1.getSource().compareToIgnoreCase(ds2.getSource()));
return ds;
}
use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.
the class TerminologyDaoImpl method findTerminologyByOntology.
public List<CvTerm> findTerminologyByOntology(String ontology) {
SqlParameterSource params = new MapSqlParameterSource("ontology", ontology);
List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-ontology"), params, new DbTermRowMapper());
return terms;
}
use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.
the class TerminologyDaoImpl method findTerminologyByAccessions.
@Override
public List<CvTerm> findTerminologyByAccessions(Set<String> accessions) {
SqlParameterSource params = new MapSqlParameterSource("accessions", accessions);
List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-acs"), params, new DbTermRowMapper());
return terms;
}
use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.
the class StatementDaoImpl method findNormalStatements.
@Override
public List<Statement> findNormalStatements(AnnotationType type, String nextprotAccession) {
Map<String, Object> params = new HashMap<>();
params.put("accession", nextprotAccession);
String sql = getSQL(type, "statements-by-entry-accession");
return new NamedParameterJdbcTemplate(dsLocator.getStatementsDataSource()).query(sql, params, new StatementMapper());
}
use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.
the class StatementDaoImpl method findStatementsByAnnotIsoIds.
@Override
public List<Statement> findStatementsByAnnotIsoIds(AnnotationType type, List<String> idList) {
List<Statement> statements = new ArrayList<>();
if (idList == null || idList.isEmpty())
return statements;
int limit = 1000;
// Make a distinct list, could use set as well?
List<String> ids = idList.parallelStream().distinct().collect(Collectors.toList());
for (int i = 0; i < ids.size(); i += limit) {
int toLimit = (i + limit > ids.size()) ? ids.size() : i + limit;
Map<String, Object> params = new HashMap<String, Object>();
params.put("ids", ids.subList(i, toLimit));
String sql = getSQL(type, "statements-by-annotation-id");
List<Statement> statementsAux = new NamedParameterJdbcTemplate(dsLocator.getStatementsDataSource()).query(sql, params, new StatementMapper());
statements.addAll(statementsAux);
}
return statements;
}
Aggregations