Search in sources :

Example 71 with QueryReturnValue

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

the class SanStorageModelBase method discoverTargets.

private void discoverTargets() {
    if (!validateDiscoverTargetFields()) {
        return;
    }
    VDS host = getContainer().getHost().getSelectedItem();
    StorageServerConnections tempVar = new StorageServerConnections();
    tempVar.setConnection(getAddress().getEntity().trim());
    tempVar.setPort(getPort().getEntity().trim());
    tempVar.setStorageType(StorageType.ISCSI);
    // $NON-NLS-1$
    tempVar.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : "");
    // $NON-NLS-1$
    tempVar.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : "");
    DiscoverSendTargetsQueryParameters parameters = new DiscoverSendTargetsQueryParameters(host.getId(), tempVar);
    setMessage(null);
    final SanStorageModelBase model = this;
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        Object result = returnValue.getReturnValue();
        model.postDiscoverTargetsInternal(result != null ? (ArrayList<StorageServerConnections>) result : new ArrayList<>());
    }, true);
    Frontend.getInstance().runQuery(QueryType.DiscoverSendTargets, parameters, asyncQuery);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) DiscoverSendTargetsQueryParameters(org.ovirt.engine.core.common.queries.DiscoverSendTargetsQueryParameters)

Example 72 with QueryReturnValue

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

the class StorageDataCenterListModel 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.GetStorageDomainListById, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<StorageDomain> domains = returnValue.getReturnValue();
        for (StorageDomain domain : domains) {
            domain.setId(domain.getStoragePoolId());
        }
        Collections.sort(domains, Comparator.comparing(StorageDomain::getStoragePoolName, new LexoNumericComparator()));
        setItems(domains);
        setIsEmpty(getItems().size() == 0);
    }));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Comparator(java.util.Comparator) Collections(java.util.Collections) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)

Example 73 with QueryReturnValue

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

the class AbstractDiskModel method updateDiskProfiles.

private void updateDiskProfiles(StoragePool selectedItem) {
    StorageDomain storageDomain = getStorageDomain().getSelectedItem();
    if (storageDomain == null) {
        return;
    }
    Frontend.getInstance().runQuery(QueryType.GetDiskProfilesByStorageDomainId, new IdQueryParameters(storageDomain.getId()), new AsyncQuery<QueryReturnValue>(value -> setDiskProfilesList((List<DiskProfile>) value.getReturnValue())));
}
Also used : Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Event(org.ovirt.engine.ui.uicompat.Event) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) 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) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Quota(org.ovirt.engine.core.common.businessentities.Quota) VM(org.ovirt.engine.core.common.businessentities.VM) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 74 with QueryReturnValue

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

the class ImportTemplateModel method init.

public void init(final Collection<VmTemplate> externalTemplates, final Guid storageDomainId) {
    Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(createSearchPattern(externalTemplates), SearchType.VmTemplate), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue returnValue) {
            UIConstants constants = ConstantsManager.getInstance().getConstants();
            List<VmTemplate> vmtList = returnValue.getReturnValue();
            List<ImportTemplateData> templateDataList = new ArrayList<>();
            for (VmTemplate template : externalTemplates) {
                ImportTemplateData templateData = new ImportTemplateData(template);
                boolean templateExistsInSystem = vmtList.contains(template);
                templateData.setExistsInSystem(templateExistsInSystem);
                if (templateExistsInSystem) {
                    templateData.enforceClone(constants.importTemplateThatExistsInSystemMustClone());
                } else if (!template.isBaseTemplate() && findAnyVmTemplateById(vmtList, template.getBaseTemplateId()) == null) {
                    templateData.enforceClone(constants.importTemplateWithoutBaseMustClone());
                }
                templateDataList.add(templateData);
            }
            setItems(templateDataList);
            withDataCenterLoaded(storageDomainId, r -> doInit());
        }

        private VmTemplate findAnyVmTemplateById(List<VmTemplate> vmtList, Guid templateId) {
            for (VmTemplate vmt : vmtList) {
                if (templateId.equals(vmt.getId())) {
                    return vmt;
                }
            }
            return null;
        }
    }));
}
Also used : AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 75 with QueryReturnValue

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

the class StorageRegisterDiskImageListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        setItems(null);
        return;
    }
    IdQueryParameters parameters = new IdAndBooleanQueryParameters(getEntity().getId(), true);
    parameters.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetUnregisteredDisksFromDB, parameters, new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<UnregisteredDisk> unregisteredDisks = returnValue.getReturnValue();
        Collections.sort(unregisteredDisks, Comparator.comparing(UnregisteredDisk::getDiskAlias));
        ArrayList<Disk> diskItems = new ArrayList<>();
        for (UnregisteredDisk unregisteredDisk : unregisteredDisks) {
            diskItems.add(unregisteredDisk.getDiskImage());
        }
        setItems(diskItems);
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) UnregisteredDisk(org.ovirt.engine.core.common.businessentities.storage.UnregisteredDisk) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) List(java.util.List) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) IdAndBooleanQueryParameters(org.ovirt.engine.core.common.queries.IdAndBooleanQueryParameters) Comparator(java.util.Comparator) Collections(java.util.Collections) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UnregisteredDisk(org.ovirt.engine.core.common.businessentities.storage.UnregisteredDisk) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) IdAndBooleanQueryParameters(org.ovirt.engine.core.common.queries.IdAndBooleanQueryParameters) ArrayList(java.util.ArrayList) List(java.util.List)

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