Search in sources :

Example 81 with NamedParameterJdbcTemplate

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

the class UserProteinListDaoImpl method deleteAllProteinListItems.

@Override
public int deleteAllProteinListItems(long listId) {
    final String DELETE_SQL = sqlDictionary.getSQLQuery("delete-all-protein-list-items");
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("list_id", listId);
    return new NamedParameterJdbcTemplate(dsLocator.getUserDataSource()).update(DELETE_SQL, params);
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 82 with NamedParameterJdbcTemplate

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

the class UserProteinListDaoImpl method getUserProteinListById.

@Override
public UserProteinList getUserProteinListById(long listId) throws DataAccessException {
    String sql = sqlDictionary.getSQLQuery("read-user-protein-list-by-id");
    SqlParameterSource namedParams = new MapSqlParameterSource("list_id", listId);
    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource());
    UserProteinList userProteinList = template.queryForObject(sql, namedParams, new ProteinListRowMapper());
    userProteinList.setAccessions(getAccessionsByListId(listId));
    return userProteinList;
}
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) UserProteinList(org.nextprot.api.user.domain.UserProteinList)

Example 83 with NamedParameterJdbcTemplate

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

the class UserProteinListDaoImpl method getUserProteinLists.

@Override
public List<UserProteinList> getUserProteinLists(String username) {
    String sql = sqlDictionary.getSQLQuery("read-user-protein-lists-by-username");
    SqlParameterSource namedParameters = new MapSqlParameterSource("user_name", username);
    return new NamedParameterJdbcTemplate(dsLocator.getUserDataSource()).query(sql, namedParameters, new ProteinListRowMapper());
}
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 84 with NamedParameterJdbcTemplate

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

the class UserProteinListDaoImpl method createUserProteinList.

@Override
public long createUserProteinList(final UserProteinList userProteinList) {
    final String INSERT_SQL = sqlDictionary.getSQLQuery("create-user-protein-list");
    MapSqlParameterSource namedParameters = new MapSqlParameterSource();
    namedParameters.addValue("list_name", userProteinList.getName());
    namedParameters.addValue("description", userProteinList.getDescription());
    namedParameters.addValue("owner_id", userProteinList.getOwnerId());
    namedParameters.addValue("public_id", userProteinList.getPublicId());
    return JdbcUtils.insertAndGetKey(INSERT_SQL, "list_id", namedParameters, new NamedParameterJdbcTemplate(dsLocator.getUserDataSource())).longValue();
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 85 with NamedParameterJdbcTemplate

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

the class IsoformDAOImpl method findIsoformsSynonymsByEntryName.

@Override
public List<EntityName> findIsoformsSynonymsByEntryName(String entryName) {
    String sql = sqlDictionary.getSQLQuery("isoforms-synonyms-by-entry-name");
    SqlParameterSource namedParameters = new MapSqlParameterSource("unique_name", entryName);
    return new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParameters, new EntityNameRowMapper());
}
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)

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