Search in sources :

Example 11 with PairQueryable

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

the class NetworkHostListModel method initAttachedInterfaces.

private void initAttachedInterfaces(final Collection<PairQueryable<VdsNetworkInterface, VDS>> items) {
    if (getEntity() == null || StringHelper.isNullOrEmpty(getEntity().getLabel()) || items == null || items.isEmpty()) {
        setItems(items);
        return;
    }
    final NetworkHostFilter filter = getViewFilterType();
    IdQueryParameters params = new IdQueryParameters(getEntity().getId());
    params.setRefresh(false);
    Frontend.getInstance().runQuery(QueryType.GetInterfacesByLabelForNetwork, params, new AsyncQuery<QueryReturnValue>(returnValueObj -> {
        if (!filter.equals(getViewFilterType())) {
            return;
        }
        attachedByLabelInterfaces = returnValueObj.getReturnValue();
        setItems(items);
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StringHelper(org.ovirt.engine.core.compat.StringHelper) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) HostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostSetupNetworksModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Comparator(java.util.Comparator) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) NetworkView(org.ovirt.engine.core.common.businessentities.network.NetworkView) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters)

Example 12 with PairQueryable

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

the class GetVdsAndNetworkInterfacesByNetworkIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VDS> vdsList = vdsDao.getAllForNetwork(getParameters().getId());
    List<VdsNetworkInterface> vdsNetworkInterfaceList = interfaceDao.getVdsInterfacesByNetworkId(getParameters().getId());
    final Map<Guid, VDS> vdsById = Entities.businessEntitiesById(vdsList);
    List<PairQueryable<VdsNetworkInterface, VDS>> vdsInterfaceVdsPairs = new ArrayList<>();
    Network network = networkDao.get(getParameters().getId());
    for (final VdsNetworkInterface vdsNetworkInterface : vdsNetworkInterfaceList) {
        vdsInterfaceVdsPairs.add(new PairQueryable<>(vdsNetworkInterface, vdsById.get(vdsNetworkInterface.getVdsId())));
        NetworkImplementationDetails vdsInterfaceNetworkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(vdsNetworkInterface, network);
        vdsNetworkInterface.setNetworkImplementationDetails(vdsInterfaceNetworkImplementationDetails);
    }
    getQueryReturnValue().setReturnValue(vdsInterfaceVdsPairs);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VDS(org.ovirt.engine.core.common.businessentities.VDS) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

Example 13 with PairQueryable

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

the class GetVmTemplatesAndNetworkInterfacesByNetworkIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VmTemplate> vmTemplateList = vmTemplateDao.getAllForNetwork(getParameters().getId());
    List<VmNetworkInterface> vmNetworkInterfaceList = vmNetworkInterfaceDao.getAllForTemplatesByNetwork(getParameters().getId());
    final Map<Guid, VmTemplate> vmTemplatesById = Entities.businessEntitiesById(vmTemplateList);
    List<PairQueryable<VmNetworkInterface, VmTemplate>> vmInterfaceVmPairs = new ArrayList<>();
    for (VmNetworkInterface vmNetworkInterface : vmNetworkInterfaceList) {
        vmInterfaceVmPairs.add(new PairQueryable<>(vmNetworkInterface, vmTemplatesById.get(vmNetworkInterface.getVmTemplateId())));
    }
    getQueryReturnValue().setReturnValue(vmInterfaceVmPairs);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 14 with PairQueryable

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

the class SubTabNetworkClusterView method createNetRoleColumn.

private AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> createNetRoleColumn() {
    return new AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public SafeHtml getValue(PairQueryable<Cluster, NetworkCluster> object) {
            List<SafeHtml> images = new LinkedList<>();
            NetworkCluster networkCluster = object.getSecond();
            if (networkCluster != null) {
                images.add(thisOrEmptyImage(networkCluster.isManagement(), managementImage));
                images.add(thisOrEmptyImage(networkCluster.isDisplay(), displayImage));
                images.add(thisOrEmptyImage(networkCluster.isMigration(), migrationImage));
                images.add(thisOrEmptyImage(networkCluster.isGluster(), glusterNwImage));
                images.add(thisOrEmptyImage(networkCluster.isDefaultRoute(), defaultRouteImage));
            }
            return MultiImageColumnHelper.getValue(images);
        }

        @Override
        public SafeHtml getTooltip(PairQueryable<Cluster, NetworkCluster> object) {
            Map<SafeHtml, String> imagesToText = new LinkedHashMap<>();
            NetworkCluster networkCluster = object.getSecond();
            if (networkCluster != null) {
                if (networkCluster.isManagement()) {
                    imagesToText.put(managementImage, constants.managementItemInfo());
                }
                if (networkCluster.isDisplay()) {
                    imagesToText.put(displayImage, constants.displayItemInfo());
                }
                if (networkCluster.isMigration()) {
                    imagesToText.put(migrationImage, constants.migrationItemInfo());
                }
                if (networkCluster.isGluster()) {
                    imagesToText.put(glusterNwImage, constants.glusterNwItemInfo());
                }
                if (networkCluster.isDefaultRoute()) {
                    imagesToText.put(defaultRouteImage, constants.defaultRouteItemInfo());
                }
            }
            return MultiImageColumnHelper.getTooltip(imagesToText);
        }
    };
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

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