Search in sources :

Example 6 with PairQueryable

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

the class SubTabNetworkClusterView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> nameColumn = new AbstractLinkColumn<PairQueryable<Cluster, NetworkCluster>>(new FieldUpdater<PairQueryable<Cluster, NetworkCluster>, String>() {

        @Override
        public void update(int index, PairQueryable<Cluster, NetworkCluster> cluster, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), cluster.getFirst().getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "400px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> versionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "130px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> attachedColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getSecond() != null;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    attachedColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(attachedColumn, constants.attachedNetworkCluster(), "120px");
    NetworkClusterStatusColumn statusColumn = new NetworkClusterStatusColumn();
    statusColumn.makeSortable(new SimpleStatusColumnComparator<>(statusColumn));
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.networkStatus(), "120px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> netRequiredColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            if (object.getSecond() != null) {
                return object.getSecond().isRequired();
            }
            return false;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    netRequiredColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(netRequiredColumn, constants.requiredNetCluster(), "120px");
    AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> netRoleColumn = createNetRoleColumn();
    netRoleColumn.makeSortable(new NetRoleColumnComparator());
    // $NON-NLS-1$
    getTable().addColumn(netRoleColumn, constants.roleNetCluster(), "120px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> descriptionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionCluster(), "400px");
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkClusterStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkClusterStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 7 with PairQueryable

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

the class GetVmsAndNetworkInterfacesByNetworkIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VM> vmList = vmDao.getAllForNetwork(getParameters().getId());
    List<VmNetworkInterface> vmNetworkInterfaceList = vmNetworkInterfaceDao.getAllForNetwork(getParameters().getId());
    final Map<Guid, VM> vmsById = Entities.businessEntitiesById(vmList);
    List<PairQueryable<VmNetworkInterface, VM>> vmInterfaceVmPairs = new ArrayList<>();
    for (VmNetworkInterface vmNetworkInterface : vmNetworkInterfaceList) {
        VM vm = vmsById.get(vmNetworkInterface.getVmId());
        if (getParameters().getRunningVms() == null || getParameters().getRunningVms().equals(vm.isRunning())) {
            vmInterfaceVmPairs.add(new PairQueryable<>(vmNetworkInterface, vm));
        }
    }
    getQueryReturnValue().setReturnValue(vmInterfaceVmPairs);
}
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) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with PairQueryable

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

the class GetClustersAndNetworksByNetworkIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<PairQueryable<Cluster, NetworkCluster>> networkClusterPairs = new ArrayList<>();
    Network network = networkDao.get(getParameters().getId());
    if (network != null && network.getDataCenterId() != null) {
        List<Cluster> clusters = clusterDao.getAllForStoragePool(network.getDataCenterId());
        List<NetworkCluster> networkClusters = networkClusterDao.getAllForNetwork(getParameters().getId());
        final Map<NetworkClusterId, NetworkCluster> networkClustersById = Entities.businessEntitiesById(networkClusters);
        for (Cluster cluster : clusters) {
            networkClusterPairs.add(new PairQueryable<>(cluster, networkClustersById.get(new NetworkClusterId(cluster.getId(), getParameters().getId()))));
        }
    }
    getQueryReturnValue().setReturnValue(networkClusterPairs);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) 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) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 9 with PairQueryable

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

the class NicActivateStatusColumn method getTooltip.

@Override
public SafeHtml getTooltip(T object) {
    VmNetworkInterface vnic = null;
    if (object instanceof VmNetworkInterface) {
        vnic = (VmNetworkInterface) object;
    } else if (object instanceof PairQueryable && ((PairQueryable) object).getFirst() instanceof VmNetworkInterface) {
        vnic = ((PairQueryable<VmNetworkInterface, VM>) object).getFirst();
    }
    // $NON-NLS-1$
    StringBuilder tooltip = new StringBuilder("");
    boolean vnicExist = vnic != null;
    if (vnicExist && vnic.isPlugged()) {
        tooltip = tooltip.append(templates.cardStatus(constants.pluggedNetworkInterface()).asString());
    } else {
        tooltip = tooltip.append(templates.cardStatus(constants.unpluggedNetworkInterface()).asString());
    }
    // $NON-NLS-1$
    tooltip = tooltip.append("<BR>");
    if (vnicExist && vnic.isLinked()) {
        tooltip = tooltip.append(templates.linkState(constants.linkedNetworkInterface()).asString());
    } else {
        tooltip = tooltip.append(templates.linkState(constants.unlinkedNetworkInterface()).asString());
    }
    return SafeHtmlUtils.fromTrustedString(tooltip.toString());
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)

Example 10 with PairQueryable

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

the class NetworkClusterListModel method createManageList.

private ClusterNetworkManageModel createManageList() {
    List<ClusterNetworkModel> networkManageModelList = new ArrayList<>();
    Iterable<PairQueryable<Cluster, NetworkCluster>> items = getItems();
    for (PairQueryable<Cluster, NetworkCluster> item : items) {
        Network network = (Network) Cloner.clone(getEntity());
        if (item.getSecond() != null) {
            network.setCluster((NetworkCluster) Cloner.clone(item.getSecond()));
        }
        ClusterNetworkModel networkManageModel = new ClusterNetworkModel(network) {

            @Override
            public String getDisplayedName() {
                return getCluster().getName();
            }
        };
        networkManageModel.setCluster((Cluster) Cloner.clone(item.getFirst()));
        networkManageModelList.add(networkManageModel);
    }
    Collections.sort(networkManageModelList, manageModelComparator);
    ClusterNetworkManageModel listModel = new ClusterNetworkManageModel(this) {

        @Override
        public boolean isMultiCluster() {
            return true;
        }
    };
    listModel.setItems(networkManageModelList);
    return listModel;
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) ClusterNetworkModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterNetworkModel) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) ClusterNetworkManageModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterNetworkManageModel) 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)

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