use of org.ovirt.engine.core.common.businessentities.VmIcon in project ovirt-engine by oVirt.
the class GetVmIconsQuery method executeQueryCommand.
/**
* query returned type: {@code Map<Guid, String>} requested icon id -> icon data
*/
@Override
protected void executeQueryCommand() {
Map<Guid, String> result = new HashMap<>();
for (Guid iconId : getParameters().getIconIds()) {
final VmIcon vmIcon = vmIconDao.get(iconId);
result.put(iconId, vmIcon.getDataUrl());
}
setReturnValue(result);
}
use of org.ovirt.engine.core.common.businessentities.VmIcon in project ovirt-engine by oVirt.
the class VmIconDaoTest method testRemoveIfUnusedWithUsed.
@Test
public void testRemoveIfUnusedWithUsed() {
prepareDao().removeIfUnused(FixturesTool.SMALL_ICON_ID);
final VmIcon survivor = prepareDao().get(FixturesTool.SMALL_ICON_ID);
assertEquals(FixturesTool.SMALL_ICON_ID, survivor.getId());
}
use of org.ovirt.engine.core.common.businessentities.VmIcon in project ovirt-engine by oVirt.
the class VmIconMapper method map.
@Mapping(from = VmIcon.class, to = Icon.class)
public static Icon map(VmIcon entity, Icon template) {
final Icon model = template != null ? template : new Icon();
model.setId(entity.getId().toString());
final Pair<String, String> typeAndData = entity.getTypeAndData();
model.setMediaType(typeAndData.getFirst());
model.setData(typeAndData.getSecond());
return model;
}
use of org.ovirt.engine.core.common.businessentities.VmIcon in project ovirt-engine by oVirt.
the class BackendIconsResourceTest method setUpVmIcons.
public static List<VmIcon> setUpVmIcons() {
final List<VmIcon> result = new ArrayList<>();
// iterating over NAMES, because it is shorter than GUIDS and it is used in verifyCollection() method
for (int i = 0; i < NAMES.length; i++) {
final VmIcon vmIcon = new VmIcon(GUIDS[i], DATA_URLS[i]);
result.add(vmIcon);
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.VmIcon in project ovirt-engine by oVirt.
the class VmIconDaoImpl method ensureIconInDatabase.
@Override
public Guid ensureIconInDatabase(final String icon) {
if (icon == null) {
throw new IllegalArgumentException("Argument 'icon' should not be null");
}
return TransactionSupport.executeInNewTransaction(() -> {
final List<VmIcon> existingIcons = getByDataUrl(icon);
if (!existingIcons.isEmpty()) {
return existingIcons.get(0).getId();
}
final VmIcon newIcon = new VmIcon(Guid.newGuid(), icon);
save(newIcon);
return newIcon.getId();
});
}