Search in sources :

Example 31 with NamedParameterJdbcTemplate

use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findDbXrefsProperties.

@Override
public List<DbXrefProperty> findDbXrefsProperties(String entryName, List<Long> resourceIds) {
    List<DbXrefProperty> result = new ArrayList<>();
    // we must split the query into multiple queries otherwise we get an SQL error:
    // the number of parameters (list of resource id) cannot exceed 32767 and miss titin has now 43012 xrefs !
    List<List> paramsList = splitList(resourceIds);
    for (List l : paramsList) {
        Map<String, Object> params = new HashMap<>();
        params.put("resourceIds", l);
        List<DbXrefProperty> someProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-props-by-resource-ids"), params, new DbXrefPropertyRowMapper());
        result.addAll(someProps);
        params.put("entryName", entryName);
        List<DbXrefProperty> someOtherProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-entry-link-props-by-entry-and-resource-ids"), params, new DbXrefPropertyRowMapper());
        result.addAll(someOtherProps);
    }
    // System.out.println("AAA final size is " + result.size());
    return result;
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) DbXrefProperty(org.nextprot.api.core.domain.DbXref.DbXrefProperty)

Example 32 with NamedParameterJdbcTemplate

use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findDbXRefByPublicationIds.

@Override
public List<PublicationDbXref> findDbXRefByPublicationIds(List<Long> publicationIds) {
    if (publicationIds.isEmpty()) {
        return new ArrayList<>();
    }
    Map<String, Object> params = new HashMap<>();
    params.put("publicationIds", publicationIds);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-by-publication-ids"), params, new PublicationDbXRefRowMapper());
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 33 with NamedParameterJdbcTemplate

use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findDbXrefEnsemblInfos.

@Override
public List<DbXref.EnsemblInfos> findDbXrefEnsemblInfos(String uniqueName, List<Long> xrefIds) {
    if (!xrefIds.isEmpty()) {
        Map<String, Object> params = new HashMap<>();
        params.put("uniqueName", uniqueName);
        params.put("xrefIds", xrefIds);
        return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("ensembl-props-by-xref-accession"), params, new EnsemblInfosRowMapper());
    }
    return new ArrayList<>();
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 34 with NamedParameterJdbcTemplate

use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findAntibodyXrefs.

@Override
public Set<DbXref> findAntibodyXrefs(List<Long> ids) {
    SqlParameterSource namedParams = new MapSqlParameterSource("ids", ids);
    List<DbXref> xrefs = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-by-antibody-ids"), namedParams, new DbXRefRowMapper());
    return new HashSet<>(xrefs);
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 35 with NamedParameterJdbcTemplate

use of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findPeptideXrefs.

@Override
public Set<DbXref> findPeptideXrefs(List<String> names) {
    SqlParameterSource namedParams = new MapSqlParameterSource("names", names);
    List<DbXref> xrefs = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-by-peptide-names"), namedParams, new DbXRefRowMapper());
    return new HashSet<>(xrefs);
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

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