Search in sources :

Example 36 with NamedParameterJdbcTemplate

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

the class DbXrefDaoImpl method findDbXRefsByPublicationId.

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

Example 37 with NamedParameterJdbcTemplate

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

the class SchemaDaoImpl method findAllSource.

@Override
public List<OWLDatasource> findAllSource() {
    SqlParameterSource params = new MapSqlParameterSource();
    List<OWLDatasource> datasources = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("schema-datasource-list"), params, new ParameterizedRowMapper<OWLDatasource>() {

        @Override
        public OWLDatasource mapRow(ResultSet resultSet, int row) throws SQLException {
            OWLDatasource datasource = new OWLDatasource();
            datasource.setName(resultSet.getString("name"));
            datasource.setDescription(resultSet.getString("description"));
            datasource.setURL(resultSet.getString("url"));
            return datasource;
        }
    });
    return datasources;
}
Also used : OWLDatasource(org.nextprot.api.rdf.domain.OWLDatasource) 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) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet)

Example 38 with NamedParameterJdbcTemplate

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

the class SchemaDaoImpl method findAllDatabase.

@Override
public List<OWLDatabase> findAllDatabase() {
    SqlParameterSource params = new MapSqlParameterSource();
    List<OWLDatabase> databases = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("schema-database-list"), params, new ParameterizedRowMapper<OWLDatabase>() {

        @Override
        public OWLDatabase mapRow(ResultSet resultSet, int row) throws SQLException {
            OWLDatabase database = new OWLDatabase();
            database.setName(resultSet.getString("name"));
            database.setDescription(resultSet.getString("description"));
            database.setURL(resultSet.getString("url"));
            database.setCategory(resultSet.getString("category"));
            return database;
        }
    });
    return databases;
}
Also used : OWLDatabase(org.nextprot.api.rdf.domain.OWLDatabase) 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) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet)

Example 39 with NamedParameterJdbcTemplate

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

the class SchemaDaoImpl method findAllProvenance.

/**
 * same as findAllDatabase() union identifier type names as pseudo database name
 */
@Override
public List<OWLDatabase> findAllProvenance() {
    SqlParameterSource params = new MapSqlParameterSource();
    List<OWLDatabase> databases = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("schema-provenance-list"), params, new ParameterizedRowMapper<OWLDatabase>() {

        @Override
        public OWLDatabase mapRow(ResultSet resultSet, int row) throws SQLException {
            OWLDatabase database = new OWLDatabase();
            database.setName(resultSet.getString("name"));
            database.setDescription(resultSet.getString("description"));
            database.setURL(resultSet.getString("url"));
            database.setCategory(resultSet.getString("category"));
            return database;
        }
    });
    return databases;
}
Also used : OWLDatabase(org.nextprot.api.rdf.domain.OWLDatabase) 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) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet)

Example 40 with NamedParameterJdbcTemplate

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

the class SchemaDaoImpl method findAllEvidence.

@Override
public List<OWLEvidence> findAllEvidence() {
    SqlParameterSource params = new MapSqlParameterSource();
    List<OWLEvidence> evidences = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("schema-evidence-list"), params, new ParameterizedRowMapper<OWLEvidence>() {

        @Override
        public OWLEvidence mapRow(ResultSet resultSet, int row) throws SQLException {
            OWLEvidence evidence = new OWLEvidence();
            evidence.setType(resultSet.getString("type"));
            evidence.setDescription(resultSet.getString("description"));
            evidence.setCount(resultSet.getInt("n"));
            return evidence;
        }
    });
    return evidences;
}
Also used : 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) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) OWLEvidence(org.nextprot.api.rdf.domain.OWLEvidence)

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