Search in sources :

Example 66 with QueryReturnValue

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

the class BaseImportNetworksModel method onProviderChosen.

private void onProviderChosen() {
    final Provider<?> provider = providers.getSelectedItem();
    if (provider == null) {
        return;
    }
    startProgress();
    AsyncQuery<List<StoragePool>> dataCenterQuery = new AsyncQuery<>(returnValue -> {
        final List<StoragePool> dataCenters = new LinkedList<>(returnValue);
        Collections.sort(dataCenters, new NameableComparator());
        AsyncQuery<QueryReturnValue> externalNetworksQuery = new AsyncQuery<>(queryReturnValue -> {
            if (queryReturnValue.getSucceeded()) {
                Map<Network, Set<Guid>> externalNetworkToDataCenters = queryReturnValue.getReturnValue();
                providerNetworks.setItems(getExternalNetworks(externalNetworkToDataCenters, dataCenters));
                importedNetworks.setItems(new LinkedList<ExternalNetwork>());
            } else {
                final ErrorPopupManager popupManager = (ErrorPopupManager) TypeResolver.getInstance().resolve(ErrorPopupManager.class);
                popupManager.show(ConstantsManager.getInstance().getMessages().failedToListExternalNetworks(queryReturnValue.getExceptionMessage()));
            }
            stopProgress();
        }, true);
        AsyncDataProvider.getInstance().getExternalNetworksByProviderId(externalNetworksQuery, provider.getId());
    });
    AsyncDataProvider.getInstance().getDataCenterList(dataCenterQuery);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Set(java.util.Set) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) LinkedList(java.util.LinkedList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Network(org.ovirt.engine.core.common.businessentities.network.Network) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork)

Example 67 with QueryReturnValue

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

the class NetworkHostListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    final NetworkHostFilter filter = getViewFilterType();
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        if (filter.equals(getViewFilterType())) {
            final Iterable returnList = returnValue.getReturnValue();
            if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
                final List<PairQueryable<VdsNetworkInterface, VDS>> items = new ArrayList<>();
                for (Object obj : returnList) {
                    items.add(new PairQueryable<VdsNetworkInterface, VDS>(null, (VDS) obj));
                }
                setItems(items);
            } else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
                initAttachedInterfaces((Collection<PairQueryable<VdsNetworkInterface, VDS>>) returnList);
            }
        }
    });
    IdQueryParameters params = new IdQueryParameters(getEntity().getId());
    params.setRefresh(getIsQueryFirstTime());
    if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
        Frontend.getInstance().runQuery(QueryType.GetVdsWithoutNetwork, params, asyncQuery);
    } else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
        Frontend.getInstance().runQuery(QueryType.GetVdsAndNetworkInterfacesByNetworkId, params, asyncQuery);
    }
    setIsQueryFirstTime(false);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Collection(java.util.Collection)

Example 68 with QueryReturnValue

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

the class FenceAgentModel method test.

/**
 * Execute the fence agent test.
 */
public void test() {
    validatePmModels();
    if (!isValid()) {
        return;
    }
    setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
    getTestCommand().setIsExecutionAllowed(false);
    Cluster cluster = getHost().getCluster().getSelectedItem();
    GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
    FenceAgent agent = new FenceAgent();
    if (getHost().getHostId() != null) {
        param.setVdsId(getHost().getHostId());
    }
    agent.setOrder(getOrder().getEntity());
    agent.setIp(getManagementIp().getEntity());
    agent.setType(getPmType().getSelectedItem());
    agent.setUser(getPmUserName().getEntity());
    agent.setPassword(getPmPassword().getEntity());
    agent.setPort(getPmPort().getEntity());
    agent.setOptionsMap(getPmOptionsMap());
    param.setAgent(agent);
    param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
    param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
    param.setVdsName(getHost().getName().getEntity());
    param.setHostName(getHost().getHost().getEntity());
    param.setClusterId(cluster.getId());
    Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
        String msg;
        if (returnValue == null) {
            msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
        } else {
            FenceOperationResult result = returnValue.getReturnValue();
            if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
                msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
            } else {
                msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
            }
        }
        setMessage(msg);
        getTestCommand().setIsExecutionAllowed(true);
    }, true));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) QueryType(org.ovirt.engine.core.common.queries.QueryType) PowerStatus(org.ovirt.engine.core.common.businessentities.pm.PowerStatus) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) Comparator(java.util.Comparator) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters)

Example 69 with QueryReturnValue

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

the class AdElementListModel method syncSearchGroups.

private void syncSearchGroups() {
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(queryReturnValue -> {
        if (handleQueryError(queryReturnValue)) {
            return;
        }
        HashSet<String> excludeUsers = new HashSet<>();
        if (getExcludeItems() != null) {
            for (DbUser item : getExcludeItems()) {
                excludeUsers.add(item.getExternalId());
            }
        }
        setgroups(new ArrayList<>());
        addGroupsToModel(queryReturnValue, excludeUsers);
        onAdGroupsLoaded();
    });
    asyncQuery.setHandleFailure(true);
    findGroups(// $NON-NLS-1$ //$NON-NLS-2$
    "name=" + (StringHelper.isNullOrEmpty(getSearchString()) ? "*" : getSearchString()), asyncQuery);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HashSet(java.util.HashSet) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 70 with QueryReturnValue

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

the class SanStorageModelBase method updateInternal.

protected void updateInternal() {
    if (!(getContainer().isNewStorage() || getContainer().isStorageActive())) {
        return;
    }
    VDS host = getContainer().getHost().getSelectedItem();
    if (host == null) {
        proposeDiscover();
        return;
    }
    final Collection<EntityModel<?>> prevSelected = Linq.findSelectedItems((Collection<EntityModel<?>>) getSelectedItem());
    clearItems();
    initializeItems(null, null);
    final SanStorageModelBase model = this;
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(response -> {
        if (response.getSucceeded()) {
            setValuesForMaintenance(model);
            model.applyData((ArrayList<LUNs>) response.getReturnValue(), false, prevSelected, isInMaintenance, metadata);
            model.initLunSelection();
            // $NON-NLS-1$
            model.setGetLUNsFailure("");
            model.stopProgress();
        } else {
            model.setGetLUNsFailure(ConstantsManager.getInstance().getConstants().couldNotRetrieveLUNsLunsFailure());
        }
    }, true);
    Frontend.getInstance().runQuery(QueryType.GetDeviceList, new GetDeviceListQueryParameters(host.getId(), getType(), false, null, false), asyncQuery);
    getContainer().startProgress();
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

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