Search in sources :

Example 21 with QueryParametersBase

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

the class SystemPermissionListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    QueryParametersBase params = new QueryParametersBase();
    params.setRefresh(false);
    Frontend.getInstance().runQuery(QueryType.GetSystemPermissions, params, new SetItemsAsyncQuery());
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Example 22 with QueryParametersBase

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

the class RoleListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    QueryParametersBase tempVar = new QueryParametersBase();
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetAllRoles, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<Role> filteredList = new ArrayList<>();
        for (Role item : (ArrayList<Role>) returnValue.getReturnValue()) {
            // ignore CONSUME_QUOTA_ROLE in UI
            if (item.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
                continue;
            }
            if (getItemsFilter() == null || getItemsFilter() == item.getType()) {
                filteredList.add(item);
            }
        }
        Collections.sort(filteredList, new NameableComparator());
        setItems(filteredList);
    }));
    setIsQueryFirstTime(false);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) RoleWithActionGroupsParameters(org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ActionGroupsToRoleParameter(org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter) RolesOperationsParameters(org.ovirt.engine.core.common.action.RolesOperationsParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) RolesParameterBase(org.ovirt.engine.core.common.action.RolesParameterBase) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Role(org.ovirt.engine.core.common.businessentities.Role) Collections(java.util.Collections) Role(org.ovirt.engine.core.common.businessentities.Role) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Example 23 with QueryParametersBase

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

the class ClusterPolicyListModel method fetchClusterPolicies.

private void fetchClusterPolicies() {
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        ArrayList<ClusterPolicy> list = returnValue.getReturnValue();
        Collections.sort(list, Comparator.comparing(ClusterPolicy::isLocked).reversed().thenComparing(ClusterPolicy::getName, new LexoNumericComparator()));
        setItems(list);
    });
    QueryParametersBase parametersBase = new QueryParametersBase();
    parametersBase.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetClusterPolicies, parametersBase, asyncQuery);
    setIsQueryFirstTime(false);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 24 with QueryParametersBase

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

Example 25 with QueryParametersBase

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

the class VmListModel method initRemoveDisksCheckboxes.

private void initRemoveDisksCheckboxes(final Map<Guid, EntityModel> vmsMap) {
    ArrayList<QueryParametersBase> params = new ArrayList<>();
    ArrayList<QueryType> queries = new ArrayList<>();
    for (Entry<Guid, EntityModel> entry : vmsMap.entrySet()) {
        if (entry.getValue().getIsChangable()) {
            // No point in fetching VM disks from ones that already determined
            // is unchangeable since they are already initialized
            params.add(new IdQueryParameters(entry.getKey()));
            queries.add(QueryType.GetAllDisksByVmId);
        }
    }
    // revise when refactoring org.ovirt.engine.ui.Frontend to support runMultipleQuery with a single query
    if (!params.isEmpty()) {
        Frontend.getInstance().runMultipleQueries(queries, params, result -> {
            for (int i = 0; i < result.getReturnValues().size(); i++) {
                if (result.getReturnValues().get(i).getSucceeded()) {
                    Guid vmId = ((IdQueryParameters) result.getParameters().get(i)).getId();
                    initRemoveDisksChecboxesPost(vmId, (List<Disk>) result.getReturnValues().get(i).getReturnValue());
                }
            }
        });
    }
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) QueryType(org.ovirt.engine.core.common.queries.QueryType) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Aggregations

QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)89 ArrayList (java.util.ArrayList)41 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)40 QueryType (org.ovirt.engine.core.common.queries.QueryType)37 Test (org.junit.Test)33 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)22 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)18 List (java.util.List)15 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)13 HashMap (java.util.HashMap)11 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Frontend (org.ovirt.engine.ui.frontend.Frontend)6 Collection (java.util.Collection)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5