Search in sources :

Example 6 with DiskByDiskAliasComparator

use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.

the class GetVmsRelatedToQuotaIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VM> vms = vmDao.getAllVmsRelatedToQuotaId(getParameters().getId());
    for (VM vm : vms) {
        vmHandler.updateDisksFromDb(vm);
        vmHandler.updateVmInitFromDB(vm.getStaticData(), true);
        Collections.sort(vm.getDiskList(), new DiskByDiskAliasComparator());
        imagesHandler.fillImagesBySnapshots(vm);
    }
    getQueryReturnValue().setReturnValue(vms);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 7 with DiskByDiskAliasComparator

use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator 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)

Example 8 with DiskByDiskAliasComparator

use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.

the class TemplateDiskListModel method setDisks.

private void setDisks(Collection<DiskImage> value) {
    ArrayList<DiskImage> disks = value != null ? new ArrayList<>(value) : new ArrayList<DiskImage>();
    Collections.sort(disks, new DiskByDiskAliasComparator());
    super.setItems(disks);
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 9 with DiskByDiskAliasComparator

use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.

the class TemplateImportDiskListModel method onEntityChanged.

@Override
protected void onEntityChanged() {
    super.onEntityChanged();
    if (getEntity() != null) {
        ArrayList<DiskImage> list = new ArrayList<>();
        VmTemplate template = (VmTemplate) getEntity();
        for (Map.Entry<VmTemplate, List<DiskImage>> item : extendedItems) {
            if (item.getKey().getQueryableId().equals(template.getQueryableId())) {
                list.addAll(item.getValue());
                Collections.sort(list, new DiskByDiskAliasComparator());
                setItems(list);
                return;
            }
        }
    } else {
        setItems(null);
    }
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Map(java.util.Map) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 10 with DiskByDiskAliasComparator

use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.

the class GetUserVmsByUserIdAndGroupsQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VM> vmList = vmDao.getAllForUserWithGroupsAndUserRoles(getUserID());
    for (VM vm : vmList) {
        updateVmGuestAgentVersion(vm);
        if (getParameters().getIncludeDiskData()) {
            updateDisksFromDB(vm);
            updateVmInit(vm);
            Collections.sort(vm.getDiskList(), new DiskByDiskAliasComparator());
            fillImagesBySnapshots(vm);
        }
    }
    setReturnValue(vmList);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Aggregations

DiskByDiskAliasComparator (org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)14 ArrayList (java.util.ArrayList)8 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)8 List (java.util.List)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)4 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)4 Collections (java.util.Collections)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)2 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)2 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)2 PreviewSnapshotModel (org.ovirt.engine.ui.uicommonweb.models.vms.PreviewSnapshotModel)2 SnapshotModel (org.ovirt.engine.ui.uicommonweb.models.vms.SnapshotModel)2 Context (com.google.gwt.cell.client.Cell.Context)1 GWT (com.google.gwt.core.client.GWT)1 BrowserEvents (com.google.gwt.dom.client.BrowserEvents)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1