use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageDomainModel in project ovirt-engine by oVirt.
the class TemplateStorageListModel method setItems.
@Override
public void setItems(final Collection<StorageDomainModel> value) {
if (storageDomainModels != null) {
Collections.sort(storageDomainModels, Comparator.comparing(s -> s.getStorageDomain().getStorageName()));
itemsChanging(value, items);
items = storageDomainModels;
itemsChanged();
getItemsChangedEvent().raise(this, EventArgs.EMPTY);
// $NON-NLS-1$
onPropertyChanged(new PropertyChangedEventArgs("Items"));
storageDomainModels = null;
} else {
VmTemplate template = getEntity();
AsyncDataProvider.getInstance().getTemplateDiskList(new AsyncQuery<>(diskImages -> {
Collection<? extends Object> storageDomains = value;
List<StorageDomainModel> storageDomainModels = new ArrayList<>();
for (Object o : storageDomains) {
StorageDomain storageDomain = (StorageDomain) o;
StorageDomainModel storageDomainModel = new StorageDomainModel();
storageDomainModel.setStorageDomain(storageDomain);
ArrayList<DiskImage> disks = new ArrayList<>();
for (DiskImage diskImage : diskImages) {
if (diskImage.getStorageIds().contains(storageDomain.getId())) {
disks.add(diskImage);
}
}
Collections.sort(disks, new DiskByDiskAliasComparator());
storageDomainModel.setDisks(disks);
storageDomainModels.add(storageDomainModel);
}
TemplateStorageListModel.this.storageDomainModels = storageDomainModels;
setItems(value);
}), template.getId());
}
}
Aggregations