Search in sources :

Example 56 with SearchParameters

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

the class VnicProfileModel method populateDataCenters.

private void populateDataCenters(Guid dcId) {
    if (dcId == null) {
        // $NON-NLS-1$
        SearchParameters tempVar = new SearchParameters("DataCenter:", SearchType.StoragePool);
        Frontend.getInstance().runQuery(QueryType.Search, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> getDataCenters().setItems(returnValue.getReturnValue())));
    } else {
        AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<StoragePool>(returnValue -> getDataCenters().setItems(Arrays.asList(returnValue))), dcId);
        getDataCenters().setIsChangeable(false);
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) Guid(org.ovirt.engine.core.compat.Guid) GetDeviceCustomPropertiesParameters(org.ovirt.engine.core.common.queries.GetDeviceCustomPropertiesParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Network(org.ovirt.engine.core.common.businessentities.network.Network) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VersionQueryParameters(org.ovirt.engine.core.common.action.VersionQueryParameters) NetworkQoSModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkQoSModel) VnicProfileParameters(org.ovirt.engine.core.common.action.VnicProfileParameters) Objects(java.util.Objects) List(java.util.List) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Example 57 with SearchParameters

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

the class AbstractBackendCollectionResourceTest method setUpQueryExpectations.

protected void setUpQueryExpectations(String query, Object failure) throws Exception {
    QueryReturnValue queryResult = new QueryReturnValue();
    SearchParameters params = new SearchParameters(prefix + query, searchType);
    queryResult.setSucceeded(failure == null);
    if (failure == null) {
        List<Q> entities = new ArrayList<>();
        for (int i = 0; i < NAMES.length; i++) {
            entities.add(getEntity(i));
        }
        queryResult.setReturnValue(entities);
        when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenReturn(queryResult);
    } else {
        if (failure instanceof String) {
            queryResult.setExceptionString((String) failure);
            setUpL10nExpectations((String) failure);
            when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenReturn(queryResult);
        } else if (failure instanceof Exception) {
            when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenThrow((Exception) failure);
        }
    }
    enqueueInteraction(() -> verify(backend, atLeastOnce()).runQuery(eq(QueryType.Search), eqSearchParams(params)));
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 58 with SearchParameters

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

the class VmImportGeneralModel method updateProperties.

private void updateProperties() {
    VM vm = getEntity().getVm();
    updateVmNamesMap(getName().getEntity());
    editedVmId = vm.getId();
    super.updateProperties(vm.getId());
    addVmOriginalNameToMapIfMissing();
    getName().setEntity(getVmEditedName());
    getOperatingSystems().setItems(AsyncDataProvider.getInstance().getOsIds(vm.getClusterArch()));
    setDescription(vm.getVmDescription());
    // $NON-NLS-1$
    setQuotaName(vm.getQuotaName() != null ? vm.getQuotaName() : "");
    setQuotaAvailable(vm.getQuotaEnforcementType() != null && !vm.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
    setTemplate(vmTemplateNameRenderer.render(vm));
    // $NON-NLS-1$
    setDefinedMemory(vm.getVmMemSizeMb() + " MB");
    // $NON-NLS-1$
    setMinAllocatedMemory(vm.getMinAllocatedMem() + " MB");
    if (vm.isRunningOrPaused() && vm.getGuestMemoryBuffered() != null && vm.getGuestMemoryCached() != null && vm.getGuestMemoryFree() != null) {
        setGuestFreeCachedBufferedMemInfo(// $NON-NLS-1$
        (vm.getGuestMemoryFree() / 1024L) + " / " + (vm.getGuestMemoryBuffered() / 1024L) + // $NON-NLS-1$
        " / " + (vm.getGuestMemoryCached() / 1024L) + // $NON-NLS-1$
        " MB");
    } else {
        // Handled in form
        setGuestFreeCachedBufferedMemInfo(null);
    }
    setOS(AsyncDataProvider.getInstance().getOsName(vm.getVmOsId()));
    setDefaultDisplayType(translator.translate(vm.getDefaultDisplayType()));
    setIsHighlyAvailable(vm.isAutoStartup());
    setPriority(AsyncDataProvider.getInstance().priorityToString(vm.getPriority()));
    setMonitorCount(vm.getNumOfMonitors());
    setUsbPolicy(translator.translate(vm.getUsbPolicy()));
    setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(vm.getNumOfCpus(), vm.getNumOfSockets(), vm.getCpuPerSocket(), vm.getThreadsPerCpu()));
    setGuestCpuCount(vm.getGuestCpuCount());
    setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(vm.getVmOsId()));
    if (vm.getVmInit() != null) {
        setDomain(vm.getVmInit().getDomain());
    }
    setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(vm.getVmOsId()));
    setTimeZone(vm.getTimeZone());
    setHasCustomProperties(!StringHelper.isNullOrEmpty(vm.getCustomProperties()));
    setCustomProperties(getHasCustomProperties() ? constants.configured() : constants.notConfigured());
    setCompatibilityVersion(vm.getCompatibilityVersion() != null ? vm.getCompatibilityVersion().toString() : // $NON-NLS-1$
    "");
    setVmId(vm.getId().toString());
    setFqdn(vm.getFqdn());
    setHasAlert(vm.getVmPauseStatus() != VmPauseStatus.NONE && vm.getVmPauseStatus() != VmPauseStatus.NOERR);
    if (getHasAlert()) {
        setAlert(translator.translate(vm.getVmPauseStatus()));
    } else {
        setAlert(null);
    }
    setHasDefaultHost(!vm.getDedicatedVmForVdsList().isEmpty());
    if (getHasDefaultHost()) {
        Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
        "Host: cluster = " + vm.getClusterName() + " sortby name", SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> {
            // $NON-NLS-1$
            VM localVm = getEntity() != null ? getEntity().getVm() : null;
            if (localVm == null) {
                return;
            }
            ArrayList<VDS> hosts = returnValue.getReturnValue();
            for (VDS host : hosts) {
                if (localVm.getDedicatedVmForVdsList().contains(host.getId())) {
                    setDefaultHost(host.getName());
                    break;
                }
            }
        }));
    } else {
        setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
    }
    setOptimizedForSystemProfile(translator.translate(vm.getVmType()));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) VmPauseStatus(org.ovirt.engine.core.common.businessentities.VmPauseStatus) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Guid(org.ovirt.engine.core.compat.Guid) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) HashMap(java.util.HashMap) StringHelper(org.ovirt.engine.core.compat.StringHelper) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Objects(java.util.Objects) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList)

Aggregations

SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)58 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)19 Test (org.junit.Test)17 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)17 ArrayList (java.util.ArrayList)15 QueryType (org.ovirt.engine.core.common.queries.QueryType)12 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)7 Frontend (org.ovirt.engine.ui.frontend.Frontend)7 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)7 List (java.util.List)6 Guid (org.ovirt.engine.core.compat.Guid)6 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)5 UIConstants (org.ovirt.engine.ui.uicompat.UIConstants)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)4 EnumTranslator (org.ovirt.engine.ui.uicompat.EnumTranslator)4