Search in sources :

Example 26 with NamedParameterJdbcTemplate

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

the class IdentifierDaoImpl method findIdentifiersByMaster.

@Override
public List<Identifier> findIdentifiersByMaster(String uniqueName) {
    Map<String, Object> params = new HashMap<>();
    params.put("uniqueName", uniqueName);
    List<Identifier> ids = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("identifiers-by-master-unique-name"), params, new IdentifierRowMapper(uniqueName));
    return ids.stream().filter(Objects::nonNull).filter(i -> isValidIdentifier(i)).collect(Collectors.toList());
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) ParameterizedRowMapper(org.springframework.jdbc.core.simple.ParameterizedRowMapper) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) Autowired(org.springframework.beans.factory.annotation.Autowired) DbXrefURLResolverDelegate(org.nextprot.api.core.service.dbxref.resolver.DbXrefURLResolverDelegate) HashMap(java.util.HashMap) Identifier(org.nextprot.api.core.domain.Identifier) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) SQLException(java.sql.SQLException) List(java.util.List) SQLDictionary(org.nextprot.api.commons.utils.SQLDictionary) ResultSet(java.sql.ResultSet) IdentifierDao(org.nextprot.api.core.dao.IdentifierDao) Map(java.util.Map) DataSourceServiceLocator(org.nextprot.api.commons.spring.jdbc.DataSourceServiceLocator) Repository(org.springframework.stereotype.Repository) Identifier(org.nextprot.api.core.domain.Identifier) HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) Objects(java.util.Objects)

Example 27 with NamedParameterJdbcTemplate

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

the class CvJournalDaoImpl method findCvJournalsByPublicationIds.

@Override
public List<PublicationCvJournal> findCvJournalsByPublicationIds(List<Long> publicationIds) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("publicationIds", publicationIds);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("cvjournal-by-publication-ids"), params, new PublicationCvJournalRowMapper());
}
Also used : HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 28 with NamedParameterJdbcTemplate

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

the class CvJournalDaoImpl method findById.

@Override
public CvJournal findById(Long journalId) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("journalId", journalId);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).queryForObject(sqlDictionary.getSQLQuery("cvjournal-by-id"), params, new JournalRowMapper());
}
Also used : HashMap(java.util.HashMap) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 29 with NamedParameterJdbcTemplate

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

the class DbXrefDaoImpl method findEntryIdentifierXrefs.

@Override
public Set<DbXref> findEntryIdentifierXrefs(String entryName) {
    SqlParameterSource namedParams = new MapSqlParameterSource("uniqueName", entryName);
    List<DbXref> xrefs = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-by-master-via-identifiers"), namedParams, new DbXRefRowMapper(entryName));
    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 30 with NamedParameterJdbcTemplate

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

the class DbXrefDaoImpl method findEntryInteractionInteractantsXrefs.

@Override
public Set<DbXref> findEntryInteractionInteractantsXrefs(String entryName) {
    SqlParameterSource namedParams = new MapSqlParameterSource("uniqueName", entryName);
    List<DbXref> xrefs = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-by-master-via-interactions-interactants"), namedParams, new DbXRefRowMapper(entryName));
    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