Search in sources :

Example 21 with QueryReturnValue

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

the class PoolDiskListModel method onEntityChanged.

@Override
protected void onEntityChanged() {
    super.onEntityChanged();
    VmPool pool = getEntity();
    if (pool != null) {
        Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<QueryReturnValue>(result -> {
            if (result != null) {
                VM vm = result.getReturnValue();
                if (vm == null) {
                    return;
                }
                setVM(vm);
                syncSearch();
            }
        }));
    }
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) VmDiskListModelBase(org.ovirt.engine.ui.uicommonweb.models.vms.VmDiskListModelBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 22 with QueryReturnValue

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

the class PoolInterfaceListModel method onEntityChanged.

@Override
protected void onEntityChanged() {
    super.onEntityChanged();
    VmPool pool = getEntity();
    if (pool != null) {
        Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<QueryReturnValue>(result -> {
            if (result != null) {
                VM vm = result.getReturnValue();
                if (vm == null) {
                    return;
                }
                syncSearch(QueryType.GetVmInterfacesByVmId, new IdQueryParameters(vm.getId()));
            }
        }));
    }
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 23 with QueryReturnValue

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

the class QuotaUserListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    IdQueryParameters param = new IdQueryParameters(getEntity().getId());
    param.setRefresh(getIsQueryFirstTime());
    param.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetPermissionsToConsumeQuotaByQuotaId, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<Permission> list = returnValue.getReturnValue();
        Map<Guid, Permission> map = new HashMap<>();
        for (Permission permission : list) {
            // filter out sys-admin and dc admin from consumers sub-tab
            if (permission.getRoleId().equals(ApplicationGuids.superUser.asGuid()) || permission.getRoleId().equals(ApplicationGuids.dataCenterAdmin.asGuid())) {
                continue;
            }
            if (!map.containsKey(permission.getAdElementId())) {
                map.put(permission.getAdElementId(), permission);
            } else {
                if (map.get(permission.getAdElementId()).getRoleId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
                    map.put(permission.getAdElementId(), permission);
                }
            }
        }
        list.clear();
        for (Permission permission : map.values()) {
            list.add(permission);
        }
        setItems(list);
    }));
    setIsQueryFirstTime(false);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) 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) PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Permission(org.ovirt.engine.core.common.businessentities.Permission) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) AdElementListModel(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Quota(org.ovirt.engine.core.common.businessentities.Quota) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with QueryReturnValue

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

the class QuotaVmListModel 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.GetVmsRelatedToQuotaId, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        setItems((ArrayList<VM>) returnValue.getReturnValue());
        setIsEmpty(((List) getItems()).size() == 0);
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) Quota(org.ovirt.engine.core.common.businessentities.Quota) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList)

Example 25 with QueryReturnValue

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

the class DownloadImageHandler method start.

public void start() {
    Frontend.getInstance().runAction(ActionType.TransferDiskImage, createInitParams(), result -> {
        if (result.getReturnValue().getSucceeded()) {
            Guid transferId = result.getReturnValue().getActionReturnValue();
            Frontend.getInstance().runQuery(QueryType.GetImageTransferById, new IdQueryParameters(transferId), new AsyncQuery<QueryReturnValue>(returnValue -> {
                ImageTransfer imageTransfer = returnValue.getReturnValue();
                initiateDownload(imageTransfer);
            }));
        }
    }, this);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ImageTransferPhase(org.ovirt.engine.core.common.businessentities.storage.ImageTransferPhase) Predicate(java.util.function.Predicate) Guid(org.ovirt.engine.core.compat.Guid) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) Frame(com.google.gwt.user.client.ui.Frame) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) TransferType(org.ovirt.engine.core.common.businessentities.storage.TransferType) Logger(java.util.logging.Logger) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) RootPanel(com.google.gwt.user.client.ui.RootPanel) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) TransferDiskImageParameters(org.ovirt.engine.core.common.action.TransferDiskImageParameters) Style(com.google.gwt.dom.client.Style) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) AuditLogType(org.ovirt.engine.core.common.AuditLogType) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

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