Search in sources :

Example 1 with StorageDomainModel

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());
    }
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageDomainModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) RemoveDiskParameters(org.ovirt.engine.core.common.action.RemoveDiskParameters) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) List(java.util.List) Comparator(java.util.Comparator) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) ArrayList(java.util.ArrayList) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) StorageDomainModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageDomainModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 RemoveDiskParameters (org.ovirt.engine.core.common.action.RemoveDiskParameters)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 DiskByDiskAliasComparator (org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 Frontend (org.ovirt.engine.ui.frontend.Frontend)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)1 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1