use of org.ovirt.engine.core.common.queries.IdsQueryParameters in project ovirt-engine by oVirt.
the class BackendVmsResource method mapCollection.
protected Vms mapCollection(List<org.ovirt.engine.core.common.businessentities.VM> entities) {
Set<String> details = DetailHelper.getDetails(httpHeaders, uriInfo);
boolean includeData = details.contains(DetailHelper.MAIN);
boolean includeSize = details.contains("size");
List<Guid> vmIds = entities.stream().map(VM::getId).collect(Collectors.toList());
if (includeData) {
// Fill VmInit for entities - the search query no join the VmInit to Vm
IdsQueryParameters params = new IdsQueryParameters();
params.setId(vmIds);
QueryReturnValue queryReturnValue = runQuery(QueryType.GetVmsInit, params);
if (queryReturnValue.getSucceeded() && queryReturnValue.getReturnValue() != null) {
List<VmInit> vmInits = queryReturnValue.getReturnValue();
Map<Guid, VmInit> initMap = Entities.businessEntitiesById(vmInits);
for (org.ovirt.engine.core.common.businessentities.VM vm : entities) {
vm.setVmInit(initMap.get(vm.getId()));
}
}
}
Vms collection = new Vms();
if (includeData) {
// optimization of DB access: retrieve GraphicsDevices for all VMs at once
Map<Guid, List<GraphicsDevice>> vmsGraphicsDevices = DisplayHelper.getGraphicsDevicesForMultipleEntities(this, vmIds);
for (org.ovirt.engine.core.common.businessentities.VM entity : entities) {
Vm vm = map(entity);
DisplayHelper.adjustDisplayData(this, vm, vmsGraphicsDevices, false);
removeRestrictedInfo(vm);
collection.getVms().add(addLinks(populate(vm, entity)));
}
}
if (includeSize) {
collection.setSize((long) entities.size());
}
return collection;
}
use of org.ovirt.engine.core.common.queries.IdsQueryParameters in project ovirt-engine by oVirt.
the class BackendTemplatesResource method mapCollection.
protected Templates mapCollection(List<VmTemplate> entities) {
Set<String> details = DetailHelper.getDetails(httpHeaders, uriInfo);
boolean includeData = details.contains(DetailHelper.MAIN);
boolean includeSize = details.contains("size");
if (includeData) {
// Fill VmInit for entities - the search query no join the VmInit to Templates
IdsQueryParameters params = new IdsQueryParameters();
List<Guid> ids = entities.stream().map(VmTemplate::getId).collect(Collectors.toList());
params.setId(ids);
QueryReturnValue queryReturnValue = runQuery(QueryType.GetVmsInit, params);
if (queryReturnValue.getSucceeded() && queryReturnValue.getReturnValue() != null) {
List<VmInit> vmInits = queryReturnValue.getReturnValue();
Map<Guid, VmInit> initMap = Entities.businessEntitiesById(vmInits);
for (VmTemplate template : entities) {
template.setVmInit(initMap.get(template.getId()));
}
}
}
Templates collection = new Templates();
if (includeData) {
for (VmTemplate entity : entities) {
Template template = map(entity);
collection.getTemplates().add(addLinks(populate(template, entity)));
DisplayHelper.adjustDisplayData(this, template);
}
}
if (includeSize) {
collection.setSize((long) entities.size());
}
return collection;
}
use of org.ovirt.engine.core.common.queries.IdsQueryParameters in project ovirt-engine by oVirt.
the class AsyncDataProvider method getAncestorImagesByImagesIds.
public void getAncestorImagesByImagesIds(AsyncQuery<Map<Guid, DiskImage>> aQuery, List<Guid> imagesIds) {
aQuery.converterCallback = new CastingConverter<>();
IdsQueryParameters params = new IdsQueryParameters(imagesIds);
Frontend.getInstance().runQuery(QueryType.GetAncestorImagesByImagesIds, params, aQuery);
}
Aggregations