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;
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations