Search in sources :

Example 1 with DiskByDiskAliasComparator

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

the class VmModelBehaviorBase method initTemplateDisks.

protected void initTemplateDisks(List<DiskImage> disks) {
    disks.sort(new DiskByDiskAliasComparator());
    ArrayList<DiskModel> list = new ArrayList<>();
    for (DiskImage disk : disks) {
        DiskModel diskModel = new DiskModel();
        diskModel.getAlias().setEntity(disk.getDiskAlias());
        diskModel.getVolumeType().setIsAvailable(false);
        switch(disk.getDiskStorageType()) {
            case IMAGE:
                diskModel.setSize(new EntityModel<>((int) disk.getSizeInGigabytes()));
                ListModel volumes = new ListModel();
                volumes.setItems(disk.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Collections.singletonList(VolumeType.Preallocated)) : AsyncDataProvider.getInstance().getVolumeTypeList(), disk.getVolumeType());
                diskModel.setVolumeType(volumes);
                break;
            case CINDER:
                CinderDisk cinderDisk = (CinderDisk) disk;
                diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
                ListModel volumeTypes = new ListModel();
                volumeTypes.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
                diskModel.setVolumeType(volumeTypes);
                ListModel volumeFormats = new ListModel();
                volumeFormats.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeFormat())), cinderDisk.getVolumeFormat());
                diskModel.setVolumeFormat(volumeFormats);
                break;
        }
        diskModel.setDisk(disk);
        list.add(diskModel);
    }
    getModel().setDisks(list);
    updateIsDisksAvailable();
    initStorageDomains();
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 2 with DiskByDiskAliasComparator

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

the class StorageRegisterDiskListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    IdQueryParameters parameters = new IdQueryParameters(getEntity().getId());
    parameters.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetUnregisteredCinderDisksByStorageDomainId, parameters, new SetSortedItemsAsyncQuery(new DiskByDiskAliasComparator()));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 3 with DiskByDiskAliasComparator

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

the class VmDiskListModel method setItems.

@Override
public void setItems(Collection value) {
    ArrayList<Disk> disks = value != null ? new ArrayList<>(value) : new ArrayList<Disk>();
    Collections.sort(disks, new DiskByDiskAliasComparator());
    super.setItems(disks);
    updateActionAvailability();
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 4 with DiskByDiskAliasComparator

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

the class SnapshotModel method updateVmConfiguration.

public void updateVmConfiguration(final AsyncCallback<Void> onUpdateAsyncCallback) {
    Snapshot snapshot = getEntity();
    if (snapshot == null) {
        return;
    }
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
        Snapshot snapshot1 = getEntity();
        if (vm != null && snapshot1 != null) {
            setVm(vm);
            setDisks(vm.getDiskList());
            setNics(vm.getInterfaces());
            setApps(Arrays.asList(snapshot1.getAppList() != null ? snapshot1.getAppList().split(",") : // $NON-NLS-1$
            new String[] {}));
            Collections.sort(getDisks(), new DiskByDiskAliasComparator());
            Collections.sort(getNics(), new LexoNumericNameableComparator<>());
        }
        onUpdateAsyncCallback.onSuccess(null);
    }), snapshot.getId());
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Version(org.ovirt.engine.core.compat.Version) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 5 with DiskByDiskAliasComparator

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

the class GetVmTemplatesFromStorageDomainQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VmTemplate> returnValue = vmTemplateDao.getAllForStorageDomain(getParameters().getId(), getUserID(), getParameters().isFiltered());
    if (getParameters().isWithDisks()) {
        for (VmTemplate template : returnValue) {
            vmTemplateHandler.updateDisksFromDb(template);
            Collections.sort(template.getDiskList(), new DiskByDiskAliasComparator());
        }
    }
    Collections.sort(returnValue, Comparator.comparing(VmTemplate::getActualDiskSize).reversed());
    getQueryReturnValue().setReturnValue(returnValue);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) 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