Search in sources :

Example 91 with NamedParameterJdbcTemplate

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

the class PublicationDaoImpl method findSortedPublicationsByMasterId.

@Override
public List<Publication> findSortedPublicationsByMasterId(Long masterId) {
    Map<String, Object> params = new HashMap<>();
    params.put("identifierId", masterId);
    params.put("publicationTypes", Arrays.asList(10, 20, 30, 40, 50, 60, 70, 80));
    // get all journals found for all publication ids
    List<PublicationCvJournal> journals = journalDao.findCvJournalsByPublicationIds(findSortedPublicationIdsByMasterId(masterId));
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("publication-sorted-for-master"), params, new PublicationRowMapper(journals));
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) PublicationCvJournal(org.nextprot.api.core.domain.PublicationCvJournal)

Example 92 with NamedParameterJdbcTemplate

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

the class PublicationDaoImpl method findSortedPublicationIdsByMasterId.

@Override
public List<Long> findSortedPublicationIdsByMasterId(Long masterId) {
    Map<String, Object> params = new HashMap<>();
    params.put("identifierId", masterId);
    params.put("publicationTypes", Arrays.asList(10, 20, 30, 40, 50, 60, 70, 80));
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("publication-sorted-for-master"), params, new JdbcUtils.LongRowMapper("resource_id"));
}
Also used : JdbcUtils(org.nextprot.api.commons.utils.JdbcUtils) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 93 with NamedParameterJdbcTemplate

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

the class EntityNameDaoImpl method findNames.

@Override
public List<EntityName> findNames(String uniqueName) {
    SqlParameterSource namedParameters = new MapSqlParameterSource("uniqueName", uniqueName);
    List<EntityName> entityNames = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("entity-names"), namedParameters, new EntryNameRowMapper());
    return entityNames;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) EntityName(org.nextprot.api.core.domain.EntityName) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 94 with NamedParameterJdbcTemplate

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

the class EntryPropertiesDaoImpl method findEntryProperties.

@Override
public EntryProperties findEntryProperties(String uniqueName) {
    SqlParameterSource namedParameters = new MapSqlParameterSource("uniqueName", uniqueName);
    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dsLocator.getDataSource());
    return template.queryForObject(sqlDictionary.getSQLQuery("entry-properties"), namedParameters, new EntryPropertyRowMapper());
}
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)

Example 95 with NamedParameterJdbcTemplate

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

the class EntryPublicationDaoImpl method findPublicationDirectLinks.

@Override
public Map<Long, List<PublicationDirectLink>> findPublicationDirectLinks(String entryAccession) {
    Map<String, Object> params = new HashMap<>();
    params.put("masterId", masterIdentifierDao.findIdByUniqueName(entryAccession));
    EntryPublicationPropertyRowMapper mapper = new EntryPublicationPropertyRowMapper();
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("publications-scopes-and-comments-of-master"), params, mapper).stream().collect(Collectors.groupingBy(PublicationDirectLink::getPublicationId));
}
Also used : HashMap(java.util.HashMap) 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