Search in sources :

Example 6 with NameableComparator

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

the class AsyncDataProvider method getClusterListByService.

public void getClusterListByService(AsyncQuery<List<Cluster>> aQuery, final boolean supportsVirtService, final boolean supportsGlusterService) {
    aQuery.converterCallback = source -> {
        if (source != null) {
            ArrayList<Cluster> list = getClusterByServiceList((ArrayList<Cluster>) source, supportsVirtService, supportsGlusterService);
            Collections.sort(list, new NameableComparator());
            return list;
        }
        return new ArrayList<>();
    };
    Frontend.getInstance().runQuery(QueryType.GetAllClusters, new QueryParametersBase(), aQuery);
}
Also used : NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StorageServerConnectionQueryParametersBase(org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)

Example 7 with NameableComparator

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

the class BaseImportNetworksModel method onProviderChosen.

private void onProviderChosen() {
    final Provider<?> provider = providers.getSelectedItem();
    if (provider == null) {
        return;
    }
    startProgress();
    AsyncQuery<List<StoragePool>> dataCenterQuery = new AsyncQuery<>(returnValue -> {
        final List<StoragePool> dataCenters = new LinkedList<>(returnValue);
        Collections.sort(dataCenters, new NameableComparator());
        AsyncQuery<QueryReturnValue> externalNetworksQuery = new AsyncQuery<>(queryReturnValue -> {
            if (queryReturnValue.getSucceeded()) {
                Map<Network, Set<Guid>> externalNetworkToDataCenters = queryReturnValue.getReturnValue();
                providerNetworks.setItems(getExternalNetworks(externalNetworkToDataCenters, dataCenters));
                importedNetworks.setItems(new LinkedList<ExternalNetwork>());
            } else {
                final ErrorPopupManager popupManager = (ErrorPopupManager) TypeResolver.getInstance().resolve(ErrorPopupManager.class);
                popupManager.show(ConstantsManager.getInstance().getMessages().failedToListExternalNetworks(queryReturnValue.getExceptionMessage()));
            }
            stopProgress();
        }, true);
        AsyncDataProvider.getInstance().getExternalNetworksByProviderId(externalNetworksQuery, provider.getId());
    });
    AsyncDataProvider.getInstance().getDataCenterList(dataCenterQuery);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Set(java.util.Set) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) LinkedList(java.util.LinkedList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Network(org.ovirt.engine.core.common.businessentities.network.Network) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork)

Example 8 with NameableComparator

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

the class ImportVmsModel method initDataCenters.

private void initDataCenters() {
    getDataCenters().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
        clearVms();
        exportDomain.setEntity(null);
        loadProviders();
        StoragePool dataCenter = dataCenters.getSelectedItem();
        Frontend.getInstance().runQuery(QueryType.GetStorageDomainsByStoragePoolId, new IdQueryParameters(dataCenter.getId()), new AsyncQuery<>(createGetStorageDomainsByStoragePoolIdCallback()));
    });
    dataCenters.getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>(hosts -> {
                List<VDS> upHosts = filterUpHosts(hosts);
                proxyHosts.setItems(addAnyHostInCluster(upHosts));
                xenProxyHosts.setItems(addAnyHostInCluster(upHosts));
                kvmProxyHosts.setItems(addAnyHostInCluster(upHosts));
                ImportVmsModel.this.hosts.setItems(upHosts);
                stopProgress();
            }), dataCenters.getSelectedItem().getId());
        }

        private List<VDS> filterUpHosts(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>();
            for (VDS host : hosts) {
                if (host.getStatus() == VDSStatus.Up) {
                    result.add(host);
                }
            }
            return result;
        }

        private List<VDS> addAnyHostInCluster(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>(hosts);
            // Any host in the cluster
            result.add(0, null);
            return result;
        }
    });
    AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(returnValue -> {
        List<StoragePool> dataCenters = new ArrayList<>();
        for (StoragePool a : returnValue) {
            if (a.getStatus() == StoragePoolStatus.Up) {
                dataCenters.add(a);
            }
        }
        if (dataCenters.isEmpty()) {
            getDataCenters().setIsChangeable(false);
            getImportSources().setIsChangeable(false);
            setError(constants.notAvailableWithNoUpDC());
            stopProgress();
            return;
        }
        Collections.sort(dataCenters, new NameableComparator());
        ImportVmsModel.this.dataCenters.setItems(dataCenters);
    }));
}
Also used : Arrays(java.util.Arrays) NameAndOptionalDomainValidation(org.ovirt.engine.ui.uicommonweb.validation.NameAndOptionalDomainValidation) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) URL(com.google.gwt.http.client.URL) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SortedListModel(org.ovirt.engine.ui.uicommonweb.models.SortedListModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) XENVmProviderProperties(org.ovirt.engine.core.common.businessentities.XENVmProviderProperties) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) KVMVmProviderProperties(org.ovirt.engine.core.common.businessentities.KVMVmProviderProperties) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Pair(org.ovirt.engine.core.common.utils.Pair) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VmwareVmProviderProperties(org.ovirt.engine.core.common.businessentities.VmwareVmProviderProperties) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) List(java.util.List) ArrayList(java.util.ArrayList) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)

Example 9 with NameableComparator

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

the class AsyncDataProvider method getTemplateListByStorage.

public void getTemplateListByStorage(AsyncQuery<List<VmTemplate>> aQuery, Guid storageId) {
    aQuery.converterCallback = source -> {
        ArrayList<VmTemplate> list = new ArrayList<>();
        if (source != null) {
            for (VmTemplate template : (ArrayList<VmTemplate>) source) {
                if (template.getStatus() == VmTemplateStatus.OK) {
                    list.add(template);
                }
            }
            Collections.sort(list, new NameableComparator());
        }
        return list;
    };
    Frontend.getInstance().runQuery(QueryType.GetVmTemplatesFromStorageDomain, new GetVmTemplatesFromStorageDomainParameters(storageId, false), aQuery);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) GetVmTemplatesFromStorageDomainParameters(org.ovirt.engine.core.common.queries.GetVmTemplatesFromStorageDomainParameters)

Example 10 with NameableComparator

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

the class AsyncDataProvider method getClusterByServiceList.

public ArrayList<Cluster> getClusterByServiceList(List<Cluster> list, boolean supportsVirtService, boolean supportsGlusterService) {
    final ArrayList<Cluster> filteredList = new ArrayList<>();
    for (Cluster cluster : list) {
        if ((supportsVirtService && cluster.supportsVirtService()) || (supportsGlusterService && cluster.supportsGlusterService())) {
            filteredList.add(cluster);
        }
    }
    // sort by cluster name
    Collections.sort(filteredList, new NameableComparator());
    return filteredList;
}
Also used : ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

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