Search in sources :

Example 1 with OperatingSystemInfo

use of org.ovirt.engine.api.model.OperatingSystemInfo 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 2 with OperatingSystemInfo

use of org.ovirt.engine.api.model.OperatingSystemInfo 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

OperatingSystemInfo (org.ovirt.engine.api.model.OperatingSystemInfo)2 OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)2 OperatingSystemInfos (org.ovirt.engine.api.model.OperatingSystemInfos)1 VmIconDefault (org.ovirt.engine.core.common.businessentities.VmIconDefault)1 GetVmIconDefaultParameters (org.ovirt.engine.core.common.queries.GetVmIconDefaultParameters)1 VmIconIdSizePair (org.ovirt.engine.core.common.queries.VmIconIdSizePair)1