Search in sources :

Example 81 with MapSqlParameterSource

use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project ovirt-engine by oVirt.

the class CpuProfileDaoImpl method createFullParametersMapper.

@Override
protected MapSqlParameterSource createFullParametersMapper(CpuProfile obj) {
    MapSqlParameterSource map = super.createFullParametersMapper(obj);
    map.addValue("cluster_id", obj.getClusterId());
    return map;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 82 with MapSqlParameterSource

use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project ovirt-engine by oVirt.

the class StorageServerConnectionLunMapDaoImpl method save.

@Override
public void save(LUNStorageServerConnectionMap map) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("lun_id", map.getLunId()).addValue("storage_server_connection", map.getStorageServerConnection());
    getCallsHandler().executeModification("InsertLUN_storage_server_connection_map", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 83 with MapSqlParameterSource

use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project ovirt-engine by oVirt.

the class SystemStatisticsDaoImpl method getSystemStatisticsValue.

@Override
public Integer getSystemStatisticsValue(String entity, String status) {
    MapSqlParameterSource parameterSource = new CustomMapSqlParameterSource(dbEngineDialect).addValue("entity", entity).addValue("status", status);
    RowMapper<Integer> mapper = (rs, rowNum) -> rs.getInt("val");
    Map<String, Object> dbResults = dbEngineDialect.createJdbcCallForQuery(jdbcTemplate).withProcedureName("Getsystem_statistics").returningResultSet("RETURN_VALUE", mapper).execute(parameterSource);
    return (Integer) DbFacadeUtils.asSingleResult((List<?>) dbResults.get("RETURN_VALUE"));
}
Also used : Objects(java.util.Objects) Inject(javax.inject.Inject) List(java.util.List) Map(java.util.Map) RowMapper(org.springframework.jdbc.core.RowMapper) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Named(javax.inject.Named) DbEngineDialect(org.ovirt.engine.core.dal.dbbroker.DbEngineDialect) Singleton(javax.inject.Singleton) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource) DbFacadeUtils(org.ovirt.engine.core.dal.dbbroker.DbFacadeUtils) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource) List(java.util.List)

Example 84 with MapSqlParameterSource

use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project ovirt-engine by oVirt.

the class TagDaoImpl method getTagTemplateByTagIdAndByTemplateId.

/**
 * In the database both Template and Vm Tags share the same tables and functions
 */
@Override
public TagsTemplateMap getTagTemplateByTagIdAndByTemplateId(Guid tagId, Guid vmId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", tagId).addValue("vm_id", vmId);
    RowMapper<TagsTemplateMap> mapper = (rs, rowNum) -> {
        TagsTemplateMap entity = new TagsTemplateMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setTemplateId(getGuidDefaultEmpty(rs, "vm_id"));
        entity.setDefaultDisplayType((Integer) rs.getObject("DefaultDisplayType"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagVmByTagIdAndByvmId", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap)

Example 85 with MapSqlParameterSource

use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project ovirt-engine by oVirt.

the class TagDaoImpl method remove.

@Override
public void remove(Guid id) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", id);
    getCallsHandler().executeModification("Deletetags", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Aggregations

MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)505 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)82 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)63 Test (org.junit.jupiter.api.Test)48 ArrayList (java.util.ArrayList)36 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)34 ResultSet (java.sql.ResultSet)33 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)32 List (java.util.List)30 HashMap (java.util.HashMap)29 SQLException (java.sql.SQLException)25 Guid (org.ovirt.engine.core.compat.Guid)25 Collectors (java.util.stream.Collectors)16 CustomMapSqlParameterSource (org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource)16 Transactional (org.springframework.transaction.annotation.Transactional)16 java.util (java.util)13 Component (org.springframework.stereotype.Component)13 Map (java.util.Map)12 RowMapper (org.springframework.jdbc.core.RowMapper)11 Named (javax.inject.Named)10