Search in sources :

Example 21 with NamedParameterJdbcTemplate

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

the class EntityNameDaoImpl method findAlternativeChainNames.

@Override
public List<EntityName> findAlternativeChainNames(String uniqueName) {
    SqlParameterSource namedParameters = new MapSqlParameterSource("uniqueName", uniqueName);
    List<EntityName> entityNames = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("alternative-chain-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 22 with NamedParameterJdbcTemplate

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

the class FamilyDaoImpl method findParentOfFamilyId.

@Override
public Family findParentOfFamilyId(Long familyId) {
    String sql = sqlDictionary.getSQLQuery("parent-family-by-term-id");
    SqlParameterSource namedParameters = new MapSqlParameterSource("familyId", familyId);
    List<Family> parents = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParameters, new FamilyRowMapper());
    if (parents == null || parents.size() == 0)
        return null;
    return parents.get(0);
}
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) Family(org.nextprot.api.core.domain.Family)

Example 23 with NamedParameterJdbcTemplate

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

the class FamilyDaoImpl method findFamilies.

@Override
public List<Family> findFamilies(String uniqueName) {
    String sql = sqlDictionary.getSQLQuery("families-by-entry");
    SqlParameterSource namedParameters = new MapSqlParameterSource("uniqueName", uniqueName);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParameters, new FamilyRowMapper());
}
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 24 with NamedParameterJdbcTemplate

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

the class GeneDAOImpl method getIsoformMappingsByIsoformName.

@Override
public Map<String, List<IsoformGeneMapping>> getIsoformMappingsByIsoformName(Collection<String> isoformNames) {
    SqlParameterSource namedParameters = new MapSqlParameterSource("isoform_names", isoformNames);
    List<Map<String, Object>> result = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).queryForList(sqlDictionary.getSQLQuery("isoform-mappings"), namedParameters);
    Map<String, IsoformGeneMapping> isoformMappings = new HashMap<>();
    for (Map<String, Object> m : result) {
        String isoName = ((String) m.get("isoform"));
        long geneId = ((Long) m.get("reference_identifier_id"));
        String isoformMappingKey = isoName + "." + geneId;
        if (!isoformMappings.containsKey(isoformMappingKey)) {
            isoformMappings.put(isoformMappingKey, new IsoformGeneMapping());
        }
        IsoformGeneMapping isoformGeneMapping = isoformMappings.get(isoformMappingKey);
        isoformGeneMapping.setReferenceGeneId(geneId);
        isoformGeneMapping.setIsoformName(isoName);
        isoformGeneMapping.setReferenceGeneName((String) m.get("reference_gene"));
        GeneRegion geneRegion = new GeneRegion(isoformGeneMapping.getReferenceGeneName(), ((Integer) m.get("first_position")), ((Integer) m.get("last_position")));
        isoformGeneMapping.getIsoformGeneRegionMappings().add(geneRegion);
    }
    return isoformMappings.values().stream().collect(Collectors.groupingBy(IsoformGeneMapping::getIsoformName, Collectors.toList()));
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) HashMap(java.util.HashMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with NamedParameterJdbcTemplate

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

the class GeneDAOImpl method findExonsPartiallyAlignedToTranscriptOfGene.

@Override
public List<UncategorizedExon> findExonsPartiallyAlignedToTranscriptOfGene(String isoName, String transcriptName, String geneName) {
    MapSqlParameterSource namedParameters = new MapSqlParameterSource("transcriptName", transcriptName);
    namedParameters.addValue("geneName", geneName);
    namedParameters.addValue("isoformName", isoName);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("exons-partially-aligned-to-transcript"), namedParameters, new ExonMapper());
}
Also used : 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