Search in sources :

Example 16 with NamedParameterJdbcTemplate

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;
}
Also used : ReleaseContentsDataSource(org.nextprot.api.core.domain.release.ReleaseContentsDataSource) HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 17 with NamedParameterJdbcTemplate

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CvTerm(org.nextprot.api.core.domain.CvTerm) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 18 with NamedParameterJdbcTemplate

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CvTerm(org.nextprot.api.core.domain.CvTerm) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 19 with NamedParameterJdbcTemplate

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());
}
Also used : HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 20 with NamedParameterJdbcTemplate

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;
}
Also used : HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) Statement(org.nextprot.commons.statements.Statement) ArrayList(java.util.ArrayList)

Aggregations

NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)119 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)66 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)42 HashMap (java.util.HashMap)30 ResultSet (java.sql.ResultSet)16 SQLException (java.sql.SQLException)16 DbXref (org.nextprot.api.core.domain.DbXref)8 NextProtException (org.nextprot.api.commons.exception.NextProtException)7 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)7 ArrayList (java.util.ArrayList)5 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)5 List (java.util.List)4 Map (java.util.Map)4 CvTerm (org.nextprot.api.core.domain.CvTerm)4 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)3 NotSupportException (com.kyj.fx.voeditor.visual.exceptions.NotSupportException)3 DataSource (javax.sql.DataSource)3 UserProteinList (org.nextprot.api.user.domain.UserProteinList)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 Date (java.util.Date)2