Search in sources :

Example 81 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class RemoveQosModel method setMessage.

private void setMessage() {
    ArrayList<QueryParametersBase> parameters = new ArrayList<>();
    ArrayList<QueryType> queryTypes = new ArrayList<>();
    for (T qos : sourceListModel.getSelectedItems()) {
        QueryParametersBase parameter = new IdQueryParameters(qos.getId());
        parameters.add(parameter);
        queryTypes.add(getUsingEntitiesByQosIdQueryType());
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> handleSetMessageQueryResult(result));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 82 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class DiskStorageListModel method syncSearch.

@Override
protected void syncSearch() {
    DiskImage diskImage = getEntity();
    if (diskImage == null) {
        return;
    }
    IdQueryParameters getStorageDomainsByImageIdParameters = new IdQueryParameters(diskImage.getImageId());
    getStorageDomainsByImageIdParameters.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetStorageDomainsByImageId, getStorageDomainsByImageIdParameters, new SetItemsAsyncQuery());
    setIsQueryFirstTime(false);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 83 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class RemoveNetworkQoSModel method setMessage.

private void setMessage() {
    ArrayList<QueryParametersBase> parameters = new ArrayList<>();
    ArrayList<QueryType> queryTypes = new ArrayList<>();
    for (Object networkQoS : sourceListModel.getSelectedItems()) {
        QueryParametersBase parameter = new IdQueryParameters(((NetworkQoS) networkQoS).getId());
        parameters.add(parameter);
        queryTypes.add(QueryType.GetVnicProfilesByNetworkQosId);
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> {
        ArrayList<VnicProfileView> vnicProfiles = new ArrayList<>();
        setHelpTag(HelpTag.remove_network_qos);
        // $NON-NLS-1$
        setHashName("remove_network_qos");
        for (QueryReturnValue returnValue : result.getReturnValues()) {
            vnicProfiles.addAll((ArrayList<VnicProfileView>) returnValue.getReturnValue());
        }
        if (vnicProfiles.isEmpty()) {
            ArrayList<String> list = new ArrayList<>();
            for (Object item : sourceListModel.getSelectedItems()) {
                NetworkQoS i = (NetworkQoS) item;
                list.add(i.getName());
            }
            setItems(list);
        } else {
            setMessage(ConstantsManager.getInstance().getMessages().removeNetworkQoSMessage(vnicProfiles.size()));
            ArrayList<String> list = new ArrayList<>();
            for (VnicProfileView item : vnicProfiles) {
                list.add(item.getName());
            }
            setItems(list);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 84 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderModel method initQuotaForStorageDomains.

private void initQuotaForStorageDomains() {
    List<QueryType> queryTypeList = new ArrayList<>();
    List<QueryParametersBase> queryParamsList = new ArrayList<>();
    for (StorageDomain storage : getStorage().getItems()) {
        queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
        queryParamsList.add(new IdQueryParameters(storage.getId()));
    }
    storageQuotaMap = new HashMap<>();
    Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
        Iterator<QueryReturnValue> returnValuesIter = result.getReturnValues().iterator();
        Iterator<StorageDomain> domainsIter = getStorage().getItems().iterator();
        boolean noQuota = true;
        while (domainsIter.hasNext()) {
            ArrayList<Quota> quotaList = returnValuesIter.next().getReturnValue();
            noQuota = noQuota && quotaList.isEmpty();
            storageQuotaMap.put(domainsIter.next().getId(), quotaList);
        }
        if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
            showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
        }
        initDisksStorageDomainsList();
    });
}
Also used : ArrayList(java.util.ArrayList) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 85 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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)

Aggregations

IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)268 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)89 Guid (org.ovirt.engine.core.compat.Guid)80 ArrayList (java.util.ArrayList)68 StorageDomainsAndStoragePoolIdQueryParameters (org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters)62 QueryType (org.ovirt.engine.core.common.queries.QueryType)59 List (java.util.List)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)45 VM (org.ovirt.engine.core.common.businessentities.VM)42 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)36 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)26 Collection (java.util.Collection)25 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)25 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)25 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 HashMap (java.util.HashMap)22 ActionType (org.ovirt.engine.core.common.action.ActionType)21 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)19