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);
}
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);
}
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);
}));
}
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);
}
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;
}
Aggregations