Search in sources :

Example 86 with QueryReturnValue

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

the class RemoveQosModel method handleSetMessageQueryResult.

protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
    Map<String, String> entitiesAndQos = new HashMap<>();
    setHelpTag(getRemoveQosHelpTag());
    setHashName(getRemoveQosHashName());
    int index = 0;
    for (QueryReturnValue returnValue : result.getReturnValues()) {
        for (Nameable entity : (List<Nameable>) returnValue.getReturnValue()) {
            entitiesAndQos.put(entity.getName(), sourceListModel.getSelectedItems().get(index).getName());
        }
        index++;
    }
    if (entitiesAndQos.isEmpty()) {
        ArrayList<String> list = new ArrayList<>();
        for (T item : sourceListModel.getSelectedItems()) {
            list.add(item.getName());
        }
        setItems(list);
    } else {
        setMessage(getRemoveQosMessage(entitiesAndQos.size()));
        ArrayList<String> list = new ArrayList<>();
        for (Entry<String, String> item : entitiesAndQos.entrySet()) {
            // $NON-NLS-1$ //$NON-NLS-2$
            list.add(item.getKey() + " (" + item.getValue() + ")");
        }
        setItems(list);
    }
}
Also used : Nameable(org.ovirt.engine.core.common.businessentities.Nameable) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 87 with QueryReturnValue

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

the class RemoveStorageQosModel method handleSetMessageQueryResult.

protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
    setHelpTag(getRemoveQosHelpTag());
    setHashName(getRemoveQosHashName());
    int index = 0;
    int numberOfTimesUsedByDiskProfiles = 0;
    ArrayList<String> list = new ArrayList<>();
    for (QueryReturnValue returnValue : result.getReturnValues()) {
        List<Nameable> diskProfileEntities = returnValue.getReturnValue();
        String qosName = sourceListModel.getSelectedItems().get(index).getName();
        if (diskProfileEntities.size() == 0) {
            list.add(qosName);
        } else {
            numberOfTimesUsedByDiskProfiles += diskProfileEntities.size();
            List<String> diskProfileNames = new ArrayList<>();
            for (Nameable diskProfileEntity : diskProfileEntities) {
                String diskProfileName = diskProfileEntity.getName();
                diskProfileNames.add(diskProfileName);
            }
            // $NON-NLS-1$
            String diskProfileNamesAsString = String.join(", ", diskProfileNames);
            list.add(ConstantsManager.getInstance().getMessages().removeStorageQoSItem(qosName, diskProfileNamesAsString));
        }
        index++;
    }
    setMessage(getRemoveQosMessage(numberOfTimesUsedByDiskProfiles));
    setItems(list);
}
Also used : Nameable(org.ovirt.engine.core.common.businessentities.Nameable) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList)

Example 88 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue 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 89 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue 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 90 with QueryReturnValue

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

the class ImportVmsModel method loadVmsFromExportDomain.

public void loadVmsFromExportDomain() {
    clearProblem();
    startProgress();
    Frontend.getInstance().runQuery(QueryType.GetVmsFromExportDomain, new GetAllFromExportDomainQueryParameters(getDataCenters().getSelectedItem().getId(), exportDomain.getEntity().getId()), new AsyncQuery<QueryReturnValue>(returnValue -> updateVms(returnValue.<List<VM>>getReturnValue())));
}
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) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Aggregations

QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)265 ArrayList (java.util.ArrayList)123 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)97 QueryType (org.ovirt.engine.core.common.queries.QueryType)85 List (java.util.List)74 Guid (org.ovirt.engine.core.compat.Guid)66 Frontend (org.ovirt.engine.ui.frontend.Frontend)64 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)54 VM (org.ovirt.engine.core.common.businessentities.VM)49 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)47 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)42 HashMap (java.util.HashMap)40 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 Test (org.junit.Test)38 Collection (java.util.Collection)34 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)33 Map (java.util.Map)31 ActionType (org.ovirt.engine.core.common.action.ActionType)31 VDS (org.ovirt.engine.core.common.businessentities.VDS)31