Search in sources :

Example 11 with NameableComparator

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

the class AsyncDataProvider method getAllProvidersByProvidedEntity.

public void getAllProvidersByProvidedEntity(AsyncQuery<List<Provider<?>>> query, final VdcObjectType providedEntity) {
    query.converterCallback = returnValue -> {
        if (returnValue == null) {
            return new ArrayList<>();
        }
        return ((Collection<Provider<?>>) returnValue).stream().filter(p -> p.getType().getProvidedTypes().contains(providedEntity)).sorted(new NameableComparator()).collect(Collectors.toList());
    };
    Frontend.getInstance().runQuery(QueryType.GetAllProviders, new GetAllProvidersParameters(), query);
}
Also used : ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) GetAllProvidersParameters(org.ovirt.engine.core.common.queries.GetAllProvidersParameters) Provider(org.ovirt.engine.core.common.businessentities.Provider)

Example 12 with NameableComparator

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

the class MoveOrCopyDiskModel method postInitStorageDomains.

protected void postInitStorageDomains() {
    for (DiskModel disk : getDisks()) {
        DiskImage diskImage = (DiskImage) disk.getDisk();
        // Source storage domains
        List<Guid> diskStorageIds = diskImage.getStorageIds();
        List<StorageDomain> sourceStorageDomains = Linq.getStorageDomainsByIds(diskStorageIds, getActiveStorageDomains());
        boolean isDiskBasedOnTemplate = !diskImage.getParentId().equals(Guid.Empty);
        ArrayList<StorageDomain> destStorageDomains = getDestinationDomains(getActiveStorageDomains(), sourceStorageDomains, disk, isDiskBasedOnTemplate);
        // Add prohibition reasons
        if (sourceStorageDomains.isEmpty() || destStorageDomains.isEmpty()) {
            problematicDisks.add(disk.getAlias().getEntity());
            updateChangeability(disk, isDiskBasedOnTemplate, sourceStorageDomains.isEmpty(), destStorageDomains.isEmpty());
        }
        // Sort and add storage domains
        Collections.sort(destStorageDomains, new NameableComparator());
        Collections.sort(sourceStorageDomains, new NameableComparator());
        disk.getStorageDomain().setItems(destStorageDomains);
        disk.getSourceStorageDomain().setItems(sourceStorageDomains);
        addSourceStorageDomainName(disk, sourceStorageDomains);
    }
    sortDisks();
    postCopyOrMoveInit();
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 13 with NameableComparator

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

the class ExportRepoImageModel method filterStorageDomains.

@Override
protected List<StorageDomain> filterStorageDomains(List<StorageDomain> storageDomains) {
    List<StorageDomain> availableStorageDomains = new ArrayList<>();
    // Take only GLANCE domains
    for (StorageDomain storageDomainItem : storageDomains) {
        if (storageDomainItem.getStorageType() == StorageType.GLANCE) {
            availableStorageDomains.add(storageDomainItem);
        }
    }
    // Sorting by name
    Collections.sort(availableStorageDomains, new NameableComparator());
    return availableStorageDomains;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Example 14 with NameableComparator

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

the class AdElementListModel method populateRoles.

protected void populateRoles(List<Role> roles) {
    Role selectedRole = null;
    List<Role> rolesToPopulate = new ArrayList<>();
    for (Role role : roles) {
        if (role.getId() != null) {
            // ignore CONSUME_QUOTA_ROLE in UI
            if (!role.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
                rolesToPopulate.add(role);
            }
            // select engine user if it exists
            if (role.getId().equals(ApplicationGuids.engineUser.asGuid())) {
                selectedRole = role;
            }
        }
    }
    rolesToPopulate.sort(new NameableComparator());
    getRole().setItems(rolesToPopulate);
    if (selectDefaultRole) {
        if (selectedRole != null) {
            getRole().setSelectedItem(selectedRole);
        } else if (rolesToPopulate.size() > 0) {
            // if engine user does not exist, pick the first on the list
            getRole().setSelectedItem(rolesToPopulate.get(0));
        }
    } else {
        getRole().setSelectedItem(null);
    }
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Example 15 with NameableComparator

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

the class DataCenterNetworkListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    super.syncSearch();
    IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId());
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetAllNetworks, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<Network> newItems = returnValue.getReturnValue();
        Collections.sort(newItems, new NameableComparator());
        setItems(newItems);
    }));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Network(org.ovirt.engine.core.common.businessentities.network.Network) Collections(java.util.Collections) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Aggregations

NameableComparator (org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)15 ArrayList (java.util.ArrayList)13 List (java.util.List)6 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)5 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)5 Collections (java.util.Collections)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 QueryType (org.ovirt.engine.core.common.queries.QueryType)4 Guid (org.ovirt.engine.core.compat.Guid)4 Frontend (org.ovirt.engine.ui.frontend.Frontend)4 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)4 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)3 AsyncCallback (org.ovirt.engine.ui.frontend.AsyncCallback)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)3