Search in sources :

Example 56 with MapSqlParameterSource

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

the class StorageQosDaoImpl method getQosByDiskProfileIds.

@Override
public Map<Guid, StorageQos> getQosByDiskProfileIds(Collection<Guid> diskProfileIds) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("disk_profile_ids", createArrayOfUUIDs(diskProfileIds));
    List<Pair<Guid, StorageQos>> pairs = getCallsHandler().executeReadList("GetQosByDiskProfiles", storageQosMultipleProfilesMapper, parameterSource);
    return pairs.stream().collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 57 with MapSqlParameterSource

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

the class DnsResolverConfigurationDaoImpl method saveNameServersByDnsResolverConfigurationId.

private void saveNameServersByDnsResolverConfigurationId(Guid dnsResolverConfigurationId, List<NameServer> nameServers) {
    for (int i = 0; i < nameServers.size(); i++) {
        MapSqlParameterSource mapper = getCustomMapSqlParameterSource().addValue("dns_resolver_configuration_id", dnsResolverConfigurationId).addValue("address", nameServers.get(i).getAddress()).addValue("position", i);
        getCallsHandler().executeModification("InsertNameServer", mapper);
    }
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 58 with MapSqlParameterSource

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

the class HostNetworkQosDaoImpl method createFullParametersMapper.

@Override
protected MapSqlParameterSource createFullParametersMapper(HostNetworkQos obj) {
    MapSqlParameterSource map = super.createFullParametersMapper(obj);
    map.addValue(OUT_AVERAGE_LINKSHARE, obj.getOutAverageLinkshare());
    map.addValue(OUT_AVERAGE_UPPERLIMIT, obj.getOutAverageUpperlimit());
    map.addValue(OUT_AVERAGE_REALTIME, obj.getOutAverageRealtime());
    return map;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 59 with MapSqlParameterSource

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

the class InterfaceDaoImpl method saveInterfaceForVds.

@Override
public void saveInterfaceForVds(VdsNetworkInterface nic) {
    hostNetworkQosDao.persistQosChanges(nic.getId(), nic.getQos());
    MapSqlParameterSource parameterSource = createInterfaceParametersMapper(nic);
    getCallsHandler().executeModification("Insertvds_interface", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource)

Example 60 with MapSqlParameterSource

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

the class VmJobDaoImpl method createFullParametersMapper.

@Override
protected MapSqlParameterSource createFullParametersMapper(VmJob entity) {
    MapSqlParameterSource mapper = createIdParameterMapper(entity.getId());
    mapper.addValue("vm_id", entity.getVmId());
    mapper.addValue("job_state", entity.getJobState().getValue());
    mapper.addValue("job_type", entity.getJobType().getValue());
    if (entity.getJobType() == VmJobType.BLOCK) {
        VmBlockJob blockJob = (VmBlockJob) entity;
        mapper.addValue("block_job_type", blockJob.getBlockJobType().getValue());
        mapper.addValue("bandwidth", blockJob.getBandwidth());
        mapper.addValue("cursor_cur", blockJob.getCursorCur());
        mapper.addValue("cursor_end", blockJob.getCursorEnd());
        mapper.addValue("image_group_id", blockJob.getImageGroupId());
    } else {
        mapper.addValue("block_job_type", null);
        mapper.addValue("bandwidth", null);
        mapper.addValue("cursor_cur", null);
        mapper.addValue("cursor_end", null);
        mapper.addValue("image_group_id", null);
    }
    return mapper;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob)

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