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");
}
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);
}
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);
}
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());
}
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;
}
Aggregations