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)));
}
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());
}
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);
}
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);
}
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);
}
Aggregations