Search in sources :

Example 1 with PairQueryable

use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.

the class NetworkVmListModel method remove.

private void remove() {
    if (getWindow() != null) {
        return;
    }
    List<VmNetworkInterface> vnics = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        PairQueryable<VmNetworkInterface, VM> pair = (PairQueryable<VmNetworkInterface, VM>) item;
        vnics.add(pair.getFirst());
    }
    RemoveVmInterfaceModel model = new RemoveVmInterfaceModel(this, vnics, true);
    setWindow(model);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) RemoveVmInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.vms.RemoveVmInterfaceModel) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList)

Example 2 with PairQueryable

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

Example 3 with PairQueryable

use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.

the class NetworkVmListModel method updateActionAvailability.

private void updateActionAvailability() {
    ArrayList<VM> vms = new ArrayList<>();
    Iterable<PairQueryable<VmNetworkInterface, VM>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList();
    for (PairQueryable<VmNetworkInterface, VM> item : selectedItems) {
        vms.add(item.getSecond());
    }
    getRemoveCommand().setIsExecutionAllowed(ActionUtils.canExecute(vms, VM.class, ActionType.RemoveVmInterface) && getSelectedItems() != null && !getSelectedItems().isEmpty() && canRemoveVnics());
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList)

Example 4 with PairQueryable

use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.

the class NetworkHostListModel method updateActionAvailability.

private void updateActionAvailability() {
    Collection<PairQueryable<VdsNetworkInterface, VDS>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList();
    getSetupNetworksCommand().setIsExecutionAllowed(selectedItems.size() == 1);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) ArrayList(java.util.ArrayList)

Example 5 with PairQueryable

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

Aggregations

PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)14 ArrayList (java.util.ArrayList)11 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)4 Collection (java.util.Collection)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Network (org.ovirt.engine.core.common.businessentities.network.Network)3 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 Guid (org.ovirt.engine.core.compat.Guid)3 Comparator (java.util.Comparator)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 NetworkView (org.ovirt.engine.core.common.businessentities.network.NetworkView)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Frontend (org.ovirt.engine.ui.frontend.Frontend)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2