Search in sources :

Example 6 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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 7 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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 8 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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 9 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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)

Example 10 with IdQueryParameters

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

the class RegisterEntityModel method updateClusterQuota.

private void updateClusterQuota(List<Cluster> clusters) {
    if (!isQuotaEnabled()) {
        return;
    }
    List<QueryType> queries = new ArrayList<>();
    List<QueryParametersBase> params = new ArrayList<>();
    for (Cluster cluster : clusters) {
        queries.add(QueryType.GetAllRelevantQuotasForCluster);
        params.add(new IdQueryParameters(cluster.getId()));
    }
    Frontend.getInstance().runMultipleQueries(queries, params, result -> {
        Map<Guid, List<Quota>> clusterQuotasMap = new HashMap<>();
        for (int i = 0; i < result.getReturnValues().size(); i++) {
            List<Quota> quotas = result.getReturnValues().get(i).getReturnValue();
            Guid clusterId = ((IdQueryParameters) result.getParameters().get(i)).getId();
            clusterQuotasMap.put(clusterId, quotas);
        }
        getClusterQuotasMap().setEntity(clusterQuotasMap);
    });
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Aggregations

IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)268 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)89 Guid (org.ovirt.engine.core.compat.Guid)80 ArrayList (java.util.ArrayList)68 StorageDomainsAndStoragePoolIdQueryParameters (org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters)62 QueryType (org.ovirt.engine.core.common.queries.QueryType)59 List (java.util.List)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)45 VM (org.ovirt.engine.core.common.businessentities.VM)42 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)36 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)26 Collection (java.util.Collection)25 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)25 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)25 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 HashMap (java.util.HashMap)22 ActionType (org.ovirt.engine.core.common.action.ActionType)21 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)19