Search in sources :

Example 16 with QueryReturnValue

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

the class RoleListModel method eventRaised.

@Override
public void eventRaised(Event ev, Object sender, EventArgs args) {
    super.eventRaised(ev, sender, args);
    if (getWindow() != null && sender == ((RoleModel) getWindow()).getIsAdminRole()) {
        if (commandType == CommandType.New) {
            List<ActionGroup> selectedActionGroups = new ArrayList<>();
            selectedActionGroups.add(ActionGroup.LOGIN);
            setAttachedActionGroups(selectedActionGroups);
        } else {
            Role role = getSelectedItem();
            Frontend.getInstance().runQuery(QueryType.GetRoleActionGroupsByRoleId, new IdQueryParameters(role.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
                publicAttachedActions = returnValue.getReturnValue();
                setAttachedActionGroups(publicAttachedActions);
            }));
        }
    }
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) 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) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList)

Example 17 with QueryReturnValue

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

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

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

the class GuideModel method checkVdsClusterChangeSucceeded.

protected void checkVdsClusterChangeSucceeded(final String searchStr, final List<ActionParametersBase> changeVdsParameterList, final List<ActionParametersBase> activateVdsParameterList) {
    final Map<Guid, Guid> hostClusterIdMap = new HashMap<>();
    for (ActionParametersBase param : changeVdsParameterList) {
        hostClusterIdMap.put(((ChangeVDSClusterParameters) param).getVdsId(), ((ChangeVDSClusterParameters) param).getClusterId());
    }
    Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<VDS> hosts = returnValue.getReturnValue();
        boolean succeeded = true;
        for (VDS host : hosts) {
            if (!host.getClusterId().equals(hostClusterIdMap.get(host.getId()))) {
                succeeded = false;
            }
        }
        if (!succeeded) {
            getWindow().stopProgress();
            cancel();
            errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostChangeClusterTimeOut());
        } else {
            activateHostsAfterClusterChange(searchStr, activateVdsParameterList);
        }
    }));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) Guid(org.ovirt.engine.core.compat.Guid) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) Map(java.util.Map) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VDS(org.ovirt.engine.core.common.businessentities.VDS) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) Timer(com.google.gwt.user.client.Timer) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 20 with QueryReturnValue

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

the class NetworkVmListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    GetVmsAndNetworkInterfacesByNetworkIdParameters params = new GetVmsAndNetworkInterfacesByNetworkIdParameters(getEntity().getId(), NetworkVmFilter.running.equals(getViewFilterType()));
    params.setRefresh(getIsQueryFirstTime());
    final NetworkVmFilter filter = getViewFilterType();
    Frontend.getInstance().runQuery(QueryType.GetVmsAndNetworkInterfacesByNetworkId, params, new AsyncQuery<QueryReturnValue>(returnValue -> {
        if (filter.equals(getViewFilterType())) {
            setItems((Collection<PairQueryable<VmNetworkInterface, VM>>) returnValue.getReturnValue());
        }
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GetVmsAndNetworkInterfacesByNetworkIdParameters(org.ovirt.engine.core.common.queries.GetVmsAndNetworkInterfacesByNetworkIdParameters) PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Comparator(java.util.Comparator) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) NetworkView(org.ovirt.engine.core.common.businessentities.network.NetworkView) RemoveVmInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.vms.RemoveVmInterfaceModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) Collection(java.util.Collection) GetVmsAndNetworkInterfacesByNetworkIdParameters(org.ovirt.engine.core.common.queries.GetVmsAndNetworkInterfacesByNetworkIdParameters)

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