use of org.ovirt.engine.api.model.Templates 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.api.model.Templates in project ovirt-engine by oVirt.
the class BackendStorageDomainTemplatesResource method list.
@Override
public Templates list() {
Templates templates = new Templates();
boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
if (unregistered) {
List<org.ovirt.engine.core.common.businessentities.VmTemplate> unregisteredTemplates = getBackendCollection(QueryType.GetUnregisteredVmTemplates, new IdQueryParameters(storageDomainId));
List<Template> collection = new ArrayList<>();
for (org.ovirt.engine.core.common.businessentities.VmTemplate entity : unregisteredTemplates) {
Template vmTemplate = map(entity);
collection.add(addLinks(populate(vmTemplate, entity)));
}
templates.getTemplates().addAll(collection);
} else {
templates.getTemplates().addAll(getCollection());
}
return templates;
}
use of org.ovirt.engine.api.model.Templates in project ovirt-engine by oVirt.
the class V3TemplatesInAdapter method adapt.
@Override
public Templates adapt(V3Templates from) {
Templates to = new Templates();
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetActive()) {
to.setActive(from.getActive());
}
if (from.isSetSize()) {
to.setSize(from.getSize());
}
if (from.isSetTotal()) {
to.setTotal(from.getTotal());
}
to.getTemplates().addAll(adaptIn(from.getTemplates()));
return to;
}
Aggregations