Search in sources :

Example 31 with SearchParameters

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

the class AbstractBackendBaseTest method setUpGetEntityExpectations.

protected <E> void setUpGetEntityExpectations(String query, SearchType type, E entity) throws Exception {
    QueryReturnValue queryResult = new QueryReturnValue();
    SearchParameters params = new SearchParameters(query, type);
    when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenReturn(queryResult);
    enqueueInteraction(() -> verify(backend, atLeastOnce()).runQuery(eq(QueryType.Search), eqSearchParams(params)));
    queryResult.setSucceeded(true);
    List<E> entities = new ArrayList<>();
    entities.add(entity);
    queryResult.setReturnValue(entities);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList)

Example 32 with SearchParameters

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

the class HostListModel method syncSearch.

@Override
protected void syncSearch() {
    SearchParameters tempVar = new SearchParameters(applySortOptions(getModifiedSearchString()), SearchType.VDS, isCaseSensitiveSearch());
    tempVar.setMaxCount(getSearchPageSize());
    super.syncSearch(QueryType.Search, tempVar);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters)

Example 33 with SearchParameters

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

the class NetworkListModel method syncSearch.

@Override
protected void syncSearch() {
    SearchParameters tempVar = new SearchParameters(applySortOptions(getSearchString()), SearchType.Network, isCaseSensitiveSearch());
    tempVar.setMaxCount(getSearchPageSize());
    super.syncSearch(QueryType.Search, tempVar);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters)

Example 34 with SearchParameters

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

the class PoolGeneralModel method updateProperties.

private void updateProperties() {
    final VmPool pool = getEntity();
    setName(pool.getName());
    setDescription(pool.getVmPoolDescription());
    Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue result) {
            // refactor to "switch ... case...".
            if (result != null) {
                setvm((VM) result.getReturnValue());
            }
            if (getvm() != null) {
                setTemplate(vmTemplateNameRenderer.render(getvm()));
                setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(getvm().getNumOfCpus(), getvm().getNumOfSockets(), getvm().getCpuPerSocket(), getvm().getThreadsPerCpu()));
                setMonitorCount(getvm().getNumOfMonitors());
                setOS(getvm().getVmOsId());
                // $NON-NLS-1$
                setDefinedMemory(getvm().getVmMemSizeMb() + " MB");
                // $NON-NLS-1$
                setMinAllocatedMemory(getvm().getMinAllocatedMem() + " MB");
                Translator translator = EnumTranslator.getInstance();
                setDefaultDisplayType(translator.translate(getvm().getDefaultDisplayType()));
                setOrigin(translator.translate(getvm().getOrigin()));
                setUsbPolicy(translator.translate(getvm().getUsbPolicy()));
                setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
                setOptimizedForSystemProfile(translator.translate(getvm().getVmType()));
                setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
                setTimeZone(getvm().getTimeZone());
                setIsStateless(!pool.isStateful());
                setQuotaName(getvm().getQuotaName());
                setHasDefaultHost(getvm().getDedicatedVmForVdsList().size() > 0);
                if (getHasDefaultHost()) {
                    Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
                    "Host: cluster = " + getvm().getClusterName() + " sortby name", SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue1 -> {
                        // $NON-NLS-1$
                        String defaultHost1 = "";
                        ArrayList<VDS> hosts = returnValue1.getReturnValue();
                        for (VDS host : hosts) {
                            if (getvm().getDedicatedVmForVdsList().contains(host.getId())) {
                                if (defaultHost1.isEmpty()) {
                                    defaultHost1 = host.getName();
                                } else {
                                    // $NON-NLS-1$
                                    defaultHost1 += ", " + host.getName();
                                }
                            }
                        }
                        setDefaultHost(defaultHost1);
                    }));
                } else {
                    setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
                }
                if (getvm() != null) {
                    PoolGeneralModel.super.updateProperties(getvm().getId());
                }
            } else {
                setTemplate(null);
                setCpuCount(0);
                setMonitorCount(0);
                setOS(0);
                setDefinedMemory(null);
                setMinAllocatedMemory(null);
                setDefaultDisplayType(null);
                setHasDomain(false);
                setDomain(null);
                setHasTimeZone(false);
                setTimeZone(null);
                setUsbPolicy(null);
                setDefaultHost(null);
                setIsStateless(!pool.isStateful());
                // $NON-NLS-1$
                setGraphicsType("");
                // $NON-NLS-1$
                setOptimizedForSystemProfile("");
                getUpdateCompleteEvent().raise(this, EventArgs.EMPTY);
            }
        }
    }));
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Objects(java.util.Objects) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) Translator(org.ovirt.engine.ui.uicompat.Translator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) AbstractGeneralModel(org.ovirt.engine.ui.uicommonweb.models.vms.AbstractGeneralModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmTemplateNameRenderer(org.ovirt.engine.ui.uicommonweb.models.vms.VmTemplateNameRenderer) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList)

Example 35 with SearchParameters

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

the class PoolListModel method syncSearch.

@Override
protected void syncSearch() {
    SearchParameters tempVar = new SearchParameters(applySortOptions(getSearchString()), SearchType.VmPools, isCaseSensitiveSearch());
    tempVar.setMaxCount(getSearchPageSize());
    super.syncSearch(QueryType.Search, tempVar);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters)

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