Search in sources :

Example 26 with SearchParameters

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

the class GlusterVolumeGeoRepCreateModel method getVolumesForForceSessionCreate.

public void getVolumesForForceSessionCreate() {
    GlusterVolumeGeoRepCreateModel.this.startProgress(constants.fetchingDataMessage());
    // $NON-NLS-1$
    SearchParameters volumesSearchParameters = new SearchParameters("Volumes:", SearchType.GlusterVolume, false);
    volumesSearchParameters.setRefresh(true);
    Frontend.getInstance().runQuery(QueryType.Search, volumesSearchParameters, new AsyncQuery<QueryReturnValue>(returnValue -> showAvailableVolumes(returnValue)));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Pair(org.ovirt.engine.core.common.utils.Pair) Model(org.ovirt.engine.ui.uicommonweb.models.Model) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue)

Example 27 with SearchParameters

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

the class AlertListModel method syncSearch.

@Override
protected void syncSearch() {
    // $NON-NLS-1$
    SearchParameters tempVar = new SearchParameters("Events: severity=alert", SearchType.AuditLog);
    tempVar.setMaxCount(getSearchPageSize());
    tempVar.setRefresh(false);
    SearchParameters searchParameters = tempVar;
    Frontend.getInstance().runQuery(QueryType.Search, searchParameters, new SetItemsAsyncQuery());
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters)

Example 28 with SearchParameters

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

the class EventListModel method refreshModel.

protected void refreshModel() {
    AsyncQuery<QueryReturnValue> query = new AsyncQuery<>(returnValue -> {
        List<AuditLog> newEvents = returnValue.getReturnValue();
        List<AuditLog> currentEvents = (List<AuditLog>) getItems();
        if (isDisplayEventsOnly()) {
            newEvents = newEvents.stream().filter(e -> e.getSeverity() != AuditLogSeverity.ALERT).collect(Collectors.toList());
        }
        if (!newEvents.isEmpty() && currentEvents != null && (currentEvents.isEmpty() || !currentEvents.get(0).equals(newEvents.get(0)))) {
            // We received some new events, tell the active models to update.
            RefreshActiveModelEvent.fire(EventListModel.this, false);
        }
        EventListModel.this.setItems(newEvents);
        EventListModel.this.setLastEvent(Linq.firstOrNull(newEvents));
    });
    SearchParameters params = new SearchParameters(applySortOptions(getSearchString()), SearchType.AuditLog, isCaseSensitiveSearch());
    params.setMaxCount(getSearchPageSize());
    params.setRefresh(false);
    Frontend.getInstance().runQuery(QueryType.Search, params, query);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) List(java.util.List) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 29 with SearchParameters

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

the class DiskListModel method syncSearch.

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

Example 30 with SearchParameters

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

the class VmGeneralModel method updateProperties.

private void updateProperties() {
    VM vm = getEntity();
    super.updateProperties(vm.getId());
    setName(vm.getName());
    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()));
    EnumTranslator translator = EnumTranslator.getInstance();
    setDefaultDisplayType(translator.translate(vm.getDefaultDisplayType()));
    setOrigin(translator.translate(vm.getOrigin()));
    setIsHighlyAvailable(vm.isAutoStartup());
    setPriority(AsyncDataProvider.getInstance().priorityToString(vm.getPriority()));
    setOptimizedForSystemProfile(translator.translate(vm.getVmType()));
    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(!StringHelper.isNullOrEmpty(vm.getTimeZone()));
    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);
    }
    setHasCreatedByUser(vm.getCreatedByUserId() != null);
    if (getHasCreatedByUser()) {
        Frontend.getInstance().runQuery(QueryType.GetDbUserByUserId, new IdQueryParameters(vm.getCreatedByUserId()), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

            @Override
            public void onSuccess(QueryReturnValue result) {
                DbUser dbUser = result.getReturnValue();
                if (dbUser != null) {
                    setCreatedByUser(getUserName(dbUser));
                }
            }

            private String getUserName(DbUser dbUser) {
                if (StringHelper.isNotNullOrEmpty(dbUser.getFirstName()) || StringHelper.isNotNullOrEmpty(dbUser.getLastName())) {
                    return messages.userName(nullToEmpty(dbUser.getFirstName()), nullToEmpty(dbUser.getLastName()));
                }
                return dbUser.getLoginName();
            }

            private String nullToEmpty(String val) {
                return val == null ? "" : val;
            }
        }));
    }
    setHasDefaultHost(vm.getDedicatedVmForVdsList().size() > 0);
    if (getHasDefaultHost()) {
        Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
        "Host: cluster = " + vm.getClusterName() + " sortby name", SearchType.VDS).withoutRefresh(), new AsyncQuery<QueryReturnValue>(returnValue -> {
            // $NON-NLS-1$
            VM localVm = getEntity();
            if (localVm == null) {
                return;
            }
            ArrayList<VDS> hosts = returnValue.getReturnValue();
            if (localVm.getDedicatedVmForVdsList().size() > 0) {
                String defaultHost = "";
                for (VDS host : hosts) {
                    if (localVm.getDedicatedVmForVdsList().contains(host.getId())) {
                        if (defaultHost.isEmpty()) {
                            defaultHost = host.getName();
                        } else {
                            // $NON-NLS-1$
                            defaultHost += ", " + host.getName();
                        }
                    }
                }
                setDefaultHost(defaultHost);
            }
        }));
    } else {
        setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
    }
    final String guestCpuType = vm.getCpuName() != null ? vm.getCpuName() : (vm.getCustomCpuName() != null ? vm.getCustomCpuName() : vm.getClusterCpuName());
    setGuestCpuType(guestCpuType);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) 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) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) VmPauseStatus(org.ovirt.engine.core.common.businessentities.VmPauseStatus) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StringHelper(org.ovirt.engine.core.compat.StringHelper) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Objects(java.util.Objects) VM(org.ovirt.engine.core.common.businessentities.VM) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) ArrayList(java.util.ArrayList) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

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