Search in sources :

Example 1 with VmIconDefault

use of org.ovirt.engine.core.common.businessentities.VmIconDefault in project ovirt-engine by oVirt.

the class OvfVmIconDefaultsProvider method getVmIconDefaults.

public Map<Integer, VmIconIdSizePair> getVmIconDefaults() {
    final Map<Integer, VmIconIdSizePair> result = new HashMap<>();
    final List<VmIconDefault> iconDefaults = vmIconDefaultDao.getAll();
    for (VmIconDefault iconDefault : iconDefaults) {
        result.put(iconDefault.getOsId(), new VmIconIdSizePair(iconDefault.getSmallIconId(), iconDefault.getLargeIconId()));
    }
    if (!result.containsKey(OsRepository.DEFAULT_X86_OS)) {
        throw new EngineException(EngineError.DefaultIconPairNotFound);
    }
    return result;
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) HashMap(java.util.HashMap) EngineException(org.ovirt.engine.core.common.errors.EngineException) VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault)

Example 2 with VmIconDefault

use of org.ovirt.engine.core.common.businessentities.VmIconDefault in project ovirt-engine by oVirt.

the class BackendOperatingSystemResource method get.

@Override
public OperatingSystemInfo get() {
    OsRepository repository = SimpleDependencyInjector.getInstance().get(OsRepository.class);
    OperatingSystemInfo model = new OperatingSystemInfo();
    model.setId(id);
    Integer key = Integer.valueOf(id);
    String uniqueName = repository.getUniqueOsNames().get(key);
    if (uniqueName == null) {
        return notFound();
    }
    model.setName(uniqueName);
    String name = repository.getOsNames().get(key);
    if (name != null) {
        model.setDescription(name);
    }
    final VmIconDefault vmIconDefault = getEntity(VmIconDefault.class, QueryType.GetVmIconDefault, new GetVmIconDefaultParameters(key), "VmIconDefault");
    if (vmIconDefault != null) {
        model.setSmallIcon(IconHelper.createIcon(vmIconDefault.getSmallIconId()));
        model.setLargeIcon(IconHelper.createIcon(vmIconDefault.getLargeIconId()));
    }
    return addLinks(model);
}
Also used : GetVmIconDefaultParameters(org.ovirt.engine.core.common.queries.GetVmIconDefaultParameters) OperatingSystemInfo(org.ovirt.engine.api.model.OperatingSystemInfo) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault)

Example 3 with VmIconDefault

use of org.ovirt.engine.core.common.businessentities.VmIconDefault in project ovirt-engine by oVirt.

the class VmIconDefaultDaoTest method testGetByOperatingSystemIdExisting.

@Test
public void testGetByOperatingSystemIdExisting() {
    final VmIconDefault vmIconDefault = prepareDao().getByOperatingSystemId(OTHER_OS_VM_ICON_DEFAULT.getOsId());
    assertEquals(OTHER_OS_VM_ICON_DEFAULT, vmIconDefault);
}
Also used : VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault) Test(org.junit.Test)

Example 4 with VmIconDefault

use of org.ovirt.engine.core.common.businessentities.VmIconDefault in project ovirt-engine by oVirt.

the class VmIconDefaultDaoTest method testGetByOperatingSystemIdNonExisting.

@Test
public void testGetByOperatingSystemIdNonExisting() {
    final VmIconDefault vmIconDefault = prepareDao().getByOperatingSystemId(-1);
    assertNull(vmIconDefault);
}
Also used : VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault) Test(org.junit.Test)

Example 5 with VmIconDefault

use of org.ovirt.engine.core.common.businessentities.VmIconDefault in project ovirt-engine by oVirt.

the class IconLoader method updateVmIconDefaultsTable.

/**
 * It recreates 'vm_icon_defaults' table based on new configuration.
 */
private void updateVmIconDefaultsTable() {
    vmIconDefaultDao.removeAll();
    for (Map.Entry<Integer, VmIconIdSizePair> entry : osIdToIconIdMap.entrySet()) {
        final VmIconDefault osDefaultIconIds = new VmIconDefault(Guid.newGuid(), entry.getKey(), entry.getValue().getSmall(), entry.getValue().getLarge());
        vmIconDefaultDao.save(osDefaultIconIds);
    }
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) HashMap(java.util.HashMap) Map(java.util.Map) VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault)

Aggregations

VmIconDefault (org.ovirt.engine.core.common.businessentities.VmIconDefault)5 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 VmIconIdSizePair (org.ovirt.engine.core.common.queries.VmIconIdSizePair)2 Map (java.util.Map)1 OperatingSystemInfo (org.ovirt.engine.api.model.OperatingSystemInfo)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)1 GetVmIconDefaultParameters (org.ovirt.engine.core.common.queries.GetVmIconDefaultParameters)1