Search in sources :

Example 11 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class IconUtils method addNewIconPair.

private void addNewIconPair(VmBase vmBase, String largeIconDataUrl) {
    final VmIconIdSizePair iconIds = ensureIconPairInDatabase(largeIconDataUrl);
    vmBase.setLargeIconId(iconIds.getLarge());
    vmBase.setSmallIconId(iconIds.getSmall());
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair)

Example 12 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class BackendOperatingSystemsResource method list.

@Override
public OperatingSystemInfos list() {
    OsRepository repository = SimpleDependencyInjector.getInstance().get(OsRepository.class);
    final Map<Integer, VmIconIdSizePair> iconDefaults = getIconDefaults();
    List<Integer> ids = repository.getOsIds();
    Map<Integer, String> uniqueNames = repository.getUniqueOsNames();
    Map<Integer, String> names = repository.getOsNames();
    OperatingSystemInfos collection = new OperatingSystemInfos();
    for (Integer id : ids) {
        OperatingSystemInfo model = new OperatingSystemInfo();
        model.setId(id.toString());
        if (iconDefaults.containsKey(id)) {
            final VmIconIdSizePair iconDefault = iconDefaults.get(id);
            model.setSmallIcon(IconHelper.createIcon(iconDefault.getSmall()));
            model.setLargeIcon(IconHelper.createIcon(iconDefault.getLarge()));
        }
        String uniqueName = uniqueNames.get(id);
        if (uniqueName != null) {
            model.setName(uniqueName);
        }
        String name = names.get(id);
        if (name != null) {
            model.setDescription(name);
        }
        collection.getOperatingSystemInfos().add(addLinks(model));
    }
    return collection;
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) OperatingSystemInfo(org.ovirt.engine.api.model.OperatingSystemInfo) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) OperatingSystemInfos(org.ovirt.engine.api.model.OperatingSystemInfos)

Aggregations

VmIconIdSizePair (org.ovirt.engine.core.common.queries.VmIconIdSizePair)12 HashMap (java.util.HashMap)3 Map (java.util.Map)2 VmIconDefault (org.ovirt.engine.core.common.businessentities.VmIconDefault)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 OperatingSystemInfo (org.ovirt.engine.api.model.OperatingSystemInfo)1 OperatingSystemInfos (org.ovirt.engine.api.model.OperatingSystemInfos)1 AddVmParameters (org.ovirt.engine.core.common.action.AddVmParameters)1 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)1 Pair (org.ovirt.engine.core.common.utils.Pair)1