Search in sources :

Example 61 with MapSqlParameterSource

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

the class VmNumaNodeDaoImpl method insertNumaNodeMap.

private void insertNumaNodeMap(List<VmNumaNode> numaNodes) {
    List<MapSqlParameterSource> vNodeToPnodeExecutions = new ArrayList<>();
    for (VmNumaNode node : numaNodes) {
        node.getVdsNumaNodeList().stream().map(index -> createVnodeToPnodeParametersMapper(index, node.getId())).forEach(vNodeToPnodeExecutions::add);
    }
    getCallsHandler().executeStoredProcAsBatch("InsertNumaNodeMap", vNodeToPnodeExecutions);
}
Also used : Arrays(java.util.Arrays) CollectionUtils.pairsToMap(org.ovirt.engine.core.utils.CollectionUtils.pairsToMap) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Guid(org.ovirt.engine.core.compat.Guid) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) Pair(org.ovirt.engine.core.common.utils.Pair) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 62 with MapSqlParameterSource

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

the class VmPoolDaoImpl method update.

@Override
public void update(VmPool pool) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_pool_description", pool.getVmPoolDescription()).addValue("vm_pool_comment", pool.getComment()).addValue("vm_pool_id", pool.getVmPoolId()).addValue("vm_pool_name", pool.getName()).addValue("vm_pool_type", pool.getVmPoolType()).addValue("stateful", pool.isStateful()).addValue("parameters", pool.getParameters()).addValue("prestarted_vms", pool.getPrestartedVms()).addValue("cluster_id", pool.getClusterId()).addValue("max_assigned_vms_per_user", pool.getMaxAssignedVmsPerUser()).addValue("spice_proxy", pool.getSpiceProxy()).addValue("is_being_destroyed", pool.isBeingDestroyed()).addValue("is_auto_storage_select", pool.isAutoStorageSelect());
    getCallsHandler().executeModification("UpdateVm_pools", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 63 with MapSqlParameterSource

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

the class VmPoolDaoImpl method setBeingDestroyed.

@Override
public void setBeingDestroyed(Guid vmPoolId, boolean beingDestroyed) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_pool_id", vmPoolId).addValue("is_being_destroyed", beingDestroyed);
    getCallsHandler().executeModification("SetVmPoolBeingDestroyed", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 64 with MapSqlParameterSource

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

the class VmPoolDaoImpl method boundVmPoolPrestartedVms.

@Override
public void boundVmPoolPrestartedVms(Guid vmPoolId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_pool_id", vmPoolId);
    getCallsHandler().executeModification("BoundVmPoolPrestartedVms", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 65 with MapSqlParameterSource

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

the class VmPoolDaoImpl method save.

@Override
public void save(VmPool pool) {
    Guid id = pool.getVmPoolId();
    if (Guid.isNullOrEmpty(id)) {
        id = Guid.newGuid();
        pool.setVmPoolId(id);
    }
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_pool_description", pool.getVmPoolDescription()).addValue("vm_pool_comment", pool.getComment()).addValue("vm_pool_id", pool.getVmPoolId()).addValue("vm_pool_name", pool.getName()).addValue("vm_pool_type", pool.getVmPoolType()).addValue("stateful", pool.isStateful()).addValue("parameters", pool.getParameters()).addValue("prestarted_vms", pool.getPrestartedVms()).addValue("cluster_id", pool.getClusterId()).addValue("max_assigned_vms_per_user", pool.getMaxAssignedVmsPerUser()).addValue("spice_proxy", pool.getSpiceProxy()).addValue("is_being_destroyed", pool.isBeingDestroyed()).addValue("is_auto_storage_select", pool.isAutoStorageSelect());
    getCallsHandler().executeModification("InsertVm_pools", parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Guid(org.ovirt.engine.core.compat.Guid)

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